Struct dlc_manager::manager::Manager
source · pub struct Manager<W: Deref, B: Deref, S: Deref, O: Deref, T: Deref, F: Deref>where
W::Target: Wallet,
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, B: Deref, S: Deref, O: Deref, T: Deref, F: Deref> Manager<W, B, S, O, T, F>where
W::Target: Wallet,
B::Target: Blockchain,
S::Target: Storage,
O::Target: Oracle,
T::Target: Time,
F::Target: FeeEstimator,
impl<W: Deref, B: Deref, S: Deref, O: Deref, T: Deref, F: Deref> Manager<W, B, S, O, T, F>where
W::Target: Wallet,
B::Target: Blockchain,
S::Target: Storage,
O::Target: Oracle,
T::Target: Time,
F::Target: FeeEstimator,
sourcepub fn new(
wallet: W,
blockchain: B,
store: S,
oracles: HashMap<XOnlyPublicKey, O>,
time: T,
fee_estimator: F
) -> Result<Self, Error>
pub fn new(
wallet: W,
blockchain: B,
store: S,
oracles: HashMap<XOnlyPublicKey, O>,
time: T,
fee_estimator: F
) -> Result<Self, Error>
Create a new Manager struct.
sourcepub fn on_dlc_message(
&mut self,
msg: &DlcMessage,
counter_party: PublicKey
) -> Result<Option<DlcMessage>, Error>
pub fn on_dlc_message(
&mut self,
msg: &DlcMessage,
counter_party: PublicKey
) -> Result<Option<DlcMessage>, Error>
Function called to pass a DlcMessage to the Manager.
sourcepub fn send_offer(
&mut self,
contract_input: &ContractInput,
counter_party: PublicKey
) -> Result<OfferDlc, Error>
pub fn send_offer(
&mut 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.
sourcepub fn accept_contract_offer(
&mut self,
contract_id: &ContractId
) -> Result<(ContractId, PublicKey, AcceptDlc), Error>
pub fn accept_contract_offer(
&mut self,
contract_id: &ContractId
) -> Result<(ContractId, PublicKey, AcceptDlc), Error>
Function to call to accept a DLC for which an offer was received.
sourcepub fn periodic_check(&mut self) -> Result<(), Error>
pub fn periodic_check(&mut self) -> Result<(), Error>
Function to call to check the state of the currently executing DLCs and update them if possible.
source§impl<W: Deref, B: Deref, S: Deref, O: Deref, T: Deref, F: Deref> Manager<W, B, S, O, T, F>where
W::Target: Wallet,
B::Target: Blockchain,
S::Target: Storage,
O::Target: Oracle,
T::Target: Time,
F::Target: FeeEstimator,
impl<W: Deref, B: Deref, S: Deref, O: Deref, T: Deref, F: Deref> Manager<W, B, S, O, T, F>where
W::Target: Wallet,
B::Target: Blockchain,
S::Target: Storage,
O::Target: Oracle,
T::Target: Time,
F::Target: FeeEstimator,
sourcepub fn offer_channel(
&mut self,
contract_input: &ContractInput,
counter_party: PublicKey
) -> Result<OfferChannel, Error>
pub fn offer_channel(
&mut 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 accept_channel(
&mut self,
channel_id: &ChannelId
) -> Result<(AcceptChannel, ChannelId, ContractId, PublicKey), Error>
pub fn accept_channel(
&mut 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 fn force_close_channel(
&mut self,
channel_id: &ChannelId
) -> Result<(), Error>
pub fn force_close_channel(
&mut self,
channel_id: &ChannelId
) -> Result<(), Error>
Force close the channel with given crate::ChannelId.
sourcepub fn settle_offer(
&mut self,
channel_id: &ChannelId,
counter_payout: u64
) -> Result<(SettleOffer, PublicKey), Error>
pub fn settle_offer(
&mut 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(
&mut self,
channel_id: &ChannelId
) -> Result<(SettleAccept, PublicKey), Error>
pub fn accept_settle_offer(
&mut 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 fn renew_offer(
&mut self,
channel_id: &ChannelId,
counter_payout: u64,
contract_input: &ContractInput
) -> Result<(RenewOffer, PublicKey), Error>
pub fn renew_offer(
&mut 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(
&mut self,
channel_id: &ChannelId
) -> Result<(RenewAccept, PublicKey), Error>
pub fn accept_renew_offer(
&mut 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(
&mut self,
channel_id: &ChannelId
) -> Result<(Reject, PublicKey), Error>
pub fn reject_renew_offer(
&mut self,
channel_id: &ChannelId
) -> Result<(Reject, PublicKey), Error>
Reject an offer to renew the contract in the channel. Returns the
Reject message to be sent to the peer with the returned
[PublicKey] node id.
sourcepub fn reject_settle_offer(
&mut self,
channel_id: &ChannelId
) -> Result<(Reject, PublicKey), Error>
pub fn reject_settle_offer(
&mut 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(
&mut self,
channel_id: &ChannelId,
counter_payout: u64
) -> Result<CollaborativeCloseOffer, Error>
pub fn offer_collaborative_close(
&mut 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.