Skip to content

Commit

Permalink
chore: add get tx details from tx hash only
Browse files Browse the repository at this point in the history
  • Loading branch information
RafilxTenfen committed Oct 16, 2024
1 parent 580adf8 commit db1692a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions walletcontroller/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,21 @@ func (w *RpcWalletController) getTxDetails(req notifier.ConfRequest, msg string)
return res, nofitierStateToWalletState(state), nil
}

// Tx implements WalletController.
func (w *RpcWalletController) Tx(txHash *chainhash.Hash) (*btcjson.GetTransactionResult, *btcutil.Tx, error) {
tx, err := w.Client.GetTransaction(txHash)
if err != nil {
return nil, nil, err
}

rawTx, err := w.Client.GetRawTransaction(txHash)
if err != nil {
return nil, nil, err
}

return tx, rawTx, nil
}

// Fetch info about transaction from mempool or blockchain, requires node to have enabled transaction index
func (w *RpcWalletController) TxDetails(txHash *chainhash.Hash, pkScript []byte) (*notifier.TxConfirmation, TxStatus, error) {
req, err := notifier.NewConfRequest(txHash, pkScript)
Expand Down
2 changes: 2 additions & 0 deletions walletcontroller/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package walletcontroller
import (
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcec/v2/schnorr"
"github.com/btcsuite/btcd/btcjson"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
Expand Down Expand Up @@ -66,6 +67,7 @@ type WalletController interface {
SendRawTransaction(tx *wire.MsgTx, allowHighFees bool) (*chainhash.Hash, error)
ListOutputs(onlySpendable bool) ([]Utxo, error)
TxDetails(txHash *chainhash.Hash, pkScript []byte) (*notifier.TxConfirmation, TxStatus, error)
Tx(txHash *chainhash.Hash) (*btcjson.GetTransactionResult, *btcutil.Tx, error)
SignBip322NativeSegwit(msg []byte, address btcutil.Address) (wire.TxWitness, error)
// SignOneInputTaprootSpendingTransaction signs transactions with one taproot input that
// uses script spending path.
Expand Down

0 comments on commit db1692a

Please sign in to comment.