Skip to content

Commit

Permalink
[rpc]: update sendall RPC to return the resulting tx weight
Browse files Browse the repository at this point in the history
  • Loading branch information
ismaelsadeeq committed Jun 25, 2024
1 parent 6fe8d28 commit b3ac117
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/wallet/rpc/spend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,7 @@ RPCHelpMan sendall()
RPCResult::Type::OBJ, "", "",
{
{RPCResult::Type::BOOL, "complete", "If the transaction has a complete set of signatures"},
{RPCResult::Type::NUM, "weight", "The resulting transaction weight in weight units"},
{RPCResult::Type::STR_HEX, "txid", /*optional=*/true, "The transaction id for the send. Only 1 transaction is created regardless of the number of addresses."},
{RPCResult::Type::STR_HEX, "hex", /*optional=*/true, "If add_to_wallet is false, the hex-encoded raw transaction with signature(s)"},
{RPCResult::Type::STR, "psbt", /*optional=*/true, "If more signatures are needed, or if add_to_wallet is false, the base64-encoded (partially) signed transaction"}
Expand Down Expand Up @@ -1564,8 +1565,9 @@ RPCHelpMan sendall()
pwallet->LockCoin(txin.prevout);
}
}

return FinishTransaction(pwallet, options, rawTx);
auto result = FinishTransaction(pwallet, options, rawTx);
result.pushKV("weight", tx_size.weight);
return result;
}
};
}
Expand Down
1 change: 1 addition & 0 deletions test/functional/wallet_sendall.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def test_sendall_success(self, sendall_args, remaining_balance = 0):
assert_equal(remaining_balance, self.wallet.getbalances()["mine"]["trusted"])

assert_equal(sendall_tx_receipt["complete"], True)
assert_greater_than(sendall_tx_receipt["weight"], 0)
return self.wallet.gettransaction(txid = sendall_tx_receipt["txid"], verbose = True)

@cleanup
Expand Down

0 comments on commit b3ac117

Please sign in to comment.