Skip to main content

SendToRoute

danger

This RPC is deprecated and will be removed in a future version.

Deprecated, use routerrpc.SendToRouteV2. SendToRoute is a bi-directional streaming RPC for sending payment through the Lightning Network. This method differs from SendPayment in that it allows users to specify a full route manually. This can be used for things like rebalancing, and atomic swaps.

Source: lightning.proto

gRPC

info

This is a bidirectional-streaming RPC

rpc SendToRoute (stream SendToRouteRequest) returns (stream SendResponse);

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', loaderOptions);
const lnrpc = grpc.loadPackageDefinition(packageDefinition).lnrpc;
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 lnrpc.Lightning(GRPC_HOST, creds);
let request = {
payment_hash: <bytes>,
payment_hash_string: <string>,
route: <Route>,
};
let call = client.sendToRoute({});
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:
// {
// "payment_error": <string>,
// "payment_preimage": <bytes>,
// "payment_route": <Route>,
// "payment_hash": <bytes>,
// }

Messages

lnrpc.SendToRouteRequest

Source: lightning.proto

FieldgRPC TypeREST TypeREST Placement
payment_hash
bytesstringunknown
payment_hash_string
stringstringunknown
route
Routeobjectunknown

lnrpc.SendResponse

Source: lightning.proto

FieldgRPC TypeREST Type
payment_error
stringstring
payment_preimage
bytesstring
payment_route
Routeobject
payment_hash
bytesstring

Nested Messages

lnrpc.Route

FieldgRPC TypeREST Type
total_time_lock
uint32integer
total_fees
int64string
total_amt
int64string
hops
Hop[]array
total_fees_msat
int64string
total_amt_msat
int64string

lnrpc.Hop

FieldgRPC TypeREST Type
chan_id
uint64string
chan_capacity
int64string
amt_to_forward
int64string
fee
int64string
expiry
uint32integer
amt_to_forward_msat
int64string
fee_msat
int64string
pub_key
stringstring
tlv_payload
boolboolean
mpp_record
MPPRecordobject
amp_record
AMPRecordobject
custom_records
CustomRecordsEntry[]object
metadata
bytesstring

lnrpc.MPPRecord

FieldgRPC TypeREST Type
payment_addr
bytesstring
total_amt_msat
int64string

lnrpc.AMPRecord

FieldgRPC TypeREST Type
root_share
bytesstring
set_id
bytesstring
child_index
uint32integer

lnrpc.Hop.CustomRecordsEntry

FieldgRPC TypeREST Type
key
uint64unknown
value
bytesunknown