Skip to main content

VerifyMessage

VerifyMessage verifies a signature over a message using the public key provided. The signature must be fixed-size LN wire format encoded.

The main difference to VerifyMessage in the main RPC is that the public key used to sign the message does not have to be a node known to the network.

Source: signrpc/signer.proto

gRPC

rpc VerifyMessage (VerifyMessageReq) returns (VerifyMessageResp);

REST

HTTP MethodPath
POST /v2/signer/verifymessage

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>,
signature: <bytes>,
pubkey: <bytes>,
is_schnorr_sig: <bool>,
};
client.verifyMessage(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "valid": <bool>,
// }

Messages

signrpc.VerifyMessageReq

Source: signrpc/signer.proto

FieldgRPC TypeREST TypeREST Placement
msg
bytesstringbody
signature
bytesstringbody
pubkey
bytesstringbody
is_schnorr_sig
boolbooleanbody

signrpc.VerifyMessageResp

Source: signrpc/signer.proto

FieldgRPC TypeREST Type
valid
boolboolean