Fix unlocking of an already spent output #12739

pull pedrobranco wants to merge 1 commits into bitcoin:master from uphold:bugfix/fix-lockunspent-deadlock changing 2 files +13 −3
  1. pedrobranco commented at 6:53 PM on March 20, 2018: contributor

    Fixes #12738.

  2. promag commented at 6:57 PM on March 20, 2018: member

    IMO when the UTXO is spent it should be considered unlocked no?

  3. pedrobranco commented at 7:11 PM on March 20, 2018: contributor

    IMO when the UTXO is spent it should be considered unlocked no?

    Agree. Unlocking the unspent when relaying the transaction that spends it is preferable, but is a different scope of this PR since that approach is a breaking change.

  4. promag commented at 9:50 PM on March 20, 2018: member

    Not sure what you mean with breaking change.

  5. fanquake added the label Wallet on Mar 20, 2018
  6. in test/functional/wallet_basic.py:162 in 972d56970a outdated
     157 | @@ -158,6 +158,9 @@ def run_test(self):
     158 |          spent_0 = {"txid": node0utxos[0]["txid"], "vout": node0utxos[0]["vout"]}
     159 |          assert_raises_rpc_error(-8, "Invalid parameter, expected unspent output", self.nodes[0].lockunspent, False, [spent_0])
     160 |  
     161 | +        # Verify that a spent output can be unlocked
     162 | +        assert_equal(self.nodes[0].lockunspent, True, [spent_0], True)
    


    Empact commented at 7:52 AM on March 21, 2018:

    Seems like this is an improper use of assert_equal - basically it's meant to be use with arg1 == all other args, so the two Trues are redundant or mistaken.

    https://github.com/bitcoin/bitcoin/blob/master/test/functional/test_framework/util.py#L36

  7. pedrobranco force-pushed on Mar 21, 2018
  8. pedrobranco commented at 10:40 AM on March 21, 2018: contributor

    Not sure what you mean with breaking change.

    If we unlock the output when sending the raw transaction, calling lockunspent true <unspents> will fail because they are already unlocked. It is not a breaking change for bitcoind, but for the ones that uses the same flow as the example here.

  9. pedrobranco force-pushed on Mar 21, 2018
  10. Fix lockunspent deadlock when unlocking already spent outputs b64bf76c71
  11. pedrobranco force-pushed on Mar 21, 2018
  12. luke-jr commented at 4:54 PM on June 12, 2018: member

    lockunspent probably should throw an error if the referenced TXOs aren't unspent...

  13. laanwj commented at 4:53 PM on June 24, 2018: member

    Closing because #13160 was merged.

  14. laanwj closed this on Jun 24, 2018

  15. MarcoFalke 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-13 15:15 UTC

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