Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Hans0 on February 28, 2014, 01:12:39 PM



Title: Bitcoin Qt: lockunspent broken?
Post by: Hans0 on February 28, 2014, 01:12:39 PM
In Bitcoin Qt, I tried to lock unspent outputs. My intention was to lock all but one to force a particular output to be selected for a transaction.

I understand it should work like this:

  • call lockunspent with a list of outputs
  • call listlockunspent and observe that all specified outputs are actually locked

Unfortunately, none are locked in my testing. What am I doing wrong? There was no error message. I entered the command in the debug window.

Edit: I reviewed the source code and I did not find any obvious usage errors on my part. Debugging the client is beyond my abilities, though.


Title: Re: Bitcoin Qt: lockunspent broken?
Post by: DannyHamilton on February 28, 2014, 03:42:39 PM
In Bitcoin Qt, I tried to lock unspent outputs. My intention was to lock all but one to force a particular output to be selected for a transaction.

I understand it should work like this:

  • call lockunspent with a list of outputs
  • call listlockunspent and observe that all specified outputs are actually locked

Unfortunately, none are locked in my testing. What am I doing wrong? There was no error message. I entered the command in the debug window.

Edit: I reviewed the source code and I did not find any obvious usage errors on my part. Debugging the client is beyond my abilities, though.

I haven't used it yet, but don't you need to pass a parameter of "true" when calling lockunspent?

Code:
lockunspent true [list of outputs]

Where list of outputs is in the format:

{"txid":txid,"vout":n},...


Title: Re: Bitcoin Qt: lockunspent broken?
Post by: Hans0 on February 28, 2014, 04:32:45 PM
Yes, I did this. When I initially left it out I received an error. After filling it in the error went away.


Title: Re: Bitcoin Qt: lockunspent broken?
Post by: btcseptember on March 17, 2014, 07:53:21 AM
I got this:
Code:
Error: Error parsing JSON:ture


Title: Re: Bitcoin Qt: lockunspent broken?
Post by: gmaxwell on March 17, 2014, 08:05:46 AM
Works fine here:


[gmaxwell@helmholtz tmp]$ bitcoin-cli listlockunspent
[
]
[gmaxwell@helmholtz tmp]$ bitcoin-cli lockunspent false '[{"txid":"76a914a86e8ee2a05a44613904e18132e49b2448adc4e688ac","vout":0}]'
true
[gmaxwell@helmholtz tmp]$ bitcoin-cli listlockunspent
[
    {
        "txid" : "0000000000000076a914a86e8ee2a05a44613904e18132e49b2448adc4e688ac",
        "vout" : 0
    }
]
[gmaxwell@helmholtz tmp]$ bitcoin-cli lockunspent true '[{"txid":"76a914a86e8ee2a05a44613904e18132e49b2448adc4e688ac","vout":0}]'
true
[gmaxwell@helmholtz tmp]$ bitcoin-cli listlockunspent
[
]
[gmaxwell@helmholtz tmp]$


Title: Re: Bitcoin Qt: lockunspent broken?
Post by: CIYAM on March 17, 2014, 08:14:58 AM
Rather confusing command syntax might be the problem - try a "false" rather than a "true" by the looks of it.


Title: Re: Bitcoin Qt: lockunspent broken?
Post by: Hans0 on March 17, 2014, 11:04:05 AM
Looks like I passed in true instead of false. With your example I tested it to work. Thanks!

As a feature request, it would be useful to have the ability to lock all outputs except for a given list of outputs. That would make it easy to send from a specific output bypassing the usual coin selection logic.


Title: Re: Bitcoin Qt: lockunspent broken?
Post by: jgarzik on March 17, 2014, 09:14:32 PM
As a feature request, it would be useful to have the ability to lock all outputs except for a given list of outputs. That would make it easy to send from a specific output bypassing the usual coin selection logic.

If you need to send from a specific output, easiest to use coin control or raw transaction API.


Title: Re: Bitcoin Qt: lockunspent broken?
Post by: Hans0 on March 17, 2014, 10:51:51 PM
As a feature request, it would be useful to have the ability to lock all outputs except for a given list of outputs. That would make it easy to send from a specific output bypassing the usual coin selection logic.

If you need to send from a specific output, easiest to use coin control or raw transaction API.

Googling for "coin control" it seems that this is a non-standard feature not available in the official Bitcoin-qt. I do not like to trust other clients or branches. I'd like to have that feature available, though. Better than locking outputs.

Raw transactions seem error-prone to me. One mistake and the coins are gone.


Title: Re: Bitcoin Qt: lockunspent broken?
Post by: Hans0 on March 17, 2014, 11:21:00 PM
Doing further research it seems that 0.9 seems to have coin control. That's great news!