Skip to main content

SignOutputRaw

SignOutputRaw is a method that can be used to generated a signature for a set of inputs/outputs to a transaction. Each request specifies details concerning how the outputs should be signed, which keys they should be signed with, and also any optional tweaks. The return value is a fixed 64-byte signature (the same format as we use on the wire in Lightning).

If we are unable to sign using the specified keys, then an error will be returned.

Source: signrpc/signer.proto

gRPC

rpc SignOutputRaw (SignReq) returns (SignResp);

REST

HTTP MethodPath
POST /v2/signer/signraw

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 = {
raw_tx_bytes: <bytes>,
sign_descs: <SignDescriptor>,
prev_outputs: <TxOut>,
};
client.signOutputRaw(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "raw_sigs": <bytes>,
// }

Messages

signrpc.SignReq

Source: signrpc/signer.proto

FieldgRPC TypeREST TypeREST Placement
raw_tx_bytes
bytesstringbody
sign_descs
SignDescriptor[]arraybody
prev_outputs
TxOut[]arraybody

signrpc.SignResp

Source: signrpc/signer.proto

FieldgRPC TypeREST Type
raw_sigs
bytes[]array

Nested Messages

signrpc.SignDescriptor

FieldgRPC TypeREST Type
key_desc
KeyDescriptorobject
single_tweak
bytesstring
double_tweak
bytesstring
tap_tweak
bytesstring
witness_script
bytesstring
output
TxOutobject
sighash
uint32integer
input_index
int32integer
sign_method
SignMethodstring

signrpc.KeyDescriptor

FieldgRPC TypeREST Type
raw_key_bytes
bytesstring
key_loc
KeyLocatorobject

signrpc.KeyLocator

FieldgRPC TypeREST Type
key_family
int32integer
key_index
int32integer

signrpc.TxOut

FieldgRPC TypeREST Type
value
int64string
pk_script
bytesstring

Enums

signrpc.SignMethod

NameNumber
SIGN_METHOD_WITNESS_V0
0
SIGN_METHOD_TAPROOT_KEY_SPEND_BIP0086
1
SIGN_METHOD_TAPROOT_KEY_SPEND
2
SIGN_METHOD_TAPROOT_SCRIPT_SPEND
3