@@ -311,6 +311,17 @@ pub trait ChannelKeys : Send+Clone {
311
311
/// chosen to forgo their output as dust.
312
312
fn sign_closing_transaction < T : secp256k1:: Signing > ( & self , closing_tx : & Transaction , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > ;
313
313
314
+ /// Create a signature for a Child-Pay-For-Parent transaction.
315
+ ///
316
+ /// Such a transaction is used to unilaterally bump a commitment transaction feerate when this
317
+ /// is one isn't confirming quickly.
318
+ ///
319
+ /// Input index is the position of the spending input committed by this BIP 143 signature.
320
+ ///
321
+ /// Spent amount is the value of the output spent by this input committed by this BIP 143
322
+ /// signature.
323
+ fn sign_cpfp < T : secp256k1:: Signing > ( & self , cpfp : & Transaction , input_index : usize , spent_amount : u64 , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > ;
324
+
314
325
/// Signs a channel announcement message with our funding key, proving it comes from one
315
326
/// of the channel participants.
316
327
///
@@ -583,6 +594,13 @@ impl ChannelKeys for InMemoryChannelKeys {
583
594
Ok ( secp_ctx. sign ( & sighash, & self . funding_key ) )
584
595
}
585
596
597
+ fn sign_cpfp < T : secp256k1:: Signing > ( & self , cpfp_tx : & Transaction , input_index : usize , spent_amount : u64 , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > {
598
+ let anchor_redeemscript = chan_utils:: get_anchor_redeemscript ( & self . pubkeys ( ) . funding_pubkey ) ;
599
+ let mut sighash_parts = bip143:: SigHashCache :: new ( cpfp_tx) ;
600
+ let sighash = hash_to_message ! ( & sighash_parts. signature_hash( input_index, & anchor_redeemscript, spent_amount, SigHashType :: All ) [ ..] ) ;
601
+ Ok ( secp_ctx. sign ( & sighash, & self . funding_key ) )
602
+ }
603
+
586
604
fn sign_channel_announcement < T : secp256k1:: Signing > ( & self , msg : & UnsignedChannelAnnouncement , secp_ctx : & Secp256k1 < T > ) -> Result < Signature , ( ) > {
587
605
let msghash = hash_to_message ! ( & Sha256dHash :: hash( & msg. encode( ) [ ..] ) [ ..] ) ;
588
606
Ok ( secp_ctx. sign ( & msghash, & self . funding_key ) )
0 commit comments