transactions are being created with a 0 locktime but the intention is to use a locktime that is near the current block to prevent fee sniping
0 locktime issue #10990
pull gandrewstone wants to merge 1 commits into bitcoin:master from gandrewstone:fix0locktimebug changing 2 files +34 −1-
gandrewstone commented at 10:08 PM on August 4, 2017: none
-
transactions are being created with a 0 locktime but the intention is to use a locktime that is near the current block to prevent fee sniping 351205ba3b
-
in src/wallet/wallet.cpp:2542 in 351205ba3b
2536 | @@ -2537,7 +2537,9 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC 2537 | } 2538 | } 2539 | 2540 | - 2541 | + // If the transaction has not provided a locktime, let's use the default locktime chosen in CreateTransaction 2542 | + // so that the miner fee sniping prevention implemented there works 2543 | + if (tx.nLockTime == 0) tx.nLockTime = wtx.tx->nLockTime;
promag commented at 10:53 PM on August 4, 2017:Nit, newline after.
in test/functional/fundrawtransaction.py:113 in 351205ba3b
108 | + fee = rawtxfund['fee'] 109 | + dec_tx = self.nodes[2].decoderawtransaction(rawtxfund['hex']) 110 | + if dec_tx["locktime"] == blockcount: 111 | + break 112 | + assert(dec_tx["locktime"] > 0) 113 | + assert(i<18) # incrediably unlikely to never produce the current blockcount
promag commented at 10:53 PM on August 4, 2017:Nit,
i < 18(add spaces).in test/functional/fundrawtransaction.py:106 in 351205ba3b
101 | + outputs = { self.nodes[0].getnewaddress() : 1.0 } 102 | + rawtx = self.nodes[2].createrawtransaction(inputs, outputs) 103 | + dec_tx = self.nodes[2].decoderawtransaction(rawtx) 104 | + 105 | + # there's a random chance of an earlier locktime so iterate a few times 106 | + for i in range(0,20):
promag commented at 10:54 PM on August 4, 2017:Nit,
(0, 20)(add space).in test/functional/fundrawtransaction.py:89 in 351205ba3b
80 | @@ -81,6 +81,37 @@ def run_test(self): 81 | dec_tx = self.nodes[2].decoderawtransaction(rawtxfund['hex']) 82 | assert(len(dec_tx['vin']) > 0) #test that we have enough inputs 83 | 84 | + ############################# 85 | + # test preserving nLockTime # 86 | + ############################# 87 | + inputs = [ ] 88 | + outputs = { self.nodes[0].getnewaddress() : 1.0 } 89 | + rawtx = self.nodes[2].createrawtransaction(inputs, outputs,1234)
promag commented at 10:54 PM on August 4, 2017:Nit,
, 1234(add space).promag commented at 10:56 PM on August 4, 2017: memberNit, improve commit message as it is too long.
achow101 commented at 11:39 PM on August 4, 2017: memberNACK
The nature of the raw transaction RPCs is that the user is given absolute control over what the transaction will be. We shouldn't be doing anything for the user automatically unless they explicitly asked for that to happen.
fanquake added the label Wallet on Aug 5, 2017gandrewstone commented at 1:59 PM on August 5, 2017: none@achow101 you'd want the nLockTime value to inform the nSequence then...
achow101 commented at 6:32 PM on August 5, 2017: member@gandrewstone Yes, so?
gandrewstone commented at 2:27 PM on August 6, 2017: noneso its not. Pick this PR or make another... it took me 5 minutes to point this very small issue out but that's all the time I'm inclined to spend on it.
achow101 commented at 5:14 PM on August 6, 2017: member@gandrewstone Your PR does not do that. Your PR is not making the "nLockTime value to inform the nSequence". You don't even touch the nSequence., I agree that nLockTime should inform and partially dictate what the nSequence is going to be, but your PR doesn't do that. It just puts a lock time on transactions when they use
fundrawtransactionand we don't want that to happen as it is doing something which the user did not tell it to do and that defeats the purpose of the raw transaction RPCs.jnewbery commented at 9:43 PM on August 15, 2017: member@gandrewstone thanks for your contribution. As @achow101 says, the
_rawtransactionRPCs are tools for advanced users andfundrawtransactionshouldn't be changing the locktime value unexpectedly under the user's feet.I'm happy to review any future PR where nLockTime informs the nSequence value, but I'm also a NACK for this PR.
jonasschnelli commented at 3:14 PM on August 18, 2017: contributorlaanwj commented at 1:39 PM on October 4, 2017: memberOk, agreement seems to close this.
laanwj closed this on Oct 4, 2017DrahtBot locked this on Sep 8, 2021Labels
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-15 15:15 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me