0 locktime issue #10990

pull gandrewstone wants to merge 1 commits into bitcoin:master from gandrewstone:fix0locktimebug changing 2 files +34 −1
  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

  2. 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
  3. 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.

  4. 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).

  5. 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).

  6. 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).

  7. promag commented at 10:56 PM on August 4, 2017: member

    Nit, improve commit message as it is too long.

  8. achow101 commented at 11:39 PM on August 4, 2017: member

    NACK

    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.

  9. fanquake added the label Wallet on Aug 5, 2017
  10. gandrewstone commented at 1:59 PM on August 5, 2017: none

    @achow101 you'd want the nLockTime value to inform the nSequence then...

  11. achow101 commented at 6:32 PM on August 5, 2017: member

    @gandrewstone Yes, so?

  12. gandrewstone commented at 2:27 PM on August 6, 2017: none

    so 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.

  13. 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 fundrawtransaction and 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.

  14. jnewbery commented at 9:43 PM on August 15, 2017: member

    @gandrewstone thanks for your contribution. As @achow101 says, the _rawtransaction RPCs are tools for advanced users and fundrawtransaction shouldn'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.

  15. jonasschnelli commented at 3:14 PM on August 18, 2017: contributor

    I agree with @achow101 and @jnewbery. Auto nLockTime adjustment during fundrawtransaction is not what we should do at this point. I agree a 0 value is not ideal, but changing it during a frt is not what a user would expect.

  16. laanwj commented at 1:39 PM on October 4, 2017: member

    Ok, agreement seems to close this.

  17. laanwj closed this on Oct 4, 2017

  18. DrahtBot locked this on Sep 8, 2021

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