X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fsign%2Fmod.rs;h=04c4446e2c0c8c75bd4f2f7e3b415b8f35296cf2;hb=34f8dd9a49060676da0cf4157613cfb5fd58cf1e;hp=f25c947644838f1dfaec843c74c26c8b4f935f72;hpb=af3a369ef1ce07057e07c24a1709b494ad62493b;p=rust-lightning diff --git a/lightning/src/sign/mod.rs b/lightning/src/sign/mod.rs index f25c9476..04c4446e 100644 --- a/lightning/src/sign/mod.rs +++ b/lightning/src/sign/mod.rs @@ -68,7 +68,7 @@ pub struct KeyMaterial(pub [u8; 32]); /// Information about a spendable output to a P2WSH script. /// /// See [`SpendableOutputDescriptor::DelayedPaymentOutput`] for more details on how to spend this. -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, Hash, PartialEq, Eq)] pub struct DelayedPaymentOutputDescriptor { /// The outpoint which is spendable. pub outpoint: OutPoint, @@ -107,10 +107,16 @@ impl_writeable_tlv_based!(DelayedPaymentOutputDescriptor, { (12, channel_value_satoshis, required), }); +pub(crate) const P2WPKH_WITNESS_WEIGHT: u64 = 1 /* num stack items */ + + 1 /* sig length */ + + 73 /* sig including sighash flag */ + + 1 /* pubkey length */ + + 33 /* pubkey */; + /// Information about a spendable output to our "payment key". /// /// See [`SpendableOutputDescriptor::StaticPaymentOutput`] for more details on how to spend this. -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, Hash, PartialEq, Eq)] pub struct StaticPaymentOutputDescriptor { /// The outpoint which is spendable. pub outpoint: OutPoint, @@ -121,20 +127,52 @@ pub struct StaticPaymentOutputDescriptor { pub channel_keys_id: [u8; 32], /// The value of the channel which this transactions spends. pub channel_value_satoshis: u64, + /// The necessary channel parameters that need to be provided to the re-derived signer through + /// [`ChannelSigner::provide_channel_parameters`]. + /// + /// Added as optional, but always `Some` if the descriptor was produced in v0.0.117 or later. + pub channel_transaction_parameters: Option, } impl StaticPaymentOutputDescriptor { + /// Returns the `witness_script` of the spendable output. + /// + /// Note that this will only return `Some` for [`StaticPaymentOutputDescriptor`]s that + /// originated from an anchor outputs channel, as they take the form of a P2WSH script. + pub fn witness_script(&self) -> Option