Skip to main content

SubscribeHtlcEvents

SubscribeHtlcEvents creates a uni-directional stream from the server to the client which delivers a stream of htlc events.

Source: routerrpc/router.proto

gRPC

info

This is a server-streaming RPC

rpc SubscribeHtlcEvents (SubscribeHtlcEventsRequest) returns (stream HtlcEvent);

REST

HTTP MethodPath
GET /v2/router/htlcevents

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', 'routerrpc/router.proto'], loaderOptions);
const routerrpc = grpc.loadPackageDefinition(packageDefinition).routerrpc;
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 routerrpc.Router(GRPC_HOST, creds);
let request = {};
let call = client.subscribeHtlcEvents(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:
// {
// "incoming_channel_id": <uint64>,
// "outgoing_channel_id": <uint64>,
// "incoming_htlc_id": <uint64>,
// "outgoing_htlc_id": <uint64>,
// "timestamp_ns": <uint64>,
// "event_type": <EventType>,
// "forward_event": <ForwardEvent>,
// "forward_fail_event": <ForwardFailEvent>,
// "settle_event": <SettleEvent>,
// "link_fail_event": <LinkFailEvent>,
// "subscribed_event": <SubscribedEvent>,
// "final_htlc_event": <FinalHtlcEvent>,
// }

Messages

routerrpc.SubscribeHtlcEventsRequest

Source: routerrpc/router.proto

note

This request has no parameters.

routerrpc.HtlcEvent

Source: routerrpc/router.proto

FieldgRPC TypeREST Type
incoming_channel_id
uint64string
outgoing_channel_id
uint64string
incoming_htlc_id
uint64string
outgoing_htlc_id
uint64string
timestamp_ns
uint64string
event_type
EventTypestring
forward_event
ForwardEventobject
forward_fail_event
ForwardFailEventobject
settle_event
SettleEventobject
link_fail_event
LinkFailEventobject
subscribed_event
SubscribedEventobject
final_htlc_event
FinalHtlcEventobject

Nested Messages

routerrpc.ForwardEvent

FieldgRPC TypeREST Type
info
HtlcInfoobject

routerrpc.HtlcInfo

FieldgRPC TypeREST Type
incoming_timelock
uint32integer
outgoing_timelock
uint32integer
incoming_amt_msat
uint64string
outgoing_amt_msat
uint64string

routerrpc.ForwardFailEvent

note

This response has no parameters.

routerrpc.SettleEvent

FieldgRPC TypeREST Type
preimage
bytesstring

routerrpc.LinkFailEvent

FieldgRPC TypeREST Type
info
HtlcInfoobject
wire_failure
FailureCodestring
failure_detail
FailureDetailstring
failure_string
stringstring

routerrpc.SubscribedEvent

note

This response has no parameters.

routerrpc.FinalHtlcEvent

FieldgRPC TypeREST Type
settled
boolboolean
offchain
boolboolean

Enums

routerrpc.HtlcEvent.EventType

NameNumber
UNKNOWN
0
SEND
1
RECEIVE
2
FORWARD
3

lnrpc.Failure.FailureCode

NameNumber
RESERVED
0
INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS
1
INCORRECT_PAYMENT_AMOUNT
2
FINAL_INCORRECT_CLTV_EXPIRY
3
FINAL_INCORRECT_HTLC_AMOUNT
4
FINAL_EXPIRY_TOO_SOON
5
INVALID_REALM
6
EXPIRY_TOO_SOON
7
INVALID_ONION_VERSION
8
INVALID_ONION_HMAC
9
INVALID_ONION_KEY
10
AMOUNT_BELOW_MINIMUM
11
FEE_INSUFFICIENT
12
INCORRECT_CLTV_EXPIRY
13
CHANNEL_DISABLED
14
TEMPORARY_CHANNEL_FAILURE
15
REQUIRED_NODE_FEATURE_MISSING
16
REQUIRED_CHANNEL_FEATURE_MISSING
17
UNKNOWN_NEXT_PEER
18
TEMPORARY_NODE_FAILURE
19
PERMANENT_NODE_FAILURE
20
PERMANENT_CHANNEL_FAILURE
21
EXPIRY_TOO_FAR
22
MPP_TIMEOUT
23
INVALID_ONION_PAYLOAD
24
INTERNAL_FAILURE
997
UNKNOWN_FAILURE
998
UNREADABLE_FAILURE
999

routerrpc.FailureDetail

NameNumber
UNKNOWN
0
NO_DETAIL
1
ONION_DECODE
2
LINK_NOT_ELIGIBLE
3
ON_CHAIN_TIMEOUT
4
HTLC_EXCEEDS_MAX
5
INSUFFICIENT_BALANCE
6
INCOMPLETE_FORWARD
7
HTLC_ADD_FAILED
8
FORWARDS_DISABLED
9
INVOICE_CANCELED
10
INVOICE_UNDERPAID
11
INVOICE_EXPIRY_TOO_SOON
12
INVOICE_NOT_OPEN
13
MPP_INVOICE_TIMEOUT
14
ADDRESS_MISMATCH
15
SET_TOTAL_MISMATCH
16
SET_TOTAL_TOO_LOW
17
SET_OVERPAID
18
UNKNOWN_INVOICE
19
INVALID_KEYSEND
20
MPP_IN_PROGRESS
21
CIRCULAR_ROUTE
22