Skip to content

Commit

Permalink
Merge ffaac6e into merged_master (Bitcoin PR #16378)
Browse files Browse the repository at this point in the history
Adds a new "send" RPC which I didn't really look at too closely to match
our other RPC modifications. In particular our backport of #17211 adds a
"solving_data" field to other transaction-creation RPCs, but not this
one. (But I checked the current status of #17211 and Andy hasn't updated
upstream either, just passes NullUniValue to FundTransaction from `send`.
So that's what I did here.)
  • Loading branch information
apoelstra committed Nov 29, 2020
2 parents 1a00b8a + ffaac6e commit 5e62edc
Show file tree
Hide file tree
Showing 8 changed files with 575 additions and 24 deletions.
5 changes: 5 additions & 0 deletions doc/release-notes-16378.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
RPC
---
- A new `send` RPC with similar syntax to `walletcreatefundedpsbt`, including
support for coin selection and a custom fee rate. Using the new `send` method
is encouraged: `sendmany` and `sendtoaddress` may be deprecated in a future release.
3 changes: 3 additions & 0 deletions src/rpc/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "gettxoutproof", 0, "txids" },
{ "lockunspent", 0, "unlock" },
{ "lockunspent", 1, "transactions" },
{ "send", 0, "outputs" },
{ "send", 1, "conf_target" },
{ "send", 3, "options" },
{ "importprivkey", 2, "rescan" },
{ "importaddress", 2, "rescan" },
{ "importaddress", 3, "p2sh" },
Expand Down
11 changes: 8 additions & 3 deletions src/rpc/rawtransaction_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,15 @@ void CreatePegInInput(CMutableTransaction& mtx, uint32_t input_idx, Sidechain::B

CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, bool rbf, const UniValue& assets_in, std::vector<CPubKey>* output_pubkeys_out, bool allow_peg_in)
{
if (inputs_in.isNull() || outputs_in.isNull())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, arguments 1 and 2 must be non-null");
if (outputs_in.isNull())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, output argument must be non-null");

UniValue inputs;
if (inputs_in.isNull())
inputs = UniValue::VARR;
else
inputs = inputs_in.get_array();

UniValue inputs = inputs_in.get_array();
const bool outputs_is_obj = outputs_in.isObject();
UniValue outputs = outputs_is_obj ? outputs_in.get_obj() : outputs_in.get_array();

Expand Down
233 changes: 213 additions & 20 deletions src/wallet/rpcwallet.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/functional/rpc_fundrawtransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def test_invalid_change_address(self):
dec_tx = self.nodes[2].decoderawtransaction(rawtx)
assert_equal(utx['txid'], dec_tx['vin'][0]['txid'])

assert_raises_rpc_error(-5, "changeAddress must be a valid address", self.nodes[2].fundrawtransaction, rawtx, {'changeAddress':'foobar'})
assert_raises_rpc_error(-5, "Change address must be a valid address", self.nodes[2].fundrawtransaction, rawtx, {'changeAddress':'foobar'})

def test_valid_change_address(self):
self.log.info("Test fundrawtxn with a provided change address")
Expand Down
3 changes: 3 additions & 0 deletions test/functional/rpc_psbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ def run_basic_tests(self, confidential):
# just make sure that we added at least one input
assert len(self.nodes[0].decodepsbt(psbtx1)['tx']['vin']) > 1

# Inputs argument can be null
self.nodes[0].walletcreatefundedpsbt(None, {self.nodes[2].getnewaddress():10})

# Node 1 should not be able to add anything to it but still return the psbtx same as before
psbtx = self.nodes[1].walletfillpsbtdata(psbtx1)['psbt']
assert_equal(psbtx1, psbtx)
Expand Down
1 change: 1 addition & 0 deletions test/functional/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@
'rpc_estimatefee.py',
'rpc_getblockstats.py',
'wallet_create_tx.py',
'wallet_send.py',
'p2p_fingerprint.py',
'feature_uacomment.py',
'wallet_coinbase_category.py',
Expand Down
341 changes: 341 additions & 0 deletions test/functional/wallet_send.py

Large diffs are not rendered by default.

0 comments on commit 5e62edc

Please sign in to comment.