multi-account: update sendmany

This commit is contained in:
Roy Lee 2022-08-22 14:25:49 -07:00
parent 43bbf0a089
commit af2d35a604

View file

@ -1649,6 +1649,7 @@ func sendFrom(icmd interface{}, w *wallet.Wallet, chainClient *chain.RPCClient)
// or a fee for the miner are sent back to a new address in the wallet.
// Upon success, the TxID for the created transaction is returned.
func sendMany(icmd interface{}, w *wallet.Wallet) (interface{}, error) {
cmd := icmd.(*btcjson.SendManyCmd)
// Transaction comments are not yet supported. Error instead of
@ -1660,7 +1661,7 @@ func sendMany(icmd interface{}, w *wallet.Wallet) (interface{}, error) {
}
}
account, err := w.AccountNumber(waddrmgr.KeyScopeBIP0044, cmd.FromAccount)
account, err := w.AccountNumber(cmd.FromAccount)
if err != nil {
return nil, err
}
@ -1671,6 +1672,12 @@ func sendMany(icmd interface{}, w *wallet.Wallet) (interface{}, error) {
return nil, ErrNeedPositiveMinconf
}
// Use specified scope, if provided.
scope, err := lookupKeyScope(cmd.AddressType)
if err != nil {
return nil, err
}
// Recreate address/amount pairs, using dcrutil.Amount.
pairs := make(map[string]btcutil.Amount, len(cmd.Amounts))
for k, v := range cmd.Amounts {
@ -1681,7 +1688,7 @@ func sendMany(icmd interface{}, w *wallet.Wallet) (interface{}, error) {
pairs[k] = amt
}
return sendPairs(w, pairs, waddrmgr.KeyScopeBIP0044, account, minConf, txrules.DefaultRelayFeePerKb)
return sendPairs(w, pairs, scope, account, minConf, txrules.DefaultRelayFeePerKb)
}
// sendToAddress handles a sendtoaddress RPC request by creating a new