Skip to main content

GetTransactions

GetTransactions returns a list describing all the known transactions relevant to the wallet.

Source: lightning.proto

gRPC

rpc GetTransactions (GetTransactionsRequest) returns (TransactionDetails);

REST

HTTP MethodPath
GET /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 = {
start_height: <int32>,
end_height: <int32>,
account: <string>,
index_offset: <uint32>,
max_transactions: <uint32>,
};
client.getTransactions(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "transactions": <Transaction>,
// "last_index": <uint64>,
// "first_index": <uint64>,
// }

Messages

lnrpc.GetTransactionsRequest

Source: lightning.proto

FieldgRPC TypeREST TypeREST Placement
start_height
int32integerquery
end_height
int32integerquery
account
stringstringquery
index_offset
uint32integerquery
max_transactions
uint32integerquery

lnrpc.TransactionDetails

Source: lightning.proto

FieldgRPC TypeREST Type
transactions
Transaction[]array
last_index
uint64string
first_index
uint64string

Nested Messages

lnrpc.OutputDetail

FieldgRPC TypeREST Type
output_type
OutputScriptTypestring
address
stringstring
pk_script
stringstring
output_index
int64string
amount
int64string
is_our_address
boolboolean

lnrpc.PreviousOutPoint

FieldgRPC TypeREST Type
outpoint
stringstring
is_our_output
boolboolean

lnrpc.Transaction

FieldgRPC TypeREST Type
tx_hash
stringstring
amount
int64string
num_confirmations
int32integer
block_hash
stringstring
block_height
int32integer
time_stamp
int64string
total_fees
int64string
dest_addressesdeprecated
string[]array
output_details
OutputDetail[]array
raw_tx_hex
stringstring
label
stringstring
previous_outpoints
PreviousOutPoint[]array

Enums

lnrpc.OutputScriptType

NameNumber
SCRIPT_TYPE_PUBKEY_HASH
0
SCRIPT_TYPE_SCRIPT_HASH
1
SCRIPT_TYPE_WITNESS_V0_PUBKEY_HASH
2
SCRIPT_TYPE_WITNESS_V0_SCRIPT_HASH
3
SCRIPT_TYPE_PUBKEY
4
SCRIPT_TYPE_MULTISIG
5
SCRIPT_TYPE_NULLDATA
6
SCRIPT_TYPE_NON_STANDARD
7
SCRIPT_TYPE_WITNESS_UNKNOWN
8
SCRIPT_TYPE_WITNESS_V1_TAPROOT
9