From 0bb2748df66ae7f110b2d0baa03fe956d7b1efac Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Tue, 24 Jun 2025 17:34:32 -0300 Subject: [PATCH] walletkit: add RPC GetTransaction https://lightning.engineering/api-docs/api/lnd/wallet-kit/get-transaction/ The RPC is available since LND 0.18.0. --- testdata/permissions.json | 8 ++++++++ walletkit_client.go | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/testdata/permissions.json b/testdata/permissions.json index e8ef641..e1d7873 100644 --- a/testdata/permissions.json +++ b/testdata/permissions.json @@ -1136,6 +1136,14 @@ } ] }, + "/walletrpc.WalletKit/GetTransaction": { + "permissions": [ + { + "entity": "onchain", + "action": "read" + } + ] + }, "/walletrpc.WalletKit/PendingSweeps": { "permissions": [ { diff --git a/walletkit_client.go b/walletkit_client.go index 682cdab..088d7c3 100644 --- a/walletkit_client.go +++ b/walletkit_client.go @@ -101,6 +101,10 @@ type WalletKitClient interface { addressType walletrpc.AddressType, change bool) (btcutil.Address, error) + // GetTransaction returns details for a transaction found in the wallet. + GetTransaction(ctx context.Context, + txid chainhash.Hash) (Transaction, error) + PublishTransaction(ctx context.Context, tx *wire.MsgTx, label string) error @@ -481,6 +485,26 @@ func (m *walletKitClient) NextAddr(ctx context.Context, accountName string, return addr, nil } +// GetTransaction returns details for a transaction found in the wallet. +func (m *walletKitClient) GetTransaction(ctx context.Context, + txid chainhash.Hash) (Transaction, error) { + + rpcCtx, cancel := context.WithTimeout(ctx, m.timeout) + defer cancel() + + rpcCtx = m.walletKitMac.WithMacaroonAuth(rpcCtx) + + req := &walletrpc.GetTransactionRequest{ + Txid: txid.String(), + } + resp, err := m.client.GetTransaction(rpcCtx, req) + if err != nil { + return Transaction{}, err + } + + return unmarshallTransaction(resp) +} + func (m *walletKitClient) PublishTransaction(ctx context.Context, tx *wire.MsgTx, label string) error {