Struct lightning_signer::channel::Channel
source · pub struct Channel {
pub node: Weak<Node>,
pub keys: InMemorySigner,
pub enforcement_state: EnforcementState,
pub setup: ChannelSetup,
pub id0: ChannelId,
pub id: Option<ChannelId>,
pub monitor: ChainMonitor,
/* private fields */
}
Expand description
After Node::ready_channel
Fields§
§node: Weak<Node>
A backpointer to the node
keys: InMemorySigner
The signer for this channel
enforcement_state: EnforcementState
Channel state for policy enforcement purposes
setup: ChannelSetup
The negotiated channel setup
id0: ChannelId
The initial channel ID
id: Option<ChannelId>
The optional permanent channel ID
monitor: ChainMonitor
The chain monitor
Implementations§
source§impl Channel
impl Channel
sourcepub fn sign_counterparty_commitment_tx_phase2(
&mut self,
remote_per_commitment_point: &PublicKey,
commitment_number: u64,
feerate_per_kw: u32,
to_holder_value_sat: u64,
to_counterparty_value_sat: u64,
offered_htlcs: Vec<HTLCInfo2>,
received_htlcs: Vec<HTLCInfo2>
) -> Result<(Signature, Vec<Signature>), Status>
pub fn sign_counterparty_commitment_tx_phase2( &mut self, remote_per_commitment_point: &PublicKey, commitment_number: u64, feerate_per_kw: u32, to_holder_value_sat: u64, to_counterparty_value_sat: u64, offered_htlcs: Vec<HTLCInfo2>, received_htlcs: Vec<HTLCInfo2> ) -> Result<(Signature, Vec<Signature>), Status>
Sign a counterparty commitment transaction after rebuilding it from the supplied arguments.
sourcepub fn validate_holder_commitment_tx_phase2(
&mut self,
commitment_number: u64,
feerate_per_kw: u32,
to_holder_value_sat: u64,
to_counterparty_value_sat: u64,
offered_htlcs: Vec<HTLCInfo2>,
received_htlcs: Vec<HTLCInfo2>,
counterparty_commit_sig: &Signature,
counterparty_htlc_sigs: &[Signature]
) -> Result<(PublicKey, Option<SecretKey>), Status>
pub fn validate_holder_commitment_tx_phase2( &mut self, commitment_number: u64, feerate_per_kw: u32, to_holder_value_sat: u64, to_counterparty_value_sat: u64, offered_htlcs: Vec<HTLCInfo2>, received_htlcs: Vec<HTLCInfo2>, counterparty_commit_sig: &Signature, counterparty_htlc_sigs: &[Signature] ) -> Result<(PublicKey, Option<SecretKey>), Status>
Validate the counterparty’s signatures on the holder’s commitment and HTLCs when the commitment_signed message is received. Returns the next per_commitment_point and the holder’s revocation secret for the prior commitment. This method advances the expected next holder commitment number in the signer’s state.
sourcepub fn sign_holder_commitment_tx_phase2(
&mut self,
commitment_number: u64
) -> Result<(Signature, Vec<Signature>), Status>
pub fn sign_holder_commitment_tx_phase2( &mut self, commitment_number: u64 ) -> Result<(Signature, Vec<Signature>), Status>
Sign a holder commitment when force-closing
sourcepub fn sign_holder_commitment_tx_for_recovery(
&mut self
) -> Result<(Transaction, Vec<Transaction>, Script, (SecretKey, Vec<Vec<u8>>), PublicKey), Status>
pub fn sign_holder_commitment_tx_for_recovery( &mut self ) -> Result<(Transaction, Vec<Transaction>, Script, (SecretKey, Vec<Vec<u8>>), PublicKey), Status>
Sign a holder commitment and HTLCs when recovering from node failure Also returns the revocable scriptPubKey so we can identify our outputs Also returns the unilateral close key material
sourcepub fn sign_holder_commitment_tx_phase2_redundant(
&mut self,
commitment_number: u64,
feerate_per_kw: u32,
to_holder_value_sat: u64,
to_counterparty_value_sat: u64,
offered_htlcs: Vec<HTLCInfo2>,
received_htlcs: Vec<HTLCInfo2>
) -> Result<(Signature, Vec<Signature>), Status>
pub fn sign_holder_commitment_tx_phase2_redundant( &mut self, commitment_number: u64, feerate_per_kw: u32, to_holder_value_sat: u64, to_counterparty_value_sat: u64, offered_htlcs: Vec<HTLCInfo2>, received_htlcs: Vec<HTLCInfo2> ) -> Result<(Signature, Vec<Signature>), Status>
Sign a holder commitment transaction after rebuilding it
from the supplied arguments.
Use [sign_counterparty_commitment_tx_phase2
] instead of this,
since that one uses the last counter-signed holder tx, which is simpler
and doesn’t require re-validation of the holder tx.
sourcepub fn make_channel_parameters(&self) -> ChannelTransactionParameters
pub fn make_channel_parameters(&self) -> ChannelTransactionParameters
Build channel parameters, used to further build a commitment transaction
sourcepub fn get_ldk_shutdown_script(&self) -> Script
pub fn get_ldk_shutdown_script(&self) -> Script
Get the shutdown script where our funds will go when we mutual-close
sourcepub fn sign_mutual_close_tx_phase2(
&mut self,
to_holder_value_sat: u64,
to_counterparty_value_sat: u64,
holder_script: &Option<Script>,
counterparty_script: &Option<Script>,
holder_wallet_path_hint: &[u32]
) -> Result<Signature, Status>
pub fn sign_mutual_close_tx_phase2( &mut self, to_holder_value_sat: u64, to_counterparty_value_sat: u64, holder_script: &Option<Script>, counterparty_script: &Option<Script>, holder_wallet_path_hint: &[u32] ) -> Result<Signature, Status>
Sign a mutual close transaction after rebuilding it from the supplied arguments
sourcepub fn sign_delayed_sweep(
&self,
tx: &Transaction,
input: usize,
commitment_number: u64,
redeemscript: &Script,
amount_sat: u64,
wallet_path: &[u32]
) -> Result<Signature, Status>
pub fn sign_delayed_sweep( &self, tx: &Transaction, input: usize, commitment_number: u64, redeemscript: &Script, amount_sat: u64, wallet_path: &[u32] ) -> Result<Signature, Status>
Sign a delayed output that goes to us while sweeping a transaction we broadcast
sourcepub fn sign_counterparty_htlc_sweep(
&self,
tx: &Transaction,
input: usize,
remote_per_commitment_point: &PublicKey,
redeemscript: &Script,
htlc_amount_sat: u64,
wallet_path: &[u32]
) -> Result<Signature, Status>
pub fn sign_counterparty_htlc_sweep( &self, tx: &Transaction, input: usize, remote_per_commitment_point: &PublicKey, redeemscript: &Script, htlc_amount_sat: u64, wallet_path: &[u32] ) -> Result<Signature, Status>
Sign an offered or received HTLC output from a commitment the counterparty broadcast.
sourcepub fn sign_justice_sweep(
&self,
tx: &Transaction,
input: usize,
revocation_secret: &SecretKey,
redeemscript: &Script,
amount_sat: u64,
wallet_path: &[u32]
) -> Result<Signature, Status>
pub fn sign_justice_sweep( &self, tx: &Transaction, input: usize, revocation_secret: &SecretKey, redeemscript: &Script, amount_sat: u64, wallet_path: &[u32] ) -> Result<Signature, Status>
Sign a justice transaction on an old state that the counterparty broadcast
sourcepub fn sign_channel_announcement_with_funding_key(
&self,
announcement: &[u8]
) -> Signature
pub fn sign_channel_announcement_with_funding_key( &self, announcement: &[u8] ) -> Signature
Sign a channel announcement with both the node key and the funding key
sourcepub fn funding_signed(&self, _tx: &Transaction, _vout: u32)
pub fn funding_signed(&self, _tx: &Transaction, _vout: u32)
The node has signed our funding transaction
sourcepub fn balance(&self) -> ChannelBalance
pub fn balance(&self) -> ChannelBalance
Return channel balances
source§impl Channel
impl Channel
sourcepub fn sign_counterparty_commitment_tx(
&mut self,
tx: &Transaction,
output_witscripts: &[Vec<u8>],
remote_per_commitment_point: &PublicKey,
commitment_number: u64,
feerate_per_kw: u32,
offered_htlcs: Vec<HTLCInfo2>,
received_htlcs: Vec<HTLCInfo2>
) -> Result<Signature, Status>
pub fn sign_counterparty_commitment_tx( &mut self, tx: &Transaction, output_witscripts: &[Vec<u8>], remote_per_commitment_point: &PublicKey, commitment_number: u64, feerate_per_kw: u32, offered_htlcs: Vec<HTLCInfo2>, received_htlcs: Vec<HTLCInfo2> ) -> Result<Signature, Status>
Phase 1
sourcepub fn validate_holder_commitment_tx(
&mut self,
tx: &Transaction,
output_witscripts: &[Vec<u8>],
commitment_number: u64,
feerate_per_kw: u32,
offered_htlcs: Vec<HTLCInfo2>,
received_htlcs: Vec<HTLCInfo2>,
counterparty_commit_sig: &Signature,
counterparty_htlc_sigs: &[Signature]
) -> Result<(PublicKey, Option<SecretKey>), Status>
pub fn validate_holder_commitment_tx( &mut self, tx: &Transaction, output_witscripts: &[Vec<u8>], commitment_number: u64, feerate_per_kw: u32, offered_htlcs: Vec<HTLCInfo2>, received_htlcs: Vec<HTLCInfo2>, counterparty_commit_sig: &Signature, counterparty_htlc_sigs: &[Signature] ) -> Result<(PublicKey, Option<SecretKey>), Status>
Validate the counterparty’s signatures on the holder’s commitment and HTLCs when the commitment_signed message is received. Returns the next per_commitment_point and the holder’s revocation secret for the prior commitment. This method advances the expected next holder commitment number in the signer’s state.
sourcepub fn validate_counterparty_revocation(
&mut self,
revoke_num: u64,
old_secret: &SecretKey
) -> Result<(), Status>
pub fn validate_counterparty_revocation( &mut self, revoke_num: u64, old_secret: &SecretKey ) -> Result<(), Status>
Process the counterparty’s revocation
When this is provided, we know that the counterparty has committed to the next state.
sourcepub fn sign_mutual_close_tx(
&mut self,
tx: &Transaction,
opaths: &[Vec<u32>]
) -> Result<Signature, Status>
pub fn sign_mutual_close_tx( &mut self, tx: &Transaction, opaths: &[Vec<u32>] ) -> Result<Signature, Status>
Phase 1
sourcepub fn sign_holder_htlc_tx(
&self,
tx: &Transaction,
commitment_number: u64,
opt_per_commitment_point: Option<PublicKey>,
redeemscript: &Script,
htlc_amount_sat: u64,
output_witscript: &Script
) -> Result<TypedSignature, Status>
pub fn sign_holder_htlc_tx( &self, tx: &Transaction, commitment_number: u64, opt_per_commitment_point: Option<PublicKey>, redeemscript: &Script, htlc_amount_sat: u64, output_witscript: &Script ) -> Result<TypedSignature, Status>
Phase 1
sourcepub fn sign_counterparty_htlc_tx(
&self,
tx: &Transaction,
remote_per_commitment_point: &PublicKey,
redeemscript: &Script,
htlc_amount_sat: u64,
output_witscript: &Script
) -> Result<TypedSignature, Status>
pub fn sign_counterparty_htlc_tx( &self, tx: &Transaction, remote_per_commitment_point: &PublicKey, redeemscript: &Script, htlc_amount_sat: u64, output_witscript: &Script ) -> Result<TypedSignature, Status>
Phase 1
sourcepub fn sign_htlc_tx(
&self,
tx: &Transaction,
per_commitment_point: &PublicKey,
redeemscript: &Script,
htlc_amount_sat: u64,
output_witscript: &Script,
is_counterparty: bool,
txkeys: TxCreationKeys
) -> Result<TypedSignature, Status>
pub fn sign_htlc_tx( &self, tx: &Transaction, per_commitment_point: &PublicKey, redeemscript: &Script, htlc_amount_sat: u64, output_witscript: &Script, is_counterparty: bool, txkeys: TxCreationKeys ) -> Result<TypedSignature, Status>
Sign a 2nd level HTLC transaction hanging off a commitment transaction
sourcepub fn get_unilateral_close_key(
&self,
commitment_point_opt: &Option<PublicKey>,
revocation_pubkey: &Option<PublicKey>
) -> Result<(SecretKey, Vec<Vec<u8>>), Status>
pub fn get_unilateral_close_key( &self, commitment_point_opt: &Option<PublicKey>, revocation_pubkey: &Option<PublicKey> ) -> Result<(SecretKey, Vec<Vec<u8>>), Status>
Get the unilateral close key and the witness stack suffix, for sweeping the to-remote output of a counterparty’s force-close
sourcepub fn htlcs_fulfilled(&mut self, preimages: Vec<PaymentPreimage>)
pub fn htlcs_fulfilled(&mut self, preimages: Vec<PaymentPreimage>)
Mark any in-flight payments (outgoing HTLCs) on this channel with the given preimage as filled. Any such payments adjust our expected balance downwards.