Skip to main content

SendPaymentSync

SendPaymentSync is the synchronous non-streaming version of SendPayment. This RPC is intended to be consumed by clients of the REST proxy. Additionally, this RPC expects the destination's public key and the payment hash (if any) to be encoded as hex strings.

Source: lightning.proto

gRPC

rpc SendPaymentSync (SendRequest) returns (SendResponse);

REST

HTTP MethodPath
POST /v1/channels/transactions

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 = {
dest: <bytes>,
dest_string: <string>,
amt: <int64>,
amt_msat: <int64>,
payment_hash: <bytes>,
payment_hash_string: <string>,
payment_request: <string>,
final_cltv_delta: <int32>,
fee_limit: <FeeLimit>,
outgoing_chan_id: <uint64>,
last_hop_pubkey: <bytes>,
cltv_limit: <uint32>,
dest_custom_records: <DestCustomRecordsEntry>,
allow_self_payment: <bool>,
dest_features: <FeatureBit>,
payment_addr: <bytes>,
};
client.sendPaymentSync(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "payment_error": <string>,
// "payment_preimage": <bytes>,
// "payment_route": <Route>,
// "payment_hash": <bytes>,
// }

Messages

lnrpc.SendRequest

Source: lightning.proto

FieldgRPC TypeREST TypeREST Placement
dest
bytesstringbody
dest_stringdeprecated
stringstringbody
amt
int64stringbody
amt_msat
int64stringbody
payment_hash
bytesstringbody
payment_hash_stringdeprecated
stringstringbody
payment_request
stringstringbody
final_cltv_delta
int32integerbody
fee_limit
FeeLimitobjectbody
outgoing_chan_id
uint64stringbody
last_hop_pubkey
bytesstringbody
cltv_limit
uint32integerbody
dest_custom_records
DestCustomRecordsEntry[]objectbody
allow_self_payment
boolbooleanbody
dest_features
FeatureBit[]arraybody
payment_addr
bytesstringbody

lnrpc.SendResponse

Source: lightning.proto

FieldgRPC TypeREST Type
payment_error
stringstring
payment_preimage
bytesstring
payment_route
Routeobject
payment_hash
bytesstring

Nested Messages

lnrpc.AMPRecord

FieldgRPC TypeREST Type
root_share
bytesstring
set_id
bytesstring
child_index
uint32integer

lnrpc.FeeLimit

FieldgRPC TypeREST Type
fixed
int64string
fixed_msat
int64string
percent
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
blinding_point
bytesstring
encrypted_data
bytesstring
total_amt_msat
uint64string

lnrpc.Hop.CustomRecordsEntry

FieldgRPC TypeREST Type
key
uint64unknown
value
bytesunknown

lnrpc.MPPRecord

FieldgRPC TypeREST Type
payment_addr
bytesstring
total_amt_msat
int64string

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
first_hop_amount_msat
int64string
custom_channel_data
bytesstring

lnrpc.SendRequest.DestCustomRecordsEntry

FieldgRPC TypeREST Type
key
uint64unknown
value
bytesunknown

Enums

lnrpc.FeatureBit

NameNumber
DATALOSS_PROTECT_REQ
0
DATALOSS_PROTECT_OPT
1
INITIAL_ROUING_SYNC
3
UPFRONT_SHUTDOWN_SCRIPT_REQ
4
UPFRONT_SHUTDOWN_SCRIPT_OPT
5
GOSSIP_QUERIES_REQ
6
GOSSIP_QUERIES_OPT
7
TLV_ONION_REQ
8
TLV_ONION_OPT
9
EXT_GOSSIP_QUERIES_REQ
10
EXT_GOSSIP_QUERIES_OPT
11
STATIC_REMOTE_KEY_REQ
12
STATIC_REMOTE_KEY_OPT
13
PAYMENT_ADDR_REQ
14
PAYMENT_ADDR_OPT
15
MPP_REQ
16
MPP_OPT
17
WUMBO_CHANNELS_REQ
18
WUMBO_CHANNELS_OPT
19
ANCHORS_REQ
20
ANCHORS_OPT
21
ANCHORS_ZERO_FEE_HTLC_REQ
22
ANCHORS_ZERO_FEE_HTLC_OPT
23
ROUTE_BLINDING_REQUIRED
24
ROUTE_BLINDING_OPTIONAL
25
AMP_REQ
30
AMP_OPT
31