multi-account: update listaddresstransactions

This commit is contained in:
Roy Lee 2022-08-28 23:28:42 -07:00
parent 51e700e7d9
commit 50950fb0d5
2 changed files with 5 additions and 11 deletions

View file

@ -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

View file

@ -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
}