Skip to content

Commit 9e0533b

Browse files
committed
Merge 14641 via fundraw_min_conf_deprecated-25+knots
2 parents dd9a275 + a16d151 commit 9e0533b

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/wallet/rpc/spend.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ CreatedTransactionResult FundTransaction(CWallet& wallet, const CMutableTransact
630630
{"subtract_fee_from_outputs", UniValueType(UniValue::VARR)},
631631
{"replaceable", UniValueType(UniValue::VBOOL)},
632632
{"conf_target", UniValueType(UniValue::VNUM)},
633+
{"min_conf", UniValueType(UniValue::VNUM)},
633634
{"estimate_mode", UniValueType(UniValue::VSTR)},
634635
{"minconf", UniValueType(UniValue::VNUM)},
635636
{"maxconf", UniValueType(UniValue::VNUM)},
@@ -713,6 +714,17 @@ CreatedTransactionResult FundTransaction(CWallet& wallet, const CMutableTransact
713714
throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative minconf");
714715
}
715716
}
717+
if (options.exists("min_conf")) {
718+
if (options.exists("minconf")) {
719+
throw JSONRPCError(RPC_INVALID_PARAMETER, "min_conf and minconf options should not both be set. Use minconf (min_conf is deprecated).");
720+
}
721+
722+
coinControl.m_min_depth = options["min_conf"].getInt<int>();
723+
724+
if (coinControl.m_min_depth < 0) {
725+
throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative min_conf");
726+
}
727+
}
716728

717729
if (options.exists("maxconf")) {
718730
coinControl.m_max_depth = options["maxconf"].getInt<int>();

test/functional/rpc_psbt.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ def run_test(self):
260260
assert_raises_rpc_error(-22, f"Previous tx has too few outputs for PSBT input {parent_txid}", self.nodes[0].utxoupdatepsbt, psbt=psbtx_bad_child, prevtxs=prev_txs)
261261

262262
# Create and fund a raw tx for sending 10 BTC
263-
psbtx1 = self.nodes[0].walletcreatefundedpsbt([], {self.nodes[2].getnewaddress():10})['psbt']
263+
assert_raises_rpc_error(-4, "Insufficient funds", self.nodes[0].walletcreatefundedpsbt, inputs=[], outputs={self.nodes[2].getnewaddress():1}, options={'min_conf': 201})
264+
psbtx1 = self.nodes[0].walletcreatefundedpsbt(inputs=[], outputs={self.nodes[2].getnewaddress():11}, options={'min_conf': 200})['psbt']
264265

265266
self.log.info("Test for invalid maximum transaction weights")
266267
dest_arg = [{self.nodes[0].getnewaddress(): 1}]

test/functional/wallet_fundrawtransaction.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,16 @@ def test_option_subtract_fee_from_outputs(self):
10421042
# The total subtracted from the outputs is equal to the fee.
10431043
assert_equal(share[0] + share[2] + share[3], result[0]['fee'])
10441044

1045+
# test funding with custom min_conf
1046+
inputs = []
1047+
outputs = {self.nodes[2].getnewaddress(): 1}
1048+
rawtx = self.nodes[3].createrawtransaction(inputs, outputs)
1049+
unspent = self.nodes[3].listunspent()
1050+
assert len(unspent) == 1
1051+
input_confs = unspent[0]['confirmations']
1052+
assert_raises_rpc_error(-4, "Insufficient funds", self.nodes[3].fundrawtransaction, rawtx, {'min_conf': input_confs + 1})
1053+
result = self.nodes[3].fundrawtransaction(rawtx, {'min_conf': input_confs})
1054+
10451055
def test_subtract_fee_with_presets(self):
10461056
self.log.info("Test fundrawtxn subtract fee from outputs with preset inputs that are sufficient")
10471057

0 commit comments

Comments
 (0)