@@ -271,6 +271,13 @@ type LightningClient interface {
271271 // relevant to the wallet are sent over.
272272 SubscribeTransactions (ctx context.Context ) (<- chan Transaction ,
273273 <- chan error , error )
274+
275+ // SignMessage signs a message with this node's private key.
276+ // The returned signature string is zbase32 encoded and pubkey
277+ // recoverable, meaning that only the message digest and signature
278+ // are needed for verification.
279+ SignMessage (ctx context.Context , data []byte ) (string ,
280+ error )
274281}
275282
276283// Info contains info about the connected lnd node.
@@ -4132,6 +4139,23 @@ func (s *lightningClient) SendCustomMessage(ctx context.Context,
41324139 return err
41334140}
41344141
4142+ // SignMessage signs a message with this node's private key.
4143+ // The returned signature string is zbase32 encoded and pubkey
4144+ // recoverable, meaning that only the message digest and signature
4145+ // are needed for verification.
4146+ func (s * lightningClient ) SignMessage (ctx context.Context ,
4147+ data []byte ) (string , error ) {
4148+
4149+ rpcCtx := s .adminMac .WithMacaroonAuth (ctx )
4150+ rpcReq := & lnrpc.SignMessageRequest {Msg : data }
4151+ rpcRes , err := s .client .SignMessage (rpcCtx , rpcReq )
4152+ if err != nil {
4153+ return "" , err
4154+ }
4155+
4156+ return rpcRes .Signature , nil
4157+ }
4158+
41354159// SubscribeCustomMessages subscribes to a stream of custom messages, optionally
41364160// filtering by peer and message type. The channels returned will be closed
41374161// when the subscription exits.
0 commit comments