multi-account: update listaddresstransactions
This commit is contained in:
parent
51e700e7d9
commit
50950fb0d5
2 changed files with 5 additions and 11 deletions
|
@ -1501,13 +1501,6 @@ func listTransactions(icmd interface{}, w *wallet.Wallet) (interface{}, error) {
|
||||||
func listAddressTransactions(icmd interface{}, w *wallet.Wallet) (interface{}, error) {
|
func listAddressTransactions(icmd interface{}, w *wallet.Wallet) (interface{}, error) {
|
||||||
cmd := icmd.(*btcjson.ListAddressTransactionsCmd)
|
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.
|
// Decode addresses.
|
||||||
hash160Map := make(map[string]struct{})
|
hash160Map := make(map[string]struct{})
|
||||||
for _, addrStr := range cmd.Addresses {
|
for _, addrStr := range cmd.Addresses {
|
||||||
|
@ -1518,7 +1511,7 @@ func listAddressTransactions(icmd interface{}, w *wallet.Wallet) (interface{}, e
|
||||||
hash160Map[string(addr.ScriptAddress())] = struct{}{}
|
hash160Map[string(addr.ScriptAddress())] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
return w.ListAddressTransactions(hash160Map)
|
return w.ListAddressTransactions(*cmd.Account, hash160Map)
|
||||||
}
|
}
|
||||||
|
|
||||||
// listAllTransactions handles a listalltransactions request by returning
|
// listAllTransactions handles a listalltransactions request by returning
|
||||||
|
|
|
@ -2126,7 +2126,7 @@ func (w *Wallet) ListTransactions(accountName string, from, count int) ([]btcjso
|
||||||
// ListAddressTransactions returns a slice of objects with details about
|
// ListAddressTransactions returns a slice of objects with details about
|
||||||
// recorded transactions to or from any address belonging to a set. This is
|
// recorded transactions to or from any address belonging to a set. This is
|
||||||
// intended to be used for listaddresstransactions RPC replies.
|
// 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{}
|
txList := []btcjson.ListTransactionsResult{}
|
||||||
err := walletdb.View(w.db, func(tx walletdb.ReadTx) error {
|
err := walletdb.View(w.db, func(tx walletdb.ReadTx) error {
|
||||||
txmgrNs := tx.ReadBucket(wtxmgrNamespaceKey)
|
txmgrNs := tx.ReadBucket(wtxmgrNamespaceKey)
|
||||||
|
@ -2155,8 +2155,9 @@ func (w *Wallet) ListAddressTransactions(pkHashes map[string]struct{}) ([]btcjso
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonResults := listTransactions(tx, detail,
|
jsonResults := listTransactions(accountName,
|
||||||
w.Manager, syncBlock.Height, w.chainParams)
|
tx, detail, w.Manager,
|
||||||
|
syncBlock.Height, w.chainParams)
|
||||||
txList = append(txList, jsonResults...)
|
txList = append(txList, jsonResults...)
|
||||||
continue loopDetails
|
continue loopDetails
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue