Skip to content

Commit

Permalink
multi-scope: update listaddresstransactions
Browse files Browse the repository at this point in the history
  • Loading branch information
roylee17 committed Sep 26, 2022
1 parent a0ecaaa commit 4c3f869
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
9 changes: 1 addition & 8 deletions rpc/legacyrpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 4c3f869

Please sign in to comment.