@@ -1771,11 +1771,11 @@ impl ChannelMonitor {
1771
1771
let mut inputs_info = Vec :: new ( ) ;
1772
1772
1773
1773
macro_rules! sign_input {
1774
- ( $sighash_parts: expr, $input: expr, $amount: expr, $preimage: expr) => {
1774
+ ( $sighash_parts: expr, $input: expr, $amount: expr, $preimage: expr, $idx : expr ) => {
1775
1775
{
1776
1776
let ( sig, redeemscript, htlc_key) = match self . key_storage {
1777
1777
Storage :: Local { ref htlc_base_key, .. } => {
1778
- let htlc = & per_commitment_option. unwrap( ) [ $input . sequence as usize ] . 0 ;
1778
+ let htlc = & per_commitment_option. unwrap( ) [ $idx as usize ] . 0 ;
1779
1779
let redeemscript = chan_utils:: get_htlc_redeemscript_with_explicit_keys( htlc, & a_htlc_key, & b_htlc_key, & revocation_pubkey) ;
1780
1780
let sighash = hash_to_message!( & $sighash_parts. sighash_all( & $input, & redeemscript, $amount) [ ..] ) ;
1781
1781
let htlc_key = ignore_error!( chan_utils:: derive_private_key( & self . secp_ctx, revocation_point, & htlc_base_key) ) ;
@@ -1804,19 +1804,19 @@ impl ChannelMonitor {
1804
1804
}
1805
1805
if let Some ( payment_preimage) = self . payment_preimages . get ( & htlc. payment_hash ) {
1806
1806
if htlc. offered {
1807
- let input = TxIn {
1807
+ let mut input = TxIn {
1808
1808
previous_output : BitcoinOutPoint {
1809
1809
txid : commitment_txid,
1810
1810
vout : transaction_output_index,
1811
1811
} ,
1812
1812
script_sig : Script :: new ( ) ,
1813
- sequence : idx as u32 , // reset to 0xfffffffd in sign_input
1813
+ sequence : 0xff_ff_ff_fd ,
1814
1814
witness : Vec :: new ( ) ,
1815
1815
} ;
1816
1816
if htlc. cltv_expiry > height + CLTV_SHARED_CLAIM_BUFFER {
1817
1817
inputs. push ( input) ;
1818
1818
inputs_desc. push ( if htlc. offered { InputDescriptors :: OfferedHTLC } else { InputDescriptors :: ReceivedHTLC } ) ;
1819
- inputs_info. push ( ( payment_preimage, tx. output [ transaction_output_index as usize ] . value , htlc. cltv_expiry ) ) ;
1819
+ inputs_info. push ( ( payment_preimage, tx. output [ transaction_output_index as usize ] . value , htlc. cltv_expiry , idx ) ) ;
1820
1820
total_value += tx. output [ transaction_output_index as usize ] . value ;
1821
1821
} else {
1822
1822
let mut single_htlc_tx = Transaction {
@@ -1833,7 +1833,7 @@ impl ChannelMonitor {
1833
1833
let mut used_feerate;
1834
1834
if subtract_high_prio_fee ! ( self , fee_estimator, single_htlc_tx. output[ 0 ] . value, predicted_weight, used_feerate) {
1835
1835
let sighash_parts = bip143:: SighashComponents :: new ( & single_htlc_tx) ;
1836
- let ( redeemscript, htlc_key) = sign_input ! ( sighash_parts, single_htlc_tx. input[ 0 ] , htlc. amount_msat / 1000 , payment_preimage. 0 . to_vec( ) ) ;
1836
+ let ( redeemscript, htlc_key) = sign_input ! ( sighash_parts, single_htlc_tx. input[ 0 ] , htlc. amount_msat / 1000 , payment_preimage. 0 . to_vec( ) , idx ) ;
1837
1837
assert ! ( predicted_weight >= single_htlc_tx. get_weight( ) ) ;
1838
1838
spendable_outputs. push ( SpendableOutputDescriptor :: StaticOutput {
1839
1839
outpoint : BitcoinOutPoint { txid : single_htlc_tx. txid ( ) , vout : 0 } ,
@@ -1864,7 +1864,7 @@ impl ChannelMonitor {
1864
1864
vout : transaction_output_index,
1865
1865
} ,
1866
1866
script_sig : Script :: new ( ) ,
1867
- sequence : idx as u32 ,
1867
+ sequence : 0xff_ff_ff_fd ,
1868
1868
witness : Vec :: new ( ) ,
1869
1869
} ;
1870
1870
let mut timeout_tx = Transaction {
@@ -1881,7 +1881,7 @@ impl ChannelMonitor {
1881
1881
let mut used_feerate;
1882
1882
if subtract_high_prio_fee ! ( self , fee_estimator, timeout_tx. output[ 0 ] . value, predicted_weight, used_feerate) {
1883
1883
let sighash_parts = bip143:: SighashComponents :: new ( & timeout_tx) ;
1884
- let ( redeemscript, htlc_key) = sign_input ! ( sighash_parts, timeout_tx. input[ 0 ] , htlc. amount_msat / 1000 , vec![ 0 ] ) ;
1884
+ let ( redeemscript, htlc_key) = sign_input ! ( sighash_parts, timeout_tx. input[ 0 ] , htlc. amount_msat / 1000 , vec![ 0 ] , idx ) ;
1885
1885
assert ! ( predicted_weight >= timeout_tx. get_weight( ) ) ;
1886
1886
//TODO: track SpendableOutputDescriptor
1887
1887
log_trace ! ( self , "Outpoint {}:{} is being being claimed, if it doesn't succeed, a bumped claiming txn is going to be broadcast at height {}" , timeout_tx. input[ 0 ] . previous_output. txid, timeout_tx. input[ 0 ] . previous_output. vout, height_timer) ;
@@ -1933,7 +1933,7 @@ impl ChannelMonitor {
1933
1933
let height_timer = Self :: get_height_timer ( height, soonest_timelock) ;
1934
1934
let spend_txid = spend_tx. txid ( ) ;
1935
1935
for ( input, info) in spend_tx. input . iter_mut ( ) . zip ( inputs_info. iter ( ) ) {
1936
- let ( redeemscript, htlc_key) = sign_input ! ( sighash_parts, input, info. 1 , ( info. 0 ) . 0 . to_vec( ) ) ;
1936
+ let ( redeemscript, htlc_key) = sign_input ! ( sighash_parts, input, info. 1 , ( info. 0 ) . 0 . to_vec( ) , info . 3 ) ;
1937
1937
log_trace ! ( self , "Outpoint {}:{} is being being claimed, if it doesn't succeed, a bumped claiming txn is going to be broadcast at height {}" , input. previous_output. txid, input. previous_output. vout, height_timer) ;
1938
1938
per_input_material. insert ( input. previous_output , InputMaterial :: RemoteHTLC { script : redeemscript, key : htlc_key, preimage : Some ( * ( info. 0 ) ) , amount : info. 1 , locktime : 0 } ) ;
1939
1939
match self . claimable_outpoints . entry ( input. previous_output ) {
@@ -2871,7 +2871,6 @@ impl ChannelMonitor {
2871
2871
for per_outp_material in cached_claim_datas. per_input_material . values ( ) {
2872
2872
match per_outp_material {
2873
2873
& InputMaterial :: Revoked { ref script, ref is_htlc, ref amount, .. } => {
2874
- log_trace ! ( self , "Is HLTC ? {}" , is_htlc) ;
2875
2874
inputs_witnesses_weight += Self :: get_witnesses_weight ( if !is_htlc { & [ InputDescriptors :: RevokedOutput ] } else if HTLCType :: scriptlen_to_htlctype ( script. len ( ) ) == Some ( HTLCType :: OfferedHTLC ) { & [ InputDescriptors :: RevokedOfferedHTLC ] } else if HTLCType :: scriptlen_to_htlctype ( script. len ( ) ) == Some ( HTLCType :: AcceptedHTLC ) { & [ InputDescriptors :: RevokedReceivedHTLC ] } else { unreachable ! ( ) } ) ;
2876
2875
amt += * amount;
2877
2876
} ,
0 commit comments