mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-10 06:07:16 +01:00
rpc: add gettransaction endpoint to walletrpc sub-server
This commit is contained in:
@@ -1853,9 +1853,9 @@ var listChainTxnsCommand = cli.Command{
|
||||
cli.Int64Flag{
|
||||
Name: "end_height",
|
||||
Usage: "the block height until which to list " +
|
||||
"transactions, inclusive, to get transactions " +
|
||||
"until the chain tip, including unconfirmed, " +
|
||||
"set this value to -1",
|
||||
"transactions, inclusive, to get " +
|
||||
"transactions until the chain tip, including " +
|
||||
"unconfirmed, set this value to -1",
|
||||
},
|
||||
},
|
||||
Description: `
|
||||
|
||||
@@ -74,6 +74,7 @@ func walletCommands() []cli.Command {
|
||||
listSweepsCommand,
|
||||
labelTxCommand,
|
||||
publishTxCommand,
|
||||
getTxCommand,
|
||||
releaseOutputCommand,
|
||||
leaseOutputCommand,
|
||||
listLeasesCommand,
|
||||
@@ -561,6 +562,43 @@ func publishTransaction(ctx *cli.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
var getTxCommand = cli.Command{
|
||||
Name: "gettx",
|
||||
Usage: "Returns details of a transaction.",
|
||||
ArgsUsage: "txid",
|
||||
Description: `
|
||||
Query the transaction using the given transaction id and return its
|
||||
details. An error is returned if the transaction is not found.
|
||||
`,
|
||||
Action: actionDecorator(getTransaction),
|
||||
}
|
||||
|
||||
func getTransaction(ctx *cli.Context) error {
|
||||
ctxc := getContext()
|
||||
|
||||
// Display the command's help message if we do not have the expected
|
||||
// number of arguments/flags.
|
||||
if ctx.NArg() != 1 {
|
||||
return cli.ShowCommandHelp(ctx, "gettx")
|
||||
}
|
||||
|
||||
walletClient, cleanUp := getWalletClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
req := &walletrpc.GetTransactionRequest{
|
||||
Txid: ctx.Args().First(),
|
||||
}
|
||||
|
||||
res, err := walletClient.GetTransaction(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printRespJSON(res)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// utxoLease contains JSON annotations for a lease on an unspent output.
|
||||
type utxoLease struct {
|
||||
ID string `json:"id"`
|
||||
|
||||
Reference in New Issue
Block a user