multi-account: update listalltransactions

This commit is contained in:
Roy Lee 2022-08-25 22:17:15 -07:00
parent 2e8dcc4312
commit 1edb90e0aa
2 changed files with 5 additions and 10 deletions

View file

@ -1526,16 +1526,10 @@ func listAddressTransactions(icmd interface{}, w *wallet.Wallet) (interface{}, e
// similar to ListTransactions, except it takes only a single optional
// argument for the account name and replies with all transactions.
func listAllTransactions(icmd interface{}, w *wallet.Wallet) (interface{}, error) {
cmd := icmd.(*btcjson.ListAllTransactionsCmd)
if cmd.Account != nil && *cmd.Account != "*" {
return nil, &btcjson.RPCError{
Code: btcjson.ErrRPCInvalidParameter,
Message: "Listing all transactions may only be done for all accounts",
}
}
return w.ListAllTransactions()
return w.ListAllTransactions(*cmd.Account)
}
// listUnspent handles the listunspent command.

View file

@ -2172,7 +2172,7 @@ func (w *Wallet) ListAddressTransactions(pkHashes map[string]struct{}) ([]btcjso
// ListAllTransactions returns a slice of objects with details about a recorded
// transaction. This is intended to be used for listalltransactions RPC
// replies.
func (w *Wallet) ListAllTransactions() ([]btcjson.ListTransactionsResult, error) {
func (w *Wallet) ListAllTransactions(accountName string) ([]btcjson.ListTransactionsResult, error) {
txList := []btcjson.ListTransactionsResult{}
err := walletdb.View(w.db, func(tx walletdb.ReadTx) error {
txmgrNs := tx.ReadBucket(wtxmgrNamespaceKey)
@ -2187,7 +2187,8 @@ func (w *Wallet) ListAllTransactions() ([]btcjson.ListTransactionsResult, error)
// unsorted, but it will process mined transactions in the
// reverse order they were marked mined.
for i := len(details) - 1; i >= 0; i-- {
jsonResults := listTransactions(tx, &details[i], w.Manager,
jsonResults := listTransactions(accountName,
tx, &details[i], w.Manager,
syncBlock.Height, w.chainParams)
txList = append(txList, jsonResults...)
}