Skip to main content

SendCoins

SendCoins executes a request to send coins to a particular address. Unlike SendMany, this RPC call only allows creating a single output at a time. If neither target_conf, or sat_per_vbyte are set, then the internal wallet will consult its fee model to determine a fee for the default confirmation target.

Source: lightning.proto

gRPC

rpc SendCoins (SendCoinsRequest) returns (SendCoinsResponse);

REST

HTTP MethodPath
POST /v1/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 = {
addr: <string>,
amount: <int64>,
target_conf: <int32>,
sat_per_vbyte: <uint64>,
sat_per_byte: <int64>,
send_all: <bool>,
label: <string>,
min_confs: <int32>,
spend_unconfirmed: <bool>,
};
client.sendCoins(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "txid": <string>,
// }

Messages

lnrpc.SendCoinsRequest

Source: lightning.proto

FieldgRPC TypeREST TypeREST Placement
addr
stringstringbody
amount
int64stringbody
target_conf
int32integerbody
sat_per_vbyte
uint64stringbody
sat_per_byte
int64stringbody
send_all
boolbooleanbody
label
stringstringbody
min_confs
int32integerbody
spend_unconfirmed
boolbooleanbody

lnrpc.SendCoinsResponse

Source: lightning.proto

FieldgRPC TypeREST Type
txid
stringstring