pub struct Manager<W: Deref, SP: Deref, B: Deref, S: Deref, O: Deref, T: Deref, F: Deref, X: ContractSigner>where
W::Target: Wallet,
SP::Target: ContractSignerProvider<Signer = X>,
B::Target: Blockchain,
S::Target: Storage,
O::Target: Oracle,
T::Target: Time,
F::Target: FeeEstimator,{ /* 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> Manager<W, Arc<CachedContractSignerProvider<SP, X>>, B, S, O, T, F, X>where
W::Target: Wallet,
SP::Target: ContractSignerProvider<Signer = X>,
B::Target: Blockchain,
S::Target: Storage,
O::Target: Oracle,
T::Target: Time,
F::Target: FeeEstimator,
impl<W: Deref, SP: Deref, B: Deref, S: Deref, O: Deref, T: Deref, F: Deref, X: ContractSigner> Manager<W, Arc<CachedContractSignerProvider<SP, X>>, B, S, O, T, F, X>where
W::Target: Wallet,
SP::Target: ContractSignerProvider<Signer = X>,
B::Target: Blockchain,
S::Target: Storage,
O::Target: Oracle,
T::Target: Time,
F::Target: FeeEstimator,
Sourcepub async fn new(
wallet: W,
signer_provider: SP,
blockchain: B,
store: S,
oracles: HashMap<XOnlyPublicKey, O>,
time: T,
fee_estimator: F,
) -> 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, ) -> 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_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 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 fn on_counterparty_close(
&mut self,
contract: &SignedContract,
closing_tx: Transaction,
confirmations: u32,
) -> Result<Contract, Error>
pub 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.
Source§impl<W: Deref, SP: Deref, B: Deref, S: Deref, O: Deref, T: Deref, F: Deref, X: ContractSigner> Manager<W, Arc<CachedContractSignerProvider<SP, X>>, B, S, O, T, F, X>where
W::Target: Wallet,
SP::Target: ContractSignerProvider<Signer = X>,
B::Target: Blockchain,
S::Target: Storage,
O::Target: Oracle,
T::Target: Time,
F::Target: FeeEstimator,
impl<W: Deref, SP: Deref, B: Deref, S: Deref, O: Deref, T: Deref, F: Deref, X: ContractSigner> Manager<W, Arc<CachedContractSignerProvider<SP, X>>, B, S, O, T, F, X>where
W::Target: Wallet,
SP::Target: ContractSignerProvider<Signer = X>,
B::Target: Blockchain,
S::Target: Storage,
O::Target: Oracle,
T::Target: Time,
F::Target: FeeEstimator,
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 fn reject_channel(
&self,
channel_id: &ChannelId,
) -> Result<(Reject, PublicKey), Error>
pub 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 fn settle_offer(
&self,
channel_id: &ChannelId,
counter_payout: u64,
) -> Result<(SettleOffer, PublicKey), Error>
pub fn settle_offer( &self, channel_id: &ChannelId, counter_payout: u64, ) -> 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 fn accept_settle_offer(
&self,
channel_id: &ChannelId,
) -> Result<(SettleAccept, PublicKey), Error>
pub 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: u64,
contract_input: &ContractInput,
) -> Result<(RenewOffer, PublicKey), Error>
pub async fn renew_offer( &self, channel_id: &ChannelId, counter_payout: u64, 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 fn accept_renew_offer(
&self,
channel_id: &ChannelId,
) -> Result<(RenewAccept, PublicKey), Error>
pub 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 fn reject_renew_offer(
&self,
channel_id: &ChannelId,
) -> Result<(Reject, PublicKey), Error>
pub fn reject_renew_offer( &self, channel_id: &ChannelId, ) -> Result<(Reject, PublicKey), Error>
Sourcepub fn reject_settle_offer(
&self,
channel_id: &ChannelId,
) -> Result<(Reject, PublicKey), Error>
pub 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 fn offer_collaborative_close(
&self,
channel_id: &ChannelId,
counter_payout: u64,
) -> Result<CollaborativeCloseOffer, Error>
pub fn offer_collaborative_close( &self, channel_id: &ChannelId, counter_payout: u64, ) -> 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.