rpc: add gettransaction endpoint to walletrpc sub-server
This commit is contained in:
1 parent
c32edbd732
commit
f0bc6d804c
14 files changed
+1130
-745
No files matched your search
@@ -80,6 +80,10 @@ var (
|
||||
Entity: "address",
|
||||
Action: "read",
|
||||
}},
|
||||
"/walletrpc.WalletKit/GetTransaction": {{
|
||||
Entity: "onchain",
|
||||
Action: "read",
|
||||
}},
|
||||
"/walletrpc.WalletKit/PublishTransaction": {{
|
||||
Entity: "onchain",
|
||||
Action: "write",
|
||||
@@ -612,6 +616,29 @@ func (w *WalletKit) NextAddr(ctx context.Context,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// GetTransaction returns a transaction from the wallet given its hash.
|
||||
func (w *WalletKit) GetTransaction(_ context.Context,
|
||||
req *GetTransactionRequest) (*lnrpc.Transaction, error) {
|
||||
|
||||
// If the client doesn't specify a hash, then there's nothing to
|
||||
// return.
|
||||
if req.Txid == "" {
|
||||
return nil, fmt.Errorf("must provide a transaction hash")
|
||||
}
|
||||
|
||||
txHash, err := chainhash.NewHashFromStr(req.Txid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res, err := w.cfg.Wallet.GetTransactionDetails(txHash)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return lnrpc.RPCTransaction(res), nil
|
||||
}
|
||||
|
||||
// Attempts to publish the passed transaction to the network. Once this returns
|
||||
// without an error, the wallet will continually attempt to re-broadcast the
|
||||
// transaction on start up, until it enters the chain.
|
||||
|
||||
Reference in new issue
Block a user