Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions lightning_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,13 @@ type LightningClient interface {
// relevant to the wallet are sent over.
SubscribeTransactions(ctx context.Context) (<-chan Transaction,
<-chan error, error)

// SignMessage signs a message with this node's private key.
// The returned signature string is zbase32 encoded and pubkey
// recoverable, meaning that only the message digest and signature
// are needed for verification.
SignMessage(ctx context.Context, data []byte) (string,
error)
}

// Info contains info about the connected lnd node.
Expand Down Expand Up @@ -4132,6 +4139,23 @@ func (s *lightningClient) SendCustomMessage(ctx context.Context,
return err
}

// SignMessage signs a message with this node's private key.
// The returned signature string is zbase32 encoded and pubkey
// recoverable, meaning that only the message digest and signature
// are needed for verification.
func (s *lightningClient) SignMessage(ctx context.Context,
data []byte) (string, error) {

rpcCtx := s.adminMac.WithMacaroonAuth(ctx)
rpcReq := &lnrpc.SignMessageRequest{Msg: data}
rpcRes, err := s.client.SignMessage(rpcCtx, rpcReq)
if err != nil {
return "", err
}

return rpcRes.Signature, nil
}

// SubscribeCustomMessages subscribes to a stream of custom messages, optionally
// filtering by peer and message type. The channels returned will be closed
// when the subscription exits.
Expand Down
2 changes: 1 addition & 1 deletion macaroon_recipes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

var (
expectedPermissions = map[string]int{
"lnrpc": 11,
"lnrpc": 12,
"chainrpc": 1,
"invoicesrpc": 2,
"routerrpc": 2,
Expand Down