fix(send): pass the z_sendmany fee as a number, not a string
A prior change passed the user-selected fee to z_sendmany as a fixed-decimal string (mirroring the recipient amount). But the daemon reads the fee param with UniValue::get_real(), which rejects a string with "JSON value is not a number as expected" — breaking every z_sendmany send (surfaced via the address-to-address transfer feature). Pass the raw double instead. get_real() parses it directly and accepts any number notation (including the "5e-05" form of a small fee), so this is correct for all fee values. The recipient "amount" stays a fixed-decimal string on purpose — that field is parsed with ParseFixedPoint, which a scientific-notation double would break. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -2300,16 +2300,18 @@ void App::sendTransaction(const std::string& from, const std::string& to,
|
|||||||
|
|
||||||
send_progress_active_ = true;
|
send_progress_active_ = true;
|
||||||
++send_submissions_in_flight_;
|
++send_submissions_in_flight_;
|
||||||
// z_sendmany signature is (fromaddress, amounts, minconf, fee). Pass the user-selected
|
// z_sendmany signature is (fromaddress, amounts, minconf, fee). The fee MUST be a JSON number:
|
||||||
// fee explicitly — formatted as a fixed-decimal string so the daemon's ParseFixedPoint
|
// the daemon reads it with get_real(), so a string is rejected ("JSON value is not a number as
|
||||||
// accepts it (a small double like 0.00005 would serialize to "5e-05" and be rejected).
|
// expected"). get_real() parses the double directly and accepts any number notation (incl. the
|
||||||
const std::string fee_str = util::formatAmountFixed(fee);
|
// "5e-05" form of a small fee), so passing the raw double is correct for every fee value.
|
||||||
worker_->post([this, from, to, amount, fee_str, memo, recipients, callback]() -> rpc::RPCWorker::MainCb {
|
// (The recipient "amount" above is intentionally a fixed-decimal STRING — that field is parsed
|
||||||
|
// with ParseFixedPoint, which a scientific-notation double would break.)
|
||||||
|
worker_->post([this, from, to, amount, fee, memo, recipients, callback]() -> rpc::RPCWorker::MainCb {
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
std::string result_str;
|
std::string result_str;
|
||||||
try {
|
try {
|
||||||
rpc::RPCClient::TraceScope trace("Send tab / Submit transaction");
|
rpc::RPCClient::TraceScope trace("Send tab / Submit transaction");
|
||||||
auto result = rpc_->call("z_sendmany", {from, recipients, 1, fee_str});
|
auto result = rpc_->call("z_sendmany", {from, recipients, 1, fee});
|
||||||
result_str = result.get<std::string>();
|
result_str = result.get<std::string>();
|
||||||
ok = true;
|
ok = true;
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user