Skip to main content

GetTransaction

GetTransaction returns details for a transaction found in the wallet.

Source: walletrpc/walletkit.proto

gRPC

rpc GetTransaction (GetTransactionRequest) returns (Transaction);

REST

HTTP MethodPath
GET /v2/wallet/tx

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', 'walletrpc/walletkit.proto'], loaderOptions);
const walletrpc = grpc.loadPackageDefinition(packageDefinition).walletrpc;
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 walletrpc.WalletKit(GRPC_HOST, creds);
let request = {
txid: <string>,
};
client.getTransaction(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "tx_hash": <string>,
// "amount": <int64>,
// "num_confirmations": <int32>,
// "block_hash": <string>,
// "block_height": <int32>,
// "time_stamp": <int64>,
// "total_fees": <int64>,
// "dest_addresses": <string>,
// "output_details": <OutputDetail>,
// "raw_tx_hex": <string>,
// "label": <string>,
// "previous_outpoints": <PreviousOutPoint>,
// }

Messages

walletrpc.GetTransactionRequest

Source: walletrpc/walletkit.proto

FieldgRPC TypeREST TypeREST Placement
txid
stringstringquery

lnrpc.Transaction

Source: lightning.proto

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

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

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