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,

source

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.

source

pub fn get_store(&self) -> &S

Get the store from the Manager to access contracts.

source

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.

source

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.

source

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.

source

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,

source

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.

source

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.

source

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

Force close the channel with given crate::ChannelId.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub fn accept_collaborative_close(
&mut 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, B, S, O, T, F> RefUnwindSafe for Manager<W, B, S, O, T, F>where
B: RefUnwindSafe,
F: RefUnwindSafe,
O: RefUnwindSafe,
S: RefUnwindSafe,
T: RefUnwindSafe,
W: RefUnwindSafe,

§

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

§

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

§

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

§

impl<W, B, S, O, T, F> UnwindSafe for Manager<W, B, S, O, T, F>where
B: UnwindSafe,
F: UnwindSafe,
O: UnwindSafe,
S: UnwindSafe,
T: UnwindSafe,
W: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere
U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

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

§

fn vzip(self) -> V