Skip to main content

HtlcModifier

HtlcModifier is a bidirectional streaming RPC that allows a client to intercept and modify the HTLCs that attempt to settle the given invoice. The server will send HTLCs of invoices to the client and the client can modify some aspects of the HTLC in order to pass the invoice acceptance tests.

Source: invoicesrpc/invoices.proto

gRPC

info

This is a bidirectional-streaming RPC

rpc HtlcModifier (stream HtlcModifyResponse) returns (stream HtlcModifyRequest);

REST

HTTP MethodPath
POST /v2/invoices/htlcmodifier

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', 'invoicesrpc/invoices.proto'], loaderOptions);
const invoicesrpc = grpc.loadPackageDefinition(packageDefinition).invoicesrpc;
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 invoicesrpc.Invoices(GRPC_HOST, creds);
let request = {
circuit_key: <CircuitKey>,
amt_paid: <uint64>,
cancel_set: <bool>,
};
let call = client.htlcModifier({});
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.
});
call.write(request);
// Console output:
// {
// "invoice": <Invoice>,
// "exit_htlc_circuit_key": <CircuitKey>,
// "exit_htlc_amt": <uint64>,
// "exit_htlc_expiry": <uint32>,
// "current_height": <uint32>,
// "exit_htlc_wire_custom_records": <ExitHtlcWireCustomRecordsEntry>,
// }

Messages

invoicesrpc.HtlcModifyResponse

Source: invoicesrpc/invoices.proto

FieldgRPC TypeREST TypeREST Placement
circuit_key
CircuitKeyobjectbody
amt_paid
uint64stringbody
cancel_set
boolbooleanbody

invoicesrpc.HtlcModifyRequest

Source: invoicesrpc/invoices.proto

FieldgRPC TypeREST Type
invoice
Invoiceobject
exit_htlc_circuit_key
CircuitKeyobject
exit_htlc_amt
uint64string
exit_htlc_expiry
uint32integer
current_height
uint32integer
exit_htlc_wire_custom_records
ExitHtlcWireCustomRecordsEntry[]object

Nested Messages

invoicesrpc.CircuitKey

FieldgRPC TypeREST Type
chan_id
uint64string
htlc_id
uint64string

invoicesrpc.HtlcModifyRequest.ExitHtlcWireCustomRecordsEntry

FieldgRPC TypeREST Type
key
uint64unknown
value
bytesunknown

lnrpc.AMP

FieldgRPC TypeREST Type
root_share
bytesstring
set_id
bytesstring
child_index
uint32integer
hash
bytesstring
preimage
bytesstring

lnrpc.AMPInvoiceState

FieldgRPC TypeREST Type
state
InvoiceHTLCStatestring
settle_index
uint64string
settle_time
int64string
amt_paid_msat
int64string

lnrpc.BlindedPathConfig

FieldgRPC TypeREST Type
min_num_real_hops
uint32integer
num_hops
uint32integer
max_num_paths
uint32integer
node_omission_list
bytes[]array

lnrpc.Feature

FieldgRPC TypeREST Type
name
stringstring
is_required
boolboolean
is_known
boolboolean

lnrpc.HopHint

FieldgRPC TypeREST Type
node_id
stringstring
chan_id
uint64string
fee_base_msat
uint32integer
fee_proportional_millionths
uint32integer
cltv_expiry_delta
uint32integer

lnrpc.Invoice

FieldgRPC TypeREST Type
memo
stringstring
r_preimage
bytesstring
r_hash
bytesstring
value
int64string
value_msat
int64string
settleddeprecated
boolboolean
creation_date
int64string
settle_date
int64string
payment_request
stringstring
description_hash
bytesstring
expiry
int64string
fallback_addr
stringstring
cltv_expiry
uint64string
route_hints
RouteHint[]array
private
boolboolean
add_index
uint64string
settle_index
uint64string
amt_paiddeprecated
int64string
amt_paid_sat
int64string
amt_paid_msat
int64string
state
InvoiceStatestring
htlcs
InvoiceHTLC[]array
features
FeaturesEntry[]object
is_keysend
boolboolean
payment_addr
bytesstring
is_amp
boolboolean
amp_invoice_state
AmpInvoiceStateEntry[]object
is_blinded
boolboolean
blinded_path_config
BlindedPathConfigobject

lnrpc.Invoice.AmpInvoiceStateEntry

FieldgRPC TypeREST Type
key
stringunknown
value
AMPInvoiceStateunknown

lnrpc.Invoice.FeaturesEntry

FieldgRPC TypeREST Type
key
uint32unknown
value
Featureunknown

lnrpc.InvoiceHTLC

FieldgRPC TypeREST Type
chan_id
uint64string
htlc_index
uint64string
amt_msat
uint64string
accept_height
int32integer
accept_time
int64string
resolve_time
int64string
expiry_height
int32integer
state
InvoiceHTLCStatestring
custom_records
CustomRecordsEntry[]object
mpp_total_amt_msat
uint64string
amp
AMPobject
custom_channel_data
bytesstring

lnrpc.InvoiceHTLC.CustomRecordsEntry

FieldgRPC TypeREST Type
key
uint64unknown
value
bytesunknown

lnrpc.RouteHint

FieldgRPC TypeREST Type
hop_hints
HopHint[]array

Enums

lnrpc.Invoice.InvoiceState

NameNumber
OPEN
0
SETTLED
1
CANCELED
2
ACCEPTED
3

lnrpc.InvoiceHTLCState

NameNumber
ACCEPTED
0
SETTLED
1
CANCELED
2