From f1ff1481811c15b1cbb566e4edea8f08f64cc80d Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Wed, 28 Aug 2019 14:52:53 +0300 Subject: [PATCH] Fix bip69 vs change position issue (#3063) * Fix bip69 vs change position issue * Drop `setbip69enabled` rpc --- src/rpc/client.cpp | 1 - src/wallet/rpcwallet.cpp | 23 ----------------------- src/wallet/wallet.cpp | 4 ++-- src/wallet/wallet.h | 1 - test/functional/fundrawtransaction.py | 6 ------ 5 files changed, 2 insertions(+), 33 deletions(-) diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index c8de1d75c0..c5179e723b 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -148,7 +148,6 @@ static const CRPCConvertParam vRPCConvertParams[] = { "prioritisetransaction", 1, "fee_delta" }, { "setban", 2, "bantime" }, { "setban", 3, "absolute" }, - { "setbip69enabled", 0, "enabled" }, { "setnetworkactive", 0, "state" }, { "setprivatesendrounds", 0, "rounds" }, { "setprivatesendamount", 0, "amount" }, diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a6fd753ccb..b8ec1b7f70 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3064,27 +3064,6 @@ UniValue fundrawtransaction(const JSONRPCRequest& request) return result; } -UniValue setbip69enabled(const JSONRPCRequest& request) -{ - CWallet* const pwallet = GetWalletForJSONRPCRequest(request); - if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) - return NullUniValue; - - if (request.fHelp || request.params.size() != 1) - throw std::runtime_error( - "setbip69enabled enable\n" - "\nEnable/Disable BIP69 input/output sorting (-regtest only)\n" - "\nArguments:\n" - "1. enable (bool, required) true or false" - ); - if (Params().NetworkIDString() != CBaseChainParams::REGTEST) - throw std::runtime_error("setbip69enabled for regression testing (-regtest mode) only"); - - bBIP69Enabled = request.params[0].get_bool(); - - return NullUniValue; -} - #if ENABLE_MINER UniValue generate(const JSONRPCRequest& request) { @@ -3208,8 +3187,6 @@ static const CRPCCommand commands[] = { "hidden", "instantsendtoaddress", &instantsendtoaddress, false, {"address","amount","comment","comment_to","subtractfeefromamount"} }, { "wallet", "dumphdinfo", &dumphdinfo, true, {} }, { "wallet", "importelectrumwallet", &importelectrumwallet, true, {"filename", "index"} }, - - { "hidden", "setbip69enabled", &setbip69enabled, true, {} }, }; void RegisterWalletRPCCommands(CRPCTable &t) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index edfaaa41d3..3c48560b02 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -50,7 +50,6 @@ std::vector vpwallets; CFeeRate payTxFee(DEFAULT_TRANSACTION_FEE); unsigned int nTxConfirmTarget = DEFAULT_TX_CONFIRM_TARGET; bool bSpendZeroConfChange = DEFAULT_SPEND_ZEROCONF_CHANGE; -bool bBIP69Enabled = true; const char * DEFAULT_WALLET_DAT = "wallet.dat"; @@ -3760,7 +3759,8 @@ bool CWallet::CreateTransaction(const std::vector& vecSend, CWalletT txNew.vin.push_back(txin); } - if (bBIP69Enabled) { + // If no specific change position was requested, apply BIP69 + if (nChangePosRequest == -1) { std::sort(txNew.vin.begin(), txNew.vin.end(), CompareInputBIP69()); std::sort(vecTxDSInTmp.begin(), vecTxDSInTmp.end(), CompareInputBIP69()); std::sort(txNew.vout.begin(), txNew.vout.end(), CompareOutputBIP69()); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 8fda8628e5..327114d5bf 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -43,7 +43,6 @@ extern std::vector vpwallets; extern CFeeRate payTxFee; extern unsigned int nTxConfirmTarget; extern bool bSpendZeroConfChange; -extern bool bBIP69Enabled; static const unsigned int DEFAULT_KEYPOOL_SIZE = 1000; //! -paytxfee default diff --git a/test/functional/fundrawtransaction.py b/test/functional/fundrawtransaction.py index 41f3f2fede..bbad3bf9d6 100755 --- a/test/functional/fundrawtransaction.py +++ b/test/functional/fundrawtransaction.py @@ -667,9 +667,6 @@ class RawTransactionsTest(BitcoinTestFramework): # Make sure there is exactly one input so coin selection can't skew the result assert_equal(len(self.nodes[3].listunspent(1)), 1) - # Disable BIP69 sorting of inputs and outputs - self.nodes[3].setbip69enabled(False) - inputs = [] outputs = {self.nodes[2].getnewaddress(): 1} rawtx = self.nodes[3].createrawtransaction(inputs, outputs) @@ -732,8 +729,5 @@ 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']) - # Reenable BIP69 sorting of inputs and outputs - self.nodes[3].setbip69enabled(True) - if __name__ == '__main__': RawTransactionsTest().main()