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.
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.
1477 | + pwalletMain->UnlockAllCoins(); 1478 | + return true; 1479 | + } 1480 | + 1481 | + if (params[1].type() != array_type) 1482 | + throw JSONRPCError(-8, "Invalid parameter 1, not array");
It might be nice to accept a String address or txid to allow simpler locks (lock all to address, or all output from txid).
1503 | + COutPoint outpt(uint256(txid), nOutput); 1504 | + 1505 | + if (fUnlock) 1506 | + pwalletMain->UnlockCoin(outpt); 1507 | + else 1508 | + pwalletMain->LockCoin(outpt);
Wouldn't it make more sense to add a boolean/methods to COutPoint?
No please... outpoints shouldn't know whether they are part of some wallet structure!
@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?
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.
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/6c5b4dc30d2b9538cc154750d96efa1849eb42eb for binaries and test log.
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)
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));
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.
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
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.
Updated to add RPC "listlockunspent", and to use RPCTypeCheck()
would it be more proper for the command to be called "listlockedunspent" ?
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 | + }
was this tested? maybe this could work if we ret.push_back(o) ... but it still doesnt show locked unspent outputs
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/67e7021f3183bfeee047f5879cbd04ff974c3f3c for binaries and test log.
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/029e4952f6351b91efdd8dfef1d2335860575e9d for binaries and test log.
Needs rebase
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/ab76dd1a08f2fa524db9c0cdc02a51f0ad77ead8 for binaries and test log.
and associated RPC "listlockunspent".
This is a memory-only filter, which is empty when a node restarts.
rebased
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/fdbb537d263497529c8f9deb0bb98371530839c3 for binaries and test log.
ACK
Milestone
0.8.0