@@ -20,7 +20,7 @@ use crate::io_extras::sink;
20
20
use crate :: ln:: channel:: ANCHOR_OUTPUT_VALUE_SATOSHI ;
21
21
use crate :: ln:: types:: ChannelId ;
22
22
use crate :: ln:: chan_utils;
23
- use crate :: ln:: chan_utils:: { ANCHOR_INPUT_WITNESS_WEIGHT , HTLCOutputInCommitment } ;
23
+ use crate :: ln:: chan_utils:: HTLCOutputInCommitment ;
24
24
use crate :: prelude:: * ;
25
25
use crate :: sign:: {
26
26
ChannelDerivationParameters , ChannelSigner , HTLCDescriptor , SignerProvider , P2WPKH_WITNESS_WEIGHT ,
@@ -608,14 +608,17 @@ where
608
608
& self , claim_id : ClaimId , package_target_feerate_sat_per_1000_weight : u32 ,
609
609
commitment_tx : & Transaction , commitment_tx_fee_sat : u64 , anchor_descriptor : & AnchorDescriptor ,
610
610
) -> Result < ( ) , ( ) > {
611
+ let signer = anchor_descriptor. derive_channel_signer ( & self . signer_provider ) ;
612
+ let anchor_input_witness_weight = signer. get_holder_anchor_input_witness_weight ( ) ;
613
+
611
614
// Our commitment transaction already has fees allocated to it, so we should take them into
612
615
// account. We do so by pretending the commitment transaction's fee and weight are part of
613
616
// the anchor input.
614
617
let mut anchor_utxo = anchor_descriptor. previous_utxo ( ) ;
615
618
let commitment_tx_fee_sat = Amount :: from_sat ( commitment_tx_fee_sat) ;
616
619
anchor_utxo. value += commitment_tx_fee_sat;
617
620
let starting_package_and_fixed_input_satisfaction_weight =
618
- commitment_tx. weight ( ) . to_wu ( ) + ANCHOR_INPUT_WITNESS_WEIGHT + EMPTY_SCRIPT_SIG_WEIGHT ;
621
+ commitment_tx. weight ( ) . to_wu ( ) + anchor_input_witness_weight + EMPTY_SCRIPT_SIG_WEIGHT ;
619
622
let mut package_and_fixed_input_satisfaction_weight =
620
623
starting_package_and_fixed_input_satisfaction_weight;
621
624
@@ -640,7 +643,7 @@ where
640
643
output : vec ! [ ] ,
641
644
} ;
642
645
643
- let total_satisfaction_weight = ANCHOR_INPUT_WITNESS_WEIGHT + EMPTY_SCRIPT_SIG_WEIGHT +
646
+ let total_satisfaction_weight = anchor_input_witness_weight + EMPTY_SCRIPT_SIG_WEIGHT +
644
647
coin_selection. confirmed_utxos . iter ( ) . map ( |utxo| utxo. satisfaction_weight ) . sum :: < u64 > ( ) ;
645
648
let total_input_amount = must_spend_amount +
646
649
coin_selection. confirmed_utxos . iter ( ) . map ( |utxo| utxo. output . value ) . sum ( ) ;
@@ -686,7 +689,6 @@ where
686
689
log_debug ! ( self . logger, "Signing anchor transaction {}" , anchor_txid) ;
687
690
anchor_tx = self . utxo_source . sign_psbt ( anchor_psbt) ?;
688
691
689
- let signer = anchor_descriptor. derive_channel_signer ( & self . signer_provider ) ;
690
692
anchor_tx = signer. spend_holder_anchor_input ( & anchor_tx, 0 , & self . secp ) ?;
691
693
692
694
#[ cfg( debug_assertions) ] {
@@ -857,7 +859,7 @@ mod tests {
857
859
use super :: * ;
858
860
859
861
use crate :: io:: Cursor ;
860
- use crate :: ln:: chan_utils:: ChannelTransactionParameters ;
862
+ use crate :: ln:: chan_utils:: { ANCHOR_INPUT_WITNESS_WEIGHT , ChannelTransactionParameters } ;
861
863
use crate :: util:: ser:: Readable ;
862
864
use crate :: util:: test_utils:: { TestBroadcaster , TestLogger } ;
863
865
use crate :: sign:: KeysManager ;
0 commit comments