Add new RPC “lockunspent”, to prevent spending of selected outputs #1861

pull jgarzik wants to merge 1 commits into bitcoin:master from jgarzik:coinlock changing 5 files +125 −3
  1. jgarzik commented at 7:03 am on September 24, 2012: contributor

    This is a memory-only filter, which must be applied at bitcoind startup.

    It might be nice to store this in the wallet, but to judge interest and review the interface, this is a useful first step.

  2. in src/rpcwallet.cpp: in 6c5b4dc30d outdated
    1477+            pwalletMain->UnlockAllCoins();
    1478+        return true;
    1479+    }
    1480+
    1481+    if (params[1].type() != array_type)
    1482+        throw JSONRPCError(-8, "Invalid parameter 1, not array");
    


    luke-jr commented at 7:27 am on September 24, 2012:
    It might be nice to accept a String address or txid to allow simpler locks (lock all to address, or all output from txid).
  3. in src/rpcwallet.cpp: in 6c5b4dc30d outdated
    1503+        COutPoint outpt(uint256(txid), nOutput);
    1504+
    1505+        if (fUnlock)
    1506+            pwalletMain->UnlockCoin(outpt);
    1507+        else
    1508+            pwalletMain->LockCoin(outpt);
    


    luke-jr commented at 7:28 am on September 24, 2012:
    Wouldn’t it make more sense to add a boolean/methods to COutPoint?

    sipa commented at 2:12 pm on September 28, 2012:
    No please… outpoints shouldn’t know whether they are part of some wallet structure!

    jgarzik commented at 0:10 am on September 29, 2012:

    @sipa RPC “listunspent” already works on the wallet structure, thus “lockunspent” works with the information found in “listunspent”

    Making “lockunspent” work globally, even for ‘sendrawtransactions’ coins not in the wallet is doable, but it creates a disconnect between the dataset manipulated by “listunspent” and the one manipulated by “lockunspent”.

    Is that disconnect acceptable?


    sipa commented at 1:56 pm on October 7, 2012:

    @jgarzik I’m only replying to Luke’s suggestion to have the locking functionality inside COutPoint. That would be a bad idea.

    No objection to having a method on a wallet to lock a certain output.

  4. jgarzik commented at 7:46 am on September 24, 2012: contributor
    lockunspent does the minimum necessary to accomplish the use case at hand (protecting smartcoins from being spent), but I’m open to other opinions, if people see other uses.
  5. BitcoinPullTester commented at 6:35 pm on September 24, 2012: none
    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/6c5b4dc30d2b9538cc154750d96efa1849eb42eb for binaries and test log.
  6. in src/rpcwallet.cpp: in 6c5b4dc30d outdated
    1485+    BOOST_FOREACH(Value& output, outputs)
    1486+    {
    1487+        const Object& o = output.get_obj();
    1488+
    1489+        const Value& txid_v = find_value(o, "txid");
    1490+        if (txid_v.type() != str_type)
    


    gavinandresen commented at 8:31 pm on September 24, 2012:

    I wrote a RPCTypeCheck(object,…) method for the raw transactions API that would save you a few lines of code and should give slightly nicer error messages.

    Would be: RPCTypeCheck(o, boost::assign::map_list_of(“txid”, str_type)(“vout”, int_type));

  7. gavinandresen commented at 8:35 pm on September 24, 2012: contributor
    I like the simplicity; I vote for a listlockunspent to get the current list of locked inputs, which should at the very least be handy when debugging.
  8. xblitz commented at 7:10 pm on September 25, 2012: none
    I would rather prefer that listunspent to have an option to filter which one we want ( locked || unlocked || locked && unlocked ) .. and both would be the default instead of having adding new rpc calls
  9. jgarzik commented at 7:18 pm on September 25, 2012: contributor

    More, simple RPC calls are preferred over making existing RPC calls ever more complicated.

    “listunspent” displays the coins available for spending… let’s not make it more complicated than that.

  10. jgarzik commented at 0:56 am on September 27, 2012: contributor
    Updated to add RPC “listlockunspent”, and to use RPCTypeCheck()
  11. xblitz commented at 1:06 pm on September 27, 2012: none
    would it be more proper for the command to be called “listlockedunspent” ?
  12. in src/rpcwallet.cpp: in 67e7021f31 outdated
    1530+    BOOST_FOREACH(COutPoint &outpt, vOutpts) {
    1531+        Object o;
    1532+
    1533+        o.push_back(Pair("txid", outpt.hash.GetHex()));
    1534+        o.push_back(Pair("vout", (int)outpt.n));
    1535+    }
    


    xblitz commented at 2:09 pm on September 27, 2012:
    was this tested? maybe this could work if we ret.push_back(o) … but it still doesnt show locked unspent outputs
  13. BitcoinPullTester commented at 3:22 pm on September 27, 2012: none
    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/67e7021f3183bfeee047f5879cbd04ff974c3f3c for binaries and test log.
  14. BitcoinPullTester commented at 3:53 am on September 28, 2012: none
    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/029e4952f6351b91efdd8dfef1d2335860575e9d for binaries and test log.
  15. gmaxwell commented at 11:45 pm on October 20, 2012: contributor
    Needs rebase
  16. BitcoinPullTester commented at 5:06 am on October 21, 2012: none
    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/ab76dd1a08f2fa524db9c0cdc02a51f0ad77ead8 for binaries and test log.
  17. Add new RPC "lockunspent", to prevent spending of selected outputs
    and associated RPC "listlockunspent".
    
    This is a memory-only filter, which is empty when a node restarts.
    fdbb537d26
  18. jgarzik commented at 2:32 am on November 16, 2012: contributor
    rebased
  19. BitcoinPullTester commented at 9:41 pm on November 23, 2012: none
    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/fdbb537d263497529c8f9deb0bb98371530839c3 for binaries and test log.
  20. gavinandresen commented at 0:16 am on December 1, 2012: contributor
    ACK
  21. gavinandresen referenced this in commit 78504bb04f on Dec 12, 2012
  22. gavinandresen merged this on Dec 12, 2012
  23. gavinandresen closed this on Dec 12, 2012

  24. laudney referenced this in commit cc1e810e81 on Mar 19, 2014
  25. jgarzik deleted the branch on Aug 24, 2014
  26. KolbyML referenced this in commit 8f37bcccc3 on Dec 5, 2020
  27. KolbyML referenced this in commit 70c1fd1981 on Dec 5, 2020
  28. 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: 2024-12-26 06:12 UTC

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