@@ -309,6 +309,17 @@ pub trait BaseSign {
309
309
/// chosen to forgo their output as dust.
310
310
fn sign_closing_transaction ( & self , closing_tx : & Transaction , secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < Signature , ( ) > ;
311
311
312
+ /// Create a signature for a Child-Pay-For-Parent transaction.
313
+ ///
314
+ /// Such a transaction is used to unilaterally bump a commitment transaction feerate when this
315
+ /// is one isn't confirming quickly.
316
+ ///
317
+ /// Input index is the position of the spending input committed by this BIP 143 signature.
318
+ ///
319
+ /// Spent amount is the value of the output spent by this input committed by this BIP 143
320
+ /// signature.
321
+ fn sign_cpfp ( & self , cpfp : & Transaction , input_index : usize , spent_amount : u64 , secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < Signature , ( ) > ;
322
+
312
323
/// Signs a channel announcement message with our funding key, proving it comes from one
313
324
/// of the channel participants.
314
325
///
@@ -667,6 +678,13 @@ impl BaseSign for InMemorySigner {
667
678
Ok ( secp_ctx. sign ( & msghash, & self . funding_key ) )
668
679
}
669
680
681
+ fn sign_cpfp ( & self , cpfp_tx : & Transaction , input_index : usize , spent_amount : u64 , secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Result < Signature , ( ) > {
682
+ let anchor_redeemscript = chan_utils:: get_anchor_redeemscript ( & self . pubkeys ( ) . funding_pubkey ) ;
683
+ let mut sighash_parts = bip143:: SigHashCache :: new ( cpfp_tx) ;
684
+ let sighash = hash_to_message ! ( & sighash_parts. signature_hash( input_index, & anchor_redeemscript, spent_amount, SigHashType :: All ) [ ..] ) ;
685
+ Ok ( secp_ctx. sign ( & sighash, & self . funding_key ) )
686
+ }
687
+
670
688
fn ready_channel ( & mut self , channel_parameters : & ChannelTransactionParameters ) {
671
689
assert ! ( self . channel_parameters. is_none( ) , "Acceptance already noted" ) ;
672
690
assert ! ( channel_parameters. is_populated( ) , "Channel parameters must be fully populated" ) ;
0 commit comments