You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
KeysInterface::get_shutdown_pubkey is used to form P2WPKH shutdown
scripts. However, BOLT 2 allows for a wider variety of scripts. Refactor
KeysInterface to allow any supported script while still maintaining
serialization backwards compatibility with P2WPKH script pubkeys stored
simply as the PublicKey.
Add an optional TLV field to Channel and ChannelMonitor to support the
new format, but continue to serialize the legacy PublicKey format.
let counterparty_payment_script = Readable::read(reader)?;
2625
-
let shutdown_script = Readable::read(reader)?;
2626
+
let shutdown_script = {
2627
+
let script = <ScriptasReadable>::read(reader)?;
2628
+
if script.is_empty(){None}else{Some(script)}
2629
+
};
2626
2630
2627
2631
let channel_keys_id = Readable::read(reader)?;
2628
2632
let holder_revocation_basepoint = Readable::read(reader)?;
@@ -2854,6 +2858,7 @@ mod tests {
2854
2858
use ln::{PaymentPreimage,PaymentHash};
2855
2859
use ln::chan_utils;
2856
2860
use ln::chan_utils::{HTLCOutputInCommitment,ChannelPublicKeys,ChannelTransactionParameters,HolderCommitmentTransaction,CounterpartyChannelTransactionParameters};
2861
+
use ln::script::ShutdownScript;
2857
2862
use util::test_utils::{TestLogger,TestBroadcaster,TestFeeEstimator};
2858
2863
use bitcoin::secp256k1::key::{SecretKey,PublicKey};
2859
2864
use bitcoin::secp256k1::Secp256k1;
@@ -2947,9 +2952,10 @@ mod tests {
2947
2952
};
2948
2953
// Prune with one old state and a holder commitment tx holding a few overlaps with the
2949
2954
// old state.
2955
+
let shutdown_pubkey = PublicKey::from_secret_key(&secp_ctx,&SecretKey::from_slice(&[42;32]).unwrap());
2950
2956
let best_block = BestBlock::from_genesis(Network::Testnet);
2951
2957
let monitor = ChannelMonitor::new(Secp256k1::new(), keys,
Copy file name to clipboardExpand all lines: lightning/src/chain/keysinterface.rs
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,7 @@ use chain::transaction::OutPoint;
36
36
use ln::chan_utils;
37
37
use ln::chan_utils::{HTLCOutputInCommitment, make_funding_redeemscript,ChannelPublicKeys,HolderCommitmentTransaction,ChannelTransactionParameters,CommitmentTransaction};
let funding_redeemscript = self.get_funding_redeemscript();
1688
1690
let funding_txo_script = funding_redeemscript.to_v0_p2wsh();
1689
1691
let obscure_factor = get_commitment_transaction_number_obscure_factor(&self.get_holder_pubkeys().payment_point,&self.get_counterparty_pubkeys().payment_point,self.is_outbound());
1692
+
let shutdown_script = self.shutdown_scriptpubkey.clone().map(|script| script.into_inner());
1690
1693
let channel_monitor = ChannelMonitor::new(self.secp_ctx.clone(),self.holder_signer.clone(),
let funding_txo = self.get_funding_txo().unwrap();
1761
1764
let funding_txo_script = funding_redeemscript.to_v0_p2wsh();
1762
1765
let obscure_factor = get_commitment_transaction_number_obscure_factor(&self.get_holder_pubkeys().payment_point,&self.get_counterparty_pubkeys().payment_point,self.is_outbound());
1766
+
let shutdown_script = self.shutdown_scriptpubkey.clone().map(|script| script.into_inner());
1763
1767
let channel_monitor = ChannelMonitor::new(self.secp_ctx.clone(),self.holder_signer.clone(),
use ln::msgs::{ChannelUpdate,DataLossProtect,DecodeError,OptionalField,UnsignedChannelUpdate};
5098
+
use ln::script::ShutdownScript;
5083
5099
use ln::chan_utils;
5084
5100
use ln::chan_utils::{ChannelPublicKeys,HolderCommitmentTransaction,CounterpartyChannelTransactionParameters,HTLC_SUCCESS_TX_WEIGHT,HTLC_TIMEOUT_TX_WEIGHT};
0 commit comments