@@ -26,9 +26,10 @@ use bitcoin::hashes::sha256::Hash as Sha256;
2626use bitcoin:: hashes:: sha256d:: Hash as Sha256dHash ;
2727use bitcoin:: hash_types:: WPubkeyHash ;
2828
29- use bitcoin:: secp256k1:: { PublicKey , Scalar , Secp256k1 , SecretKey , Signing } ;
29+ use bitcoin:: secp256k1:: { Message , PublicKey , Scalar , Secp256k1 , SecretKey , Signing } ;
3030use bitcoin:: secp256k1:: ecdh:: SharedSecret ;
3131use bitcoin:: secp256k1:: ecdsa:: { RecoverableSignature , Signature } ;
32+ use bitcoin:: secp256k1:: schnorr;
3233use bitcoin:: { PackedLockTime , secp256k1, Sequence , Witness } ;
3334
3435use crate :: util:: transaction_utils;
@@ -620,6 +621,19 @@ pub trait NodeSigner {
620621 /// Errors if the [`Recipient`] variant is not supported by the implementation.
621622 fn sign_invoice ( & self , hrp_bytes : & [ u8 ] , invoice_data : & [ u5 ] , recipient : Recipient ) -> Result < RecoverableSignature , ( ) > ;
622623
624+ /// Signs a BOLT 12 message.
625+ ///
626+ /// The message is given in `bytes` as a serialized TLV stream with `tag` identifying the
627+ /// message type as defined in the BOLT 12 spec's "Signature Calculation" section. The `digest`
628+ /// is the tagged merkle root to be signed and can be re-calculated using `tag` and `bytes` if
629+ /// blindly signing the digest should be avoided.
630+ ///
631+ /// `metadata` is either the payer or offer metadata, depending on the message type and origin,
632+ /// and may be useful in order to derive the signing keys.
633+ fn sign_bolt12_message (
634+ & self , digest : & Message , tag : & str , bytes : & [ u8 ] , metadata : & [ u8 ]
635+ ) -> Result < schnorr:: Signature , ( ) > ;
636+
623637 /// Sign a gossip message.
624638 ///
625639 /// Note that if this fails, LDK may panic and the message will not be broadcast to the network
@@ -1437,6 +1451,12 @@ impl NodeSigner for KeysManager {
14371451 Ok ( self . secp_ctx . sign_ecdsa_recoverable ( & hash_to_message ! ( & Sha256 :: hash( & preimage) ) , secret) )
14381452 }
14391453
1454+ fn sign_bolt12_message (
1455+ & self , digest : & Message , tag : & str , bytes : & [ u8 ] , metadata : & [ u8 ]
1456+ ) -> Result < schnorr:: Signature , ( ) > {
1457+ todo ! ( )
1458+ }
1459+
14401460 fn sign_gossip_message ( & self , msg : UnsignedGossipMessage ) -> Result < Signature , ( ) > {
14411461 let msg_hash = hash_to_message ! ( & Sha256dHash :: hash( & msg. encode( ) [ ..] ) [ ..] ) ;
14421462 Ok ( self . secp_ctx . sign_ecdsa ( & msg_hash, & self . node_secret ) )
@@ -1545,6 +1565,12 @@ impl NodeSigner for PhantomKeysManager {
15451565 Ok ( self . inner . secp_ctx . sign_ecdsa_recoverable ( & hash_to_message ! ( & Sha256 :: hash( & preimage) ) , secret) )
15461566 }
15471567
1568+ fn sign_bolt12_message (
1569+ & self , digest : & Message , tag : & str , bytes : & [ u8 ] , metadata : & [ u8 ]
1570+ ) -> Result < schnorr:: Signature , ( ) > {
1571+ todo ! ( )
1572+ }
1573+
15481574 fn sign_gossip_message ( & self , msg : UnsignedGossipMessage ) -> Result < Signature , ( ) > {
15491575 self . inner . sign_gossip_message ( msg)
15501576 }
0 commit comments