From 50950fb0d5b64979dc34ef2accd07b051f536558 Mon Sep 17 00:00:00 2001 From: Roy Lee Date: Sun, 28 Aug 2022 23:28:42 -0700 Subject: [PATCH] multi-account: update listaddresstransactions --- rpc/legacyrpc/methods.go | 9 +-------- wallet/wallet.go | 7 ++++--- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/rpc/legacyrpc/methods.go b/rpc/legacyrpc/methods.go index 1f37cbd..025adf2 100644 --- a/rpc/legacyrpc/methods.go +++ b/rpc/legacyrpc/methods.go @@ -1501,13 +1501,6 @@ func listTransactions(icmd interface{}, w *wallet.Wallet) (interface{}, error) { func listAddressTransactions(icmd interface{}, w *wallet.Wallet) (interface{}, error) { cmd := icmd.(*btcjson.ListAddressTransactionsCmd) - if cmd.Account != nil && *cmd.Account != "*" { - return nil, &btcjson.RPCError{ - Code: btcjson.ErrRPCInvalidParameter, - Message: "Listing transactions for addresses may only be done for all accounts", - } - } - // Decode addresses. hash160Map := make(map[string]struct{}) for _, addrStr := range cmd.Addresses { @@ -1518,7 +1511,7 @@ func listAddressTransactions(icmd interface{}, w *wallet.Wallet) (interface{}, e hash160Map[string(addr.ScriptAddress())] = struct{}{} } - return w.ListAddressTransactions(hash160Map) + return w.ListAddressTransactions(*cmd.Account, hash160Map) } // listAllTransactions handles a listalltransactions request by returning diff --git a/wallet/wallet.go b/wallet/wallet.go index c2e2ded..70a7889 100644 --- a/wallet/wallet.go +++ b/wallet/wallet.go @@ -2126,7 +2126,7 @@ func (w *Wallet) ListTransactions(accountName string, from, count int) ([]btcjso // ListAddressTransactions returns a slice of objects with details about // recorded transactions to or from any address belonging to a set. This is // intended to be used for listaddresstransactions RPC replies. -func (w *Wallet) ListAddressTransactions(pkHashes map[string]struct{}) ([]btcjson.ListTransactionsResult, error) { +func (w *Wallet) ListAddressTransactions(accountName string, pkHashes map[string]struct{}) ([]btcjson.ListTransactionsResult, error) { txList := []btcjson.ListTransactionsResult{} err := walletdb.View(w.db, func(tx walletdb.ReadTx) error { txmgrNs := tx.ReadBucket(wtxmgrNamespaceKey) @@ -2155,8 +2155,9 @@ func (w *Wallet) ListAddressTransactions(pkHashes map[string]struct{}) ([]btcjso continue } - jsonResults := listTransactions(tx, detail, - w.Manager, syncBlock.Height, w.chainParams) + jsonResults := listTransactions(accountName, + tx, detail, w.Manager, + syncBlock.Height, w.chainParams) txList = append(txList, jsonResults...) continue loopDetails }