wallet: Fix origfee return for bumpfee with feerate arg #17643

pull instagibbs wants to merge 1 commits into bitcoin:master from instagibbs:bf_expl_fix changing 2 files +6 −4
  1. instagibbs commented at 2:48 PM on December 1, 2019: member

    fixes #17642 and adds a simple test that would have caught it

  2. fanquake added the label Wallet on Dec 1, 2019
  3. fanquake added the label Needs backport (0.19) on Dec 1, 2019
  4. DrahtBot commented at 5:42 PM on December 1, 2019: member

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #17566 (Switch to weight units for all feerates computation by darosior)
    • #16373 (bumpfee: Return PSBT when wallet has privkeys disabled by instagibbs)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  5. in src/wallet/feebumper.cpp:111 in a0655adcdb outdated
     107 | @@ -108,12 +108,11 @@ static feebumper::Result CheckFeeRate(const CWallet& wallet, const CWalletTx& wt
     108 |      return feebumper::Result::OK;
     109 |  }
     110 |  
     111 | -static CFeeRate EstimateFeeRate(const CWallet& wallet, const CWalletTx& wtx, CCoinControl& coin_control, CAmount& old_fee)
     112 | +static CFeeRate EstimateFeeRate(const CWallet& wallet, const CWalletTx& wtx, CCoinControl& coin_control, CAmount old_fee)
    


    darosior commented at 9:30 PM on December 1, 2019:

    Could be const, I think ?


    instagibbs commented at 1:56 AM on December 2, 2019:

    done, and re-ordered the arguments to be all const then non-const.

  6. darosior approved
  7. darosior commented at 9:40 PM on December 1, 2019: member

    ACK a0655adcdb31c36155585f0014afd86998b28fab

  8. practicalswift commented at 9:50 PM on December 1, 2019: contributor

    @instagibbs

    Thanks for tackling this quickly.

    I'm not too familiar with this part of the code: is there any scenario where the wrong fee could have been selected due to the uninitialized read? What is the likely user impact?

  9. instagibbs commented at 10:57 PM on December 1, 2019: member

    No it's simply a reporting issue.

    On Sun, Dec 1, 2019, 4:51 PM practicalswift notifications@github.com wrote:

    @instagibbs https://github.com/instagibbs

    Thanks for tackling this quickly.

    I'm not too familiar with this part of the code: is there any scenario where the wrong fee could have been selected due to the uninitialized read?

    — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bitcoin/bitcoin/pull/17643?email_source=notifications&email_token=ABMAFUYWFWI3Y4YRACOKHYDQWQWUJA5CNFSM4JTMA4CKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFRWY4Y#issuecomment-560163955, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMAFU6LGFOFK724EYW4DG3QWQWUJANCNFSM4JTMA4CA .

  10. fanquake requested review from achow101 on Dec 1, 2019
  11. Fix origfee return for bumpfee with feerate arg 02afb0c550
  12. instagibbs force-pushed on Dec 2, 2019
  13. practicalswift commented at 7:16 AM on December 2, 2019: contributor

    A demo of the unitialized read (prior to the fix):

    $ test/functional/uninitialized_orig_fee.py -l WARNING
    origfee: 1401472.87914520
    $ test/functional/uninitialized_orig_fee.py -l WARNING
    origfee: 1400508.05266608
    $ test/functional/uninitialized_orig_fee.py -l WARNING
    origfee: 1404964.24912920
    $ test/functional/uninitialized_orig_fee.py -l WARNING
    origfee: 1E-8
    $ test/functional/uninitialized_orig_fee.py -l WARNING
    origfee: 1398604.42601496
    

    Code:

    #!/usr/bin/env python3
    
    from decimal import Decimal
    
    from test_framework.messages import BIP125_SEQUENCE_NUMBER
    from test_framework.test_framework import BitcoinTestFramework
    from test_framework.util import connect_nodes
    
    MIN_RELAY_FEE = Decimal("0.00000141")
    FEE_RATE = 0.0015
    
    SEND_AMOUNT_1 = Decimal("49")
    SEND_AMOUNT_2 = Decimal("48")
    
    
    class UninitializedOrigFeeTest(BitcoinTestFramework):
        def set_test_params(self):
            self.num_nodes = 2
            self.setup_clean_chain = True
            self.extra_args = [
                ["-walletrbf={}".format(i), "-mintxfee=0.00002", "-addresstype=bech32"]
                for i in range(self.num_nodes)
            ]
    
        def run_test(self):
            connect_nodes(self.nodes[0], 1)
            self.sync_all()
            peer_node, rbf_node = self.nodes
            rbf_node_address = rbf_node.getnewaddress()
            peer_node.generate(101)
            self.sync_all()
            peer_node.sendtoaddress(rbf_node_address, SEND_AMOUNT_1)
            self.sync_all()
            peer_node.generate(1)
            self.sync_all()
            dest_address = peer_node.getnewaddress()
            tx_input = dict(
                sequence=BIP125_SEQUENCE_NUMBER,
                **next(u for u in rbf_node.listunspent() if u["amount"] == SEND_AMOUNT_1)
            )
            destinations = {dest_address: SEND_AMOUNT_2}
            destinations[rbf_node.getrawchangeaddress()] = (
                SEND_AMOUNT_1 - SEND_AMOUNT_2 - MIN_RELAY_FEE
            )
            rawtx = rbf_node.createrawtransaction([tx_input], destinations)
            signedtx = rbf_node.signrawtransactionwithwallet(rawtx)
            rbfid = rbf_node.sendrawtransaction(signedtx["hex"])
            self.sync_mempools((rbf_node, peer_node))
            bumped_tx = rbf_node.bumpfee(rbfid, {"fee_rate": FEE_RATE})
            print("origfee: {}".format(bumped_tx["origfee"]))
    
    
    if __name__ == "__main__":
        UninitializedOrigFeeTest().main()
    
  14. practicalswift commented at 7:22 AM on December 2, 2019: contributor

    With the patch in this PR applied:

    $ test/functional/uninitialized_orig_fee.py -l WARNING
    origfee: 0.00000141
    $ test/functional/uninitialized_orig_fee.py -l WARNING
    origfee: 0.00000141
    $ test/functional/uninitialized_orig_fee.py -l WARNING
    origfee: 0.00000141
    $ test/functional/uninitialized_orig_fee.py -l WARNING
    origfee: 0.00000141
    $ test/functional/uninitialized_orig_fee.py -l WARNING
    origfee: 0.00000141
    
  15. achow101 approved
  16. achow101 commented at 2:32 PM on December 2, 2019: member

    ACK 02afb0c550dc8529918460c845d1da3adf236eed

  17. MarcoFalke renamed this:
    Fix origfee return for bumpfee with feerate arg
    wallet: Fix origfee return for bumpfee with feerate arg
    on Dec 3, 2019
  18. MarcoFalke commented at 3:27 PM on December 3, 2019: member

    ACK. Tested by running the test without re-compiling bitcoind

  19. MarcoFalke referenced this in commit 2b6575d989 on Dec 3, 2019
  20. MarcoFalke merged this on Dec 3, 2019
  21. MarcoFalke closed this on Dec 3, 2019

  22. sidhujag referenced this in commit 31d5982ab8 on Dec 3, 2019
  23. luke-jr referenced this in commit bd8c6f12e8 on Jan 3, 2020
  24. fanquake referenced this in commit 310b29f9c3 on Jan 4, 2020
  25. fanquake removed the label Needs backport (0.19) on Jan 6, 2020
  26. fanquake commented at 12:00 AM on January 6, 2020: member

    Was backported in #17859.

  27. barrystyle referenced this in commit fd725a9a1b on Feb 29, 2020
  28. MarkLTZ referenced this in commit 2e6abb1507 on Mar 13, 2020
  29. MarkLTZ referenced this in commit ece88bae51 on Mar 13, 2020
  30. sidhujag referenced this in commit 3145dc4369 on Nov 10, 2020
  31. DrahtBot locked this on Feb 15, 2022

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-13 18:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me