Skip to main content

RegisterConfirmationsNtfn

RegisterConfirmationsNtfn is a synchronous response-streaming RPC that registers an intent for a client to be notified once a confirmation request has reached its required number of confirmations on-chain.

A confirmation request must have a valid output script. It is also possible to give a transaction ID. If the transaction ID is not set, a notification is sent once the output script confirms. If the transaction ID is also set, a notification is sent once the output script confirms in the given transaction.

Source: chainrpc/chainnotifier.proto

gRPC

info

This is a server-streaming RPC

rpc RegisterConfirmationsNtfn (ConfRequest) returns (stream ConfEvent);

REST

HTTP MethodPath
POST /v2/chainnotifier/register/confirmations

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', 'chainrpc/chainnotifier.proto'], loaderOptions);
const chainrpc = grpc.loadPackageDefinition(packageDefinition).chainrpc;
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 chainrpc.ChainNotifier(GRPC_HOST, creds);
let request = {
txid: <bytes>,
script: <bytes>,
num_confs: <uint32>,
height_hint: <uint32>,
include_block: <bool>,
};
let call = client.registerConfirmationsNtfn(request);
call.on('data', function(response) {
// A response was received from the server.
console.log(response);
});
call.on('status', function(status) {
// The current status of the stream.
});
call.on('end', function() {
// The server has closed the stream.
});
// Console output:
// {
// "conf": <ConfDetails>,
// "reorg": <Reorg>,
// }

Messages

chainrpc.ConfRequest

Source: chainrpc/chainnotifier.proto

FieldgRPC TypeREST TypeREST Placement
txid
bytesstringbody
script
bytesstringbody
num_confs
uint32integerbody
height_hint
uint32integerbody
include_block
boolbooleanbody

chainrpc.ConfEvent

Source: chainrpc/chainnotifier.proto

FieldgRPC TypeREST Type
conf
ConfDetailsobject
reorg
Reorgobject

Nested Messages

chainrpc.ConfDetails

FieldgRPC TypeREST Type
raw_tx
bytesstring
block_hash
bytesstring
block_height
uint32integer
tx_index
uint32integer
raw_block
bytesstring

chainrpc.Reorg

note

This response has no parameters.