mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-12 19:20:42 +02:00
Merge 14641 via fundraw_min_conf_deprecated-25+knots
This commit is contained in:
commit
9e0533bb2c
@ -630,6 +630,7 @@ CreatedTransactionResult FundTransaction(CWallet& wallet, const CMutableTransact
|
||||
{"subtract_fee_from_outputs", UniValueType(UniValue::VARR)},
|
||||
{"replaceable", UniValueType(UniValue::VBOOL)},
|
||||
{"conf_target", UniValueType(UniValue::VNUM)},
|
||||
{"min_conf", UniValueType(UniValue::VNUM)},
|
||||
{"estimate_mode", UniValueType(UniValue::VSTR)},
|
||||
{"minconf", UniValueType(UniValue::VNUM)},
|
||||
{"maxconf", UniValueType(UniValue::VNUM)},
|
||||
@ -713,6 +714,17 @@ CreatedTransactionResult FundTransaction(CWallet& wallet, const CMutableTransact
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative minconf");
|
||||
}
|
||||
}
|
||||
if (options.exists("min_conf")) {
|
||||
if (options.exists("minconf")) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "min_conf and minconf options should not both be set. Use minconf (min_conf is deprecated).");
|
||||
}
|
||||
|
||||
coinControl.m_min_depth = options["min_conf"].getInt<int>();
|
||||
|
||||
if (coinControl.m_min_depth < 0) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative min_conf");
|
||||
}
|
||||
}
|
||||
|
||||
if (options.exists("maxconf")) {
|
||||
coinControl.m_max_depth = options["maxconf"].getInt<int>();
|
||||
|
@ -260,7 +260,8 @@ class PSBTTest(BitcoinTestFramework):
|
||||
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)
|
||||
|
||||
# Create and fund a raw tx for sending 10 BTC
|
||||
psbtx1 = self.nodes[0].walletcreatefundedpsbt([], {self.nodes[2].getnewaddress():10})['psbt']
|
||||
assert_raises_rpc_error(-4, "Insufficient funds", self.nodes[0].walletcreatefundedpsbt, inputs=[], outputs={self.nodes[2].getnewaddress():1}, options={'min_conf': 201})
|
||||
psbtx1 = self.nodes[0].walletcreatefundedpsbt(inputs=[], outputs={self.nodes[2].getnewaddress():11}, options={'min_conf': 200})['psbt']
|
||||
|
||||
self.log.info("Test for invalid maximum transaction weights")
|
||||
dest_arg = [{self.nodes[0].getnewaddress(): 1}]
|
||||
|
@ -1042,6 +1042,16 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||
# The total subtracted from the outputs is equal to the fee.
|
||||
assert_equal(share[0] + share[2] + share[3], result[0]['fee'])
|
||||
|
||||
# test funding with custom min_conf
|
||||
inputs = []
|
||||
outputs = {self.nodes[2].getnewaddress(): 1}
|
||||
rawtx = self.nodes[3].createrawtransaction(inputs, outputs)
|
||||
unspent = self.nodes[3].listunspent()
|
||||
assert len(unspent) == 1
|
||||
input_confs = unspent[0]['confirmations']
|
||||
assert_raises_rpc_error(-4, "Insufficient funds", self.nodes[3].fundrawtransaction, rawtx, {'min_conf': input_confs + 1})
|
||||
result = self.nodes[3].fundrawtransaction(rawtx, {'min_conf': input_confs})
|
||||
|
||||
def test_subtract_fee_with_presets(self):
|
||||
self.log.info("Test fundrawtxn subtract fee from outputs with preset inputs that are sufficient")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user