Struct Manager

Source
pub struct Manager<W: Deref, SP: Deref, B: Deref, S: Deref, O: Deref, T: Deref, F: Deref, X: ContractSigner>{ /* 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>

Source

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.

Source

pub fn get_store(&self) -> &S

Get the store from the Manager to access contracts.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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>

Source

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.

Source

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.

Source

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.

Source

pub async fn force_close_channel( &self, channel_id: &ChannelId, ) -> Result<(), Error>

Force close the channel with given crate::ChannelId.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn reject_renew_offer( &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.

Source

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.

Source

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.

Source

pub async fn accept_collaborative_close( &self, channel_id: &ChannelId, ) -> Result<(), Error>

Accept an offer to collaboratively close the channel. The close transaction will be broadcast and the state of the channel updated.

Auto Trait Implementations§

§

impl<W, SP, B, S, O, T, F, X> !Freeze for Manager<W, SP, B, S, O, T, F, X>

§

impl<W, SP, B, S, O, T, F, X> RefUnwindSafe for Manager<W, SP, B, S, O, T, F, X>

§

impl<W, SP, B, S, O, T, F, X> Send for Manager<W, SP, B, S, O, T, F, X>
where W: Send, SP: Send, B: Send, S: Send, T: Send, F: Send, O: Send,

§

impl<W, SP, B, S, O, T, F, X> Sync for Manager<W, SP, B, S, O, T, F, X>
where W: Sync, SP: Sync, B: Sync, S: Sync, T: Sync, F: Sync, O: Sync,

§

impl<W, SP, B, S, O, T, F, X> Unpin for Manager<W, SP, B, S, O, T, F, X>
where W: Unpin, SP: Unpin, B: Unpin, S: Unpin, T: Unpin, F: Unpin, O: Unpin,

§

impl<W, SP, B, S, O, T, F, X> UnwindSafe for Manager<W, SP, B, S, O, T, F, X>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more