Skip to main content

SignMessage

SignMessage signs a message with the key specified in the key locator. The returned signature is fixed-size LN wire format encoded.

The main difference to SignMessage in the main RPC is that a specific key is used to sign the message instead of the node identity private key.

Source: signrpc/signer.proto

gRPC

rpc SignMessage (SignMessageReq) returns (SignMessageResp);

REST

HTTP MethodPath
POST /v2/signer/signmessage

Code Samples

const fs = require('fs');
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');

const GRPC_HOST = 'localhost:10009'
const MACAROON_PATH = 'LND_DIR/data/chain/bitcoin/regtest/admin.macaroon'
const TLS_PATH = 'LND_DIR/tls.cert'

const loaderOptions = {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
};
const packageDefinition = protoLoader.loadSync(['lightning.proto', 'signrpc/signer.proto'], loaderOptions);
const signrpc = grpc.loadPackageDefinition(packageDefinition).signrpc;
process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA';
const tlsCert = fs.readFileSync(TLS_PATH);
const sslCreds = grpc.credentials.createSsl(tlsCert);
const macaroon = fs.readFileSync(MACAROON_PATH).toString('hex');
const macaroonCreds = grpc.credentials.createFromMetadataGenerator(function(args, callback) {
let metadata = new grpc.Metadata();
metadata.add('macaroon', macaroon);
callback(null, metadata);
});
let creds = grpc.credentials.combineChannelCredentials(sslCreds, macaroonCreds);
let client = new signrpc.Signer(GRPC_HOST, creds);
let request = {
msg: <bytes>,
key_loc: <KeyLocator>,
double_hash: <bool>,
compact_sig: <bool>,
schnorr_sig: <bool>,
schnorr_sig_tap_tweak: <bytes>,
};
client.signMessage(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "signature": <bytes>,
// }

Messages

signrpc.SignMessageReq

Source: signrpc/signer.proto

FieldgRPC TypeREST TypeREST Placement
msg
bytesstringbody
key_loc
KeyLocatorobjectbody
double_hash
boolbooleanbody
compact_sig
boolbooleanbody
schnorr_sig
boolbooleanbody
schnorr_sig_tap_tweak
bytesstringbody

signrpc.SignMessageResp

Source: signrpc/signer.proto

FieldgRPC TypeREST Type
signature
bytesstring

Nested Messages

signrpc.KeyLocator

FieldgRPC TypeREST Type
key_family
int32integer
key_index
int32integer