pub struct Manager<W: Deref, SP: Deref, B: Deref, S: Deref, O: Deref, T: Deref, F: Deref, X: ContractSigner, L: Deref>where
W::Target: Wallet,
SP::Target: ContractSignerProvider<Signer = X>,
B::Target: Blockchain,
S::Target: Storage,
O::Target: Oracle,
T::Target: Time,
F::Target: FeeEstimator,
L::Target: Logger,{ /* private fields */ }Expand description
Used to create and update DLCs.
Implementations§
Source§impl<W: Deref, SP: Deref, B: Deref, S: Deref, O: Deref, T: Deref, F: Deref, X: ContractSigner, L: Deref> Manager<W, Arc<CachedContractSignerProvider<SP, X>>, B, S, O, T, F, X, L>
impl<W: Deref, SP: Deref, B: Deref, S: Deref, O: Deref, T: Deref, F: Deref, X: ContractSigner, L: Deref> Manager<W, Arc<CachedContractSignerProvider<SP, X>>, B, S, O, T, F, X, L>
Sourcepub async fn new(
wallet: W,
signer_provider: SP,
blockchain: B,
store: S,
oracles: HashMap<XOnlyPublicKey, O>,
time: T,
fee_estimator: F,
logger: L,
) -> Result<Self, Error>
pub async fn new( wallet: W, signer_provider: SP, blockchain: B, store: S, oracles: HashMap<XOnlyPublicKey, O>, time: T, fee_estimator: F, logger: L, ) -> Result<Self, Error>
Create a new Manager struct.
Sourcepub async fn on_dlc_message(
&self,
msg: &DlcMessage,
counter_party: PublicKey,
) -> Result<Option<DlcMessage>, Error>
pub async fn on_dlc_message( &self, msg: &DlcMessage, counter_party: PublicKey, ) -> Result<Option<DlcMessage>, Error>
Function called to pass a DlcMessage to the Manager.
Sourcepub async fn send_splice_offer(
&self,
contract_input: &ContractInput,
counter_party: PublicKey,
contract_id: &ContractId,
) -> Result<OfferDlc, Error>
pub async fn send_splice_offer( &self, contract_input: &ContractInput, counter_party: PublicKey, contract_id: &ContractId, ) -> Result<OfferDlc, Error>
Create a new spliced offer
Sourcepub async fn send_splice_offer_with_announcements(
&self,
contract_input: &ContractInput,
counter_party: PublicKey,
contract_id: &ContractId,
oracle_announcements: Vec<Vec<OracleAnnouncement>>,
) -> Result<OfferDlc, Error>
pub async fn send_splice_offer_with_announcements( &self, contract_input: &ContractInput, counter_party: PublicKey, contract_id: &ContractId, oracle_announcements: Vec<Vec<OracleAnnouncement>>, ) -> Result<OfferDlc, Error>
Creates a new offer DLC using an existing DLC as an input. The new DLC MUST use a Confirmed contract as an input.
Sourcepub async fn send_offer(
&self,
contract_input: &ContractInput,
counter_party: PublicKey,
) -> Result<OfferDlc, Error>
pub async fn send_offer( &self, contract_input: &ContractInput, counter_party: PublicKey, ) -> Result<OfferDlc, Error>
Function called to create a new DLC. The offered contract will be stored and an OfferDlc message returned.
This function will fetch the oracle announcements from the oracle.
Sourcepub async fn send_offer_with_announcements(
&self,
contract_input: &ContractInput,
counter_party: PublicKey,
oracle_announcements: Vec<Vec<OracleAnnouncement>>,
) -> Result<OfferDlc, Error>
pub async fn send_offer_with_announcements( &self, contract_input: &ContractInput, counter_party: PublicKey, oracle_announcements: Vec<Vec<OracleAnnouncement>>, ) -> Result<OfferDlc, Error>
Function called to create a new DLC. The offered contract will be stored and an OfferDlc message returned.
This function allows to pass the oracle announcements directly instead of fetching them from the oracle.
Sourcepub async fn accept_contract_offer(
&self,
contract_id: &ContractId,
) -> Result<(ContractId, PublicKey, AcceptDlc), Error>
pub async fn accept_contract_offer( &self, contract_id: &ContractId, ) -> Result<(ContractId, PublicKey, AcceptDlc), Error>
Function to call to accept a DLC for which an offer was received.
Sourcepub async fn periodic_chain_monitor(&self) -> Result<(), Error>
pub async fn periodic_chain_monitor(&self) -> Result<(), Error>
Function to update the state of the ChainMonitor with new
blocks.
Consumers MUST call this periodically in order to determine when pending transactions reach confirmation.
Sourcepub async fn periodic_check(&self, check_channels: bool) -> Result<(), Error>
pub async fn periodic_check(&self, check_channels: bool) -> Result<(), Error>
Function to call to check the state of the currently executing DLCs and update them if possible.
Sourcepub async fn on_offer_message(
&self,
offered_message: &OfferDlc,
counter_party: PublicKey,
) -> Result<(), Error>
pub async fn on_offer_message( &self, offered_message: &OfferDlc, counter_party: PublicKey, ) -> Result<(), Error>
Function to call to offer a DLC.
Sourcepub async fn on_close_message(
&self,
close_msg: &CloseDlc,
counter_party: &PublicKey,
) -> Result<(), Error>
pub async fn on_close_message( &self, close_msg: &CloseDlc, counter_party: &PublicKey, ) -> Result<(), Error>
Function to call to close a DLC.
Sourcepub async fn on_accept_message(
&self,
accept_msg: &AcceptDlc,
counter_party: &PublicKey,
) -> Result<DlcMessage, Error>
pub async fn on_accept_message( &self, accept_msg: &AcceptDlc, counter_party: &PublicKey, ) -> Result<DlcMessage, Error>
Function to call to accept a DLC for which an offer was received.
Sourcepub async fn on_sign_message(
&self,
sign_message: &SignDlc,
peer_id: &PublicKey,
) -> Result<(), Error>
pub async fn on_sign_message( &self, sign_message: &SignDlc, peer_id: &PublicKey, ) -> Result<(), Error>
Function to call to sign a DLC for which an accept was received.
Sourcepub async fn close_confirmed_contract(
&self,
contract_id: &ContractId,
attestations: Vec<(usize, OracleAttestation)>,
) -> Result<Contract, Error>
pub async fn close_confirmed_contract( &self, contract_id: &ContractId, attestations: Vec<(usize, OracleAttestation)>, ) -> Result<Contract, Error>
Manually close a contract with the oracle attestations.
Sourcepub async fn check_and_broadcast_refund(
&self,
contract_id: &ContractId,
) -> Result<Contract, Error>
pub async fn check_and_broadcast_refund( &self, contract_id: &ContractId, ) -> Result<Contract, Error>
Check if the refund locktime has passed and broadcast the refund transaction if it has.
Sourcepub async fn on_counterparty_close(
&mut self,
contract: &SignedContract,
closing_tx: Transaction,
confirmations: u32,
) -> Result<Contract, Error>
pub async fn on_counterparty_close( &mut self, contract: &SignedContract, closing_tx: Transaction, confirmations: u32, ) -> Result<Contract, Error>
Function to call when we detect that a contract was closed by our counter party.
This will update the state of the contract and return the Contract object.
Sourcepub async fn cooperative_close_contract(
&self,
contract_id: &ContractId,
counter_payout: Amount,
) -> Result<(CloseDlc, PublicKey), Error>
pub async fn cooperative_close_contract( &self, contract_id: &ContractId, counter_payout: Amount, ) -> Result<(CloseDlc, PublicKey), Error>
Initiates a cooperative close of a contract by creating and signing a closing transaction. Returns a CloseDlc message to be sent to the counter party. The contract remains in Confirmed state until the close transaction is broadcast.
Sourcepub async fn accept_cooperative_close(
&self,
contract_id: &ContractId,
close_message: &CloseDlc,
) -> Result<(), Error>
pub async fn accept_cooperative_close( &self, contract_id: &ContractId, close_message: &CloseDlc, ) -> Result<(), Error>
Accepts a cooperative close request by completing the close transaction and broadcasting it to the network.
Source§impl<W: Deref, SP: Deref, B: Deref, S: Deref, O: Deref, T: Deref, F: Deref, X: ContractSigner, L: Deref> Manager<W, Arc<CachedContractSignerProvider<SP, X>>, B, S, O, T, F, X, L>
impl<W: Deref, SP: Deref, B: Deref, S: Deref, O: Deref, T: Deref, F: Deref, X: ContractSigner, L: Deref> Manager<W, Arc<CachedContractSignerProvider<SP, X>>, B, S, O, T, F, X, L>
Sourcepub async fn offer_channel(
&self,
contract_input: &ContractInput,
counter_party: PublicKey,
) -> Result<OfferChannel, Error>
pub async fn offer_channel( &self, contract_input: &ContractInput, counter_party: PublicKey, ) -> Result<OfferChannel, Error>
Create a new channel offer and return the [dlc_messages::channel::OfferChannel]
message to be sent to the counter_party.
Sourcepub async fn reject_channel(
&self,
channel_id: &ChannelId,
) -> Result<(Reject, PublicKey), Error>
pub async fn reject_channel( &self, channel_id: &ChannelId, ) -> Result<(Reject, PublicKey), Error>
Reject a channel that was offered. Returns the [dlc_messages::channel::Reject]
message to be sent as well as the public key of the offering node.
Sourcepub async fn accept_channel(
&self,
channel_id: &ChannelId,
) -> Result<(AcceptChannel, ChannelId, ContractId, PublicKey), Error>
pub async fn accept_channel( &self, channel_id: &ChannelId, ) -> Result<(AcceptChannel, ChannelId, ContractId, PublicKey), Error>
Accept a channel that was offered. Returns the [dlc_messages::channel::AcceptChannel]
message to be sent, the updated crate::ChannelId and crate::ContractId,
as well as the public key of the offering node.
Sourcepub async fn force_close_channel(
&self,
channel_id: &ChannelId,
) -> Result<(), Error>
pub async fn force_close_channel( &self, channel_id: &ChannelId, ) -> Result<(), Error>
Force close the channel with given crate::ChannelId.
Sourcepub async fn settle_offer(
&self,
channel_id: &ChannelId,
counter_payout: Amount,
) -> Result<(SettleOffer, PublicKey), Error>
pub async fn settle_offer( &self, channel_id: &ChannelId, counter_payout: Amount, ) -> Result<(SettleOffer, PublicKey), Error>
Offer to settle the balance of a channel so that the counter party gets
counter_payout. Returns the [dlc_messages::channel::SettleChannelOffer]
message to be sent and the public key of the counter party node.
Sourcepub async fn accept_settle_offer(
&self,
channel_id: &ChannelId,
) -> Result<(SettleAccept, PublicKey), Error>
pub async fn accept_settle_offer( &self, channel_id: &ChannelId, ) -> Result<(SettleAccept, PublicKey), Error>
Accept a settlement offer, returning the SettleAccept message to be
sent to the node with the returned PublicKey id.
Sourcepub async fn renew_offer(
&self,
channel_id: &ChannelId,
counter_payout: Amount,
contract_input: &ContractInput,
) -> Result<(RenewOffer, PublicKey), Error>
pub async fn renew_offer( &self, channel_id: &ChannelId, counter_payout: Amount, contract_input: &ContractInput, ) -> Result<(RenewOffer, PublicKey), Error>
Returns a RenewOffer message as well as the PublicKey of the
counter party’s node to offer the establishment of a new contract in the
channel.
Sourcepub async fn accept_renew_offer(
&self,
channel_id: &ChannelId,
) -> Result<(RenewAccept, PublicKey), Error>
pub async fn accept_renew_offer( &self, channel_id: &ChannelId, ) -> Result<(RenewAccept, PublicKey), Error>
Accept an offer to renew the contract in the channel. Returns the
RenewAccept message to be sent to the peer with the returned
PublicKey as node id.
Sourcepub async fn reject_renew_offer(
&self,
channel_id: &ChannelId,
) -> Result<(Reject, PublicKey), Error>
pub async fn reject_renew_offer( &self, channel_id: &ChannelId, ) -> Result<(Reject, PublicKey), Error>
Sourcepub async fn reject_settle_offer(
&self,
channel_id: &ChannelId,
) -> Result<(Reject, PublicKey), Error>
pub async fn reject_settle_offer( &self, channel_id: &ChannelId, ) -> Result<(Reject, PublicKey), Error>
Returns a Reject message to be sent to the counter party of the
channel to inform them that the local party does not wish to accept the
proposed settle offer.
Sourcepub async fn offer_collaborative_close(
&self,
channel_id: &ChannelId,
counter_payout: Amount,
additional_inputs: Vec<OutPoint>,
) -> Result<CollaborativeCloseOffer, Error>
pub async fn offer_collaborative_close( &self, channel_id: &ChannelId, counter_payout: Amount, additional_inputs: Vec<OutPoint>, ) -> Result<CollaborativeCloseOffer, Error>
Returns a CollaborativeCloseOffer message to be sent to the counter
party of the channel and update the state of the channel. Note that the
channel will be forced closed after a timeout if the counter party does
not broadcast the close transaction.