@@ -1799,11 +1799,11 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1799
1799
let mut inputs_info = Vec :: new ( ) ;
1800
1800
1801
1801
macro_rules! sign_input {
1802
- ( $sighash_parts: expr, $input: expr, $amount: expr, $preimage: expr) => {
1802
+ ( $sighash_parts: expr, $input: expr, $amount: expr, $preimage: expr, $idx : expr ) => {
1803
1803
{
1804
1804
let ( sig, redeemscript, htlc_key) = match self . key_storage {
1805
1805
Storage :: Local { ref htlc_base_key, .. } => {
1806
- let htlc = & per_commitment_option. unwrap( ) [ $input . sequence as usize ] . 0 ;
1806
+ let htlc = & per_commitment_option. unwrap( ) [ $idx as usize ] . 0 ;
1807
1807
let redeemscript = chan_utils:: get_htlc_redeemscript_with_explicit_keys( htlc, & a_htlc_key, & b_htlc_key, & revocation_pubkey) ;
1808
1808
let sighash = hash_to_message!( & $sighash_parts. sighash_all( & $input, & redeemscript, $amount) [ ..] ) ;
1809
1809
let htlc_key = ignore_error!( chan_utils:: derive_private_key( & self . secp_ctx, revocation_point, & htlc_base_key) ) ;
@@ -1832,19 +1832,19 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1832
1832
}
1833
1833
if let Some ( payment_preimage) = self . payment_preimages . get ( & htlc. payment_hash ) {
1834
1834
if htlc. offered {
1835
- let input = TxIn {
1835
+ let mut input = TxIn {
1836
1836
previous_output : BitcoinOutPoint {
1837
1837
txid : commitment_txid,
1838
1838
vout : transaction_output_index,
1839
1839
} ,
1840
1840
script_sig : Script :: new ( ) ,
1841
- sequence : idx as u32 , // reset to 0xfffffffd in sign_input
1841
+ sequence : 0xff_ff_ff_fd ,
1842
1842
witness : Vec :: new ( ) ,
1843
1843
} ;
1844
1844
if htlc. cltv_expiry > height + CLTV_SHARED_CLAIM_BUFFER {
1845
1845
inputs. push ( input) ;
1846
1846
inputs_desc. push ( if htlc. offered { InputDescriptors :: OfferedHTLC } else { InputDescriptors :: ReceivedHTLC } ) ;
1847
- inputs_info. push ( ( payment_preimage, tx. output [ transaction_output_index as usize ] . value , htlc. cltv_expiry ) ) ;
1847
+ inputs_info. push ( ( payment_preimage, tx. output [ transaction_output_index as usize ] . value , htlc. cltv_expiry , idx ) ) ;
1848
1848
total_value += tx. output [ transaction_output_index as usize ] . value ;
1849
1849
} else {
1850
1850
let mut single_htlc_tx = Transaction {
@@ -1861,7 +1861,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1861
1861
let mut used_feerate;
1862
1862
if subtract_high_prio_fee ! ( self , fee_estimator, single_htlc_tx. output[ 0 ] . value, predicted_weight, used_feerate) {
1863
1863
let sighash_parts = bip143:: SighashComponents :: new ( & single_htlc_tx) ;
1864
- let ( redeemscript, htlc_key) = sign_input ! ( sighash_parts, single_htlc_tx. input[ 0 ] , htlc. amount_msat / 1000 , payment_preimage. 0 . to_vec( ) ) ;
1864
+ let ( redeemscript, htlc_key) = sign_input ! ( sighash_parts, single_htlc_tx. input[ 0 ] , htlc. amount_msat / 1000 , payment_preimage. 0 . to_vec( ) , idx ) ;
1865
1865
assert ! ( predicted_weight >= single_htlc_tx. get_weight( ) ) ;
1866
1866
spendable_outputs. push ( SpendableOutputDescriptor :: StaticOutput {
1867
1867
outpoint : BitcoinOutPoint { txid : single_htlc_tx. txid ( ) , vout : 0 } ,
@@ -1892,7 +1892,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1892
1892
vout : transaction_output_index,
1893
1893
} ,
1894
1894
script_sig : Script :: new ( ) ,
1895
- sequence : idx as u32 ,
1895
+ sequence : 0xff_ff_ff_fd ,
1896
1896
witness : Vec :: new ( ) ,
1897
1897
} ;
1898
1898
let mut timeout_tx = Transaction {
@@ -1909,7 +1909,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1909
1909
let mut used_feerate;
1910
1910
if subtract_high_prio_fee ! ( self , fee_estimator, timeout_tx. output[ 0 ] . value, predicted_weight, used_feerate) {
1911
1911
let sighash_parts = bip143:: SighashComponents :: new ( & timeout_tx) ;
1912
- let ( redeemscript, htlc_key) = sign_input ! ( sighash_parts, timeout_tx. input[ 0 ] , htlc. amount_msat / 1000 , vec![ 0 ] ) ;
1912
+ let ( redeemscript, htlc_key) = sign_input ! ( sighash_parts, timeout_tx. input[ 0 ] , htlc. amount_msat / 1000 , vec![ 0 ] , idx ) ;
1913
1913
assert ! ( predicted_weight >= timeout_tx. get_weight( ) ) ;
1914
1914
//TODO: track SpendableOutputDescriptor
1915
1915
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) ;
@@ -1961,7 +1961,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1961
1961
let height_timer = Self :: get_height_timer ( height, soonest_timelock) ;
1962
1962
let spend_txid = spend_tx. txid ( ) ;
1963
1963
for ( input, info) in spend_tx. input . iter_mut ( ) . zip ( inputs_info. iter ( ) ) {
1964
- let ( redeemscript, htlc_key) = sign_input ! ( sighash_parts, input, info. 1 , ( info. 0 ) . 0 . to_vec( ) ) ;
1964
+ let ( redeemscript, htlc_key) = sign_input ! ( sighash_parts, input, info. 1 , ( info. 0 ) . 0 . to_vec( ) , info . 3 ) ;
1965
1965
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) ;
1966
1966
per_input_material. insert ( input. previous_output , InputMaterial :: RemoteHTLC { script : redeemscript, key : htlc_key, preimage : Some ( * ( info. 0 ) ) , amount : info. 1 , locktime : 0 } ) ;
1967
1967
match self . claimable_outpoints . entry ( input. previous_output ) {
@@ -2908,7 +2908,6 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
2908
2908
for per_outp_material in cached_claim_datas. per_input_material . values ( ) {
2909
2909
match per_outp_material {
2910
2910
& InputMaterial :: Revoked { ref script, ref is_htlc, ref amount, .. } => {
2911
- log_trace ! ( self , "Is HLTC ? {}" , is_htlc) ;
2912
2911
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 ! ( ) } ) ;
2913
2912
amt += * amount;
2914
2913
} ,
0 commit comments