mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-29 13:32:33 +02:00
Merge 14641 via fundraw_min_conf_deprecated-25+knots
This commit is contained in:
commit
526d26b79b
@ -623,6 +623,7 @@ CreatedTransactionResult FundTransaction(CWallet& wallet, const CMutableTransact
|
|||||||
{"subtract_fee_from_outputs", UniValueType(UniValue::VARR)},
|
{"subtract_fee_from_outputs", UniValueType(UniValue::VARR)},
|
||||||
{"replaceable", UniValueType(UniValue::VBOOL)},
|
{"replaceable", UniValueType(UniValue::VBOOL)},
|
||||||
{"conf_target", UniValueType(UniValue::VNUM)},
|
{"conf_target", UniValueType(UniValue::VNUM)},
|
||||||
|
{"min_conf", UniValueType(UniValue::VNUM)},
|
||||||
{"estimate_mode", UniValueType(UniValue::VSTR)},
|
{"estimate_mode", UniValueType(UniValue::VSTR)},
|
||||||
{"minconf", UniValueType(UniValue::VNUM)},
|
{"minconf", UniValueType(UniValue::VNUM)},
|
||||||
{"maxconf", UniValueType(UniValue::VNUM)},
|
{"maxconf", UniValueType(UniValue::VNUM)},
|
||||||
@ -705,6 +706,17 @@ CreatedTransactionResult FundTransaction(CWallet& wallet, const CMutableTransact
|
|||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative minconf");
|
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")) {
|
if (options.exists("maxconf")) {
|
||||||
coinControl.m_max_depth = options["maxconf"].getInt<int>();
|
coinControl.m_max_depth = options["maxconf"].getInt<int>();
|
||||||
|
@ -207,7 +207,8 @@ class PSBTTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
# Create and fund a raw tx for sending 10 BTC
|
# 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']
|
||||||
|
|
||||||
# If inputs are specified, do not automatically add more:
|
# If inputs are specified, do not automatically add more:
|
||||||
utxo1 = self.nodes[0].listunspent()[0]
|
utxo1 = self.nodes[0].listunspent()[0]
|
||||||
|
@ -1042,6 +1042,16 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||||||
# The total subtracted from the outputs is equal to the fee.
|
# The total subtracted from the outputs is equal to the fee.
|
||||||
assert_equal(share[0] + share[2] + share[3], result[0]['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):
|
def test_subtract_fee_with_presets(self):
|
||||||
self.log.info("Test fundrawtxn subtract fee from outputs with preset inputs that are sufficient")
|
self.log.info("Test fundrawtxn subtract fee from outputs with preset inputs that are sufficient")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user