@@ -25,9 +25,10 @@ use bitcoin::hashes::sha256::Hash as Sha256;
2525use bitcoin:: hashes:: sha256d:: Hash as Sha256dHash ;
2626use bitcoin:: hash_types:: WPubkeyHash ;
2727
28- use bitcoin:: secp256k1:: { PublicKey , Scalar , Secp256k1 , SecretKey , Signing } ;
28+ use bitcoin:: secp256k1:: { Message , PublicKey , Scalar , Secp256k1 , SecretKey , Signing } ;
2929use bitcoin:: secp256k1:: ecdh:: SharedSecret ;
3030use bitcoin:: secp256k1:: ecdsa:: { RecoverableSignature , Signature } ;
31+ use bitcoin:: secp256k1:: schnorr;
3132use bitcoin:: { PackedLockTime , secp256k1, Sequence , Witness } ;
3233
3334use crate :: util:: transaction_utils;
@@ -494,6 +495,19 @@ pub trait NodeSigner {
494495 /// Errors if the [`Recipient`] variant is not supported by the implementation.
495496 fn sign_invoice ( & self , hrp_bytes : & [ u8 ] , invoice_data : & [ u5 ] , recipient : Recipient ) -> Result < RecoverableSignature , ( ) > ;
496497
498+ /// Signs a BOLT 12 message.
499+ ///
500+ /// The message is given in `bytes` as a serialized TLV stream with `tag` identifying the
501+ /// message type as defined in the BOLT 12 spec's "Signature Calculation" section. The `digest`
502+ /// is the tagged merkle root to be signed and can be re-calculated using `tag` and `bytes` if
503+ /// blindly signing the digest should be avoided.
504+ ///
505+ /// `metadata` is either the payer or offer metadata, depending on the message type and origin,
506+ /// and may be useful in order to derive the signing keys.
507+ fn sign_bolt12_message (
508+ & self , digest : & Message , tag : & str , bytes : & [ u8 ] , metadata : & [ u8 ]
509+ ) -> Result < schnorr:: Signature , ( ) > ;
510+
497511 /// Sign a gossip message.
498512 ///
499513 /// Note that if this fails, LDK may panic and the message will not be broadcast to the network
@@ -1286,6 +1300,12 @@ impl NodeSigner for KeysManager {
12861300 Ok ( self . secp_ctx . sign_ecdsa_recoverable ( & hash_to_message ! ( & Sha256 :: hash( & preimage) ) , secret) )
12871301 }
12881302
1303+ fn sign_bolt12_message (
1304+ & self , digest : & Message , tag : & str , bytes : & [ u8 ] , metadata : & [ u8 ]
1305+ ) -> Result < schnorr:: Signature , ( ) > {
1306+ todo ! ( )
1307+ }
1308+
12891309 fn sign_gossip_message ( & self , msg : UnsignedGossipMessage ) -> Result < Signature , ( ) > {
12901310 let msg_hash = hash_to_message ! ( & Sha256dHash :: hash( & msg. encode( ) [ ..] ) [ ..] ) ;
12911311 Ok ( sign ( & self . secp_ctx , & msg_hash, & self . node_secret ) )
@@ -1394,6 +1414,12 @@ impl NodeSigner for PhantomKeysManager {
13941414 Ok ( self . inner . secp_ctx . sign_ecdsa_recoverable ( & hash_to_message ! ( & Sha256 :: hash( & preimage) ) , secret) )
13951415 }
13961416
1417+ fn sign_bolt12_message (
1418+ & self , digest : & Message , tag : & str , bytes : & [ u8 ] , metadata : & [ u8 ]
1419+ ) -> Result < schnorr:: Signature , ( ) > {
1420+ todo ! ( )
1421+ }
1422+
13971423 fn sign_gossip_message ( & self , msg : UnsignedGossipMessage ) -> Result < Signature , ( ) > {
13981424 self . inner . sign_gossip_message ( msg)
13991425 }
0 commit comments