@@ -278,6 +278,14 @@ type LightningClient interface {
278278 // are needed for verification.
279279 SignMessage (ctx context.Context , data []byte ) (string ,
280280 error )
281+
282+ // VerifyMessage verifies a signature over a msg. The signature must
283+ // be zbase32 encoded and signed by an active node in the resident
284+ // node's channel database. In addition to returning the validity of
285+ // the signature, VerifyMessage also returns the recovered pubkey
286+ // from the signature.
287+ VerifyMessage (ctx context.Context , data []byte , signature string ) (bool ,
288+ string , error )
281289}
282290
283291// Info contains info about the connected lnd node.
@@ -4156,6 +4164,24 @@ func (s *lightningClient) SignMessage(ctx context.Context,
41564164 return rpcRes .Signature , nil
41574165}
41584166
4167+ // VerifyMessage verifies a signature over a msg. The signature must
4168+ // be zbase32 encoded and signed by an active node in the resident
4169+ // node's channel database. In addition to returning the validity of
4170+ // the signature, VerifyMessage also returns the recovered pubkey
4171+ // from the signature.
4172+ func (s * lightningClient ) VerifyMessage (ctx context.Context ,
4173+ data []byte , signature string ) (bool , string , error ) {
4174+
4175+ rpcCtx := s .adminMac .WithMacaroonAuth (ctx )
4176+ rpcReq := & lnrpc.VerifyMessageRequest {Msg : data , Signature : signature }
4177+ rpcRes , err := s .client .VerifyMessage (rpcCtx , rpcReq )
4178+ if err != nil {
4179+ return false , "" , err
4180+ }
4181+
4182+ return rpcRes .Valid , rpcRes .Pubkey , nil
4183+ }
4184+
41594185// SubscribeCustomMessages subscribes to a stream of custom messages, optionally
41604186// filtering by peer and message type. The channels returned will be closed
41614187// when the subscription exits.
0 commit comments