Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot unlock already spent output #12738

Closed
pedrobranco opened this issue Mar 20, 2018 · 3 comments · Fixed by #13160
Closed

Cannot unlock already spent output #12738

pedrobranco opened this issue Mar 20, 2018 · 3 comments · Fixed by #13160

Comments

@pedrobranco
Copy link
Contributor

When using the lockunspent RPC method to prevent concurrency when creating raw transactions, after spending a locked output it is impossible to remove that output from locked unspent list due to an issue introduced in this PR #11087.

Example:

❯ bitcoin-cli listunspent
[ { "txid": "889379c3ea542024c2cba1d2f938ed3ea9d77d1c3b25bc36c6cc7b866aed9624", "vout": 0, "address": "mhNZnkDU9DtNqXDCo8jNUpPAYX4bfsdYdy", "scriptPubKey": "21030e468d40a69954e5ed1d9536a8bec61317c423b423a4eac49869609a0034d859ac", "amount": 50.00000000, "confirmations": 101, "spendable": true, "solvable": true, "safe": true } ]

❯ bitcoin-cli lockunspent false '[{ "txid": "889379c3ea542024c2cba1d2f938ed3ea9d77d1c3b25bc36c6cc7b866aed9624", "vout": 0 }]'
true

❯ bitcoin-cli listlockunspent
[ { "txid": "889379c3ea542024c2cba1d2f938ed3ea9d77d1c3b25bc36c6cc7b866aed9624", "vout": 0 } ]

❯ bitcoin-cli createrawtransaction '[{"txid":"889379c3ea542024c2cba1d2f938ed3ea9d77d1c3b25bc36c6cc7b866aed9624", "vout":0}]' '{ "mhNZnkDU9DtNqXDCo8jNUpPAYX4bfsdYdy": 49.99999 }'
02000000012496ed6a867bccc636bc253b1c7dd7a93eed38f9d2a1cbc2242054eac37993880000000000ffffffff0118ee052a010000001976a914145a232ba20c2f679585145d487546cc294cf54e88ac00000000

❯ bitcoin-cli signrawtransaction 02000000012496ed6a867bccc636bc253b1c7dd7a93eed38f9d2a1cbc2242054eac37993880000000000ffffffff0118ee052a010000001976a914145a232ba20c2f6795851
45d487546cc294cf54e88ac00000000
{ "hex": "02000000012496ed6a867bccc636bc253b1c7dd7a93eed38f9d2a1cbc2242054eac37993880000000049483045022100e71376bc4336db9021a3ec0d4ec99d160d062d941127771c05ce9120c93be90f02202670572802b27ae363f420cea7a7abd7cf29ac0f7277057a6e4ff1bced6c88eb01ffffffff0118ee052a010000001976a914145a232ba20c2f679585145d487546cc294cf54e88ac00000000", "complete": true }


❯ bitcoin-cli sendrawtransaction 02000000012496ed6a867bccc636bc253b1c7dd7a93eed38f9d2a1cbc2242054eac37993880000000049483045022100e71376bc4336db9021a3ec0d4ec99d160d062d941127771c05ce9120c93be90f02202670572802b27ae363f420cea7a7abd7cf29ac0f7277057a6e4ff1bced6c88eb01ffffffff0118ee052a010000001976a914145a232ba20c2f679585145d487546cc294cf54e88ac00000000
1b66295a16eda977788516c71d1e87c7a24b88651141678320b50b85c6602026


❯ bitcoin-cli listlockunspent
[ { "txid": "889379c3ea542024c2cba1d2f938ed3ea9d77d1c3b25bc36c6cc7b866aed9624", "vout": 0 } ]

# Unlock the already spent output
❯ bitcoin-cli lockunspent true '[{ "txid": "889379c3ea542024c2cba1d2f938ed3ea9d77d1c3b25bc36c6cc7b866aed9624", "vout": 0 }]'
error code: -8
error message:
Invalid parameter, expected unspent output

❯ bitcoin-cli listlockunspent
[ { "txid": "889379c3ea542024c2cba1d2f938ed3ea9d77d1c3b25bc36c6cc7b866aed9624", "vout": 0 } ]

The expected output was:

# Unlock the already spent output
❯ bitcoin-cli lockunspent true '[{ "txid": "889379c3ea542024c2cba1d2f938ed3ea9d77d1c3b25bc36c6cc7b866aed9624", "vout": 0 }]'
true 

❯ bitcoin-cli listlockunspent
[ ]
@promag
Copy link
Member

promag commented Mar 21, 2018

IMO after sendrawtransaction this should be the case:

❯ bitcoin-cli listlockunspent
[]

Because at this point it is not an unspent and it's not listed in listunspent.

Therefore Invalid parameter, expected unspent output seams to be a sensible error.

@pedrobranco
Copy link
Contributor Author

IMO after sendrawtransaction this should be the case

They are different situations:

  • having sendrawtransaction to remove the used unspents from the locked unspent list, which is nice
  • As of now, we cannot unlock spent outputs (in older versions worked fine).

@promag
Copy link
Member

promag commented Mar 21, 2018

I don't think the fix is to reintroduce the old behavior. As you said:

cannot unlock spent outputs

And the call is lockunspent.

laanwj added a commit that referenced this issue Jun 24, 2018
fd9b3a7 test: Output should be unlocked when spent (João Barbosa)
54c3bb4 wallet: Unlock spent outputs (João Barbosa)

Pull request description:

  Fixes #12738.

Tree-SHA512: 2c1694727aea0c658d07566c7d11d7afe91218053f84d568fac97413348fa5a977243d6cdeebd1c6550816489e35cb3a31667c8354d9b350de99f979d641d605
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this issue Jul 7, 2020
fd9b3a7 test: Output should be unlocked when spent (João Barbosa)
54c3bb4 wallet: Unlock spent outputs (João Barbosa)

Pull request description:

  Fixes bitcoin#12738.

Tree-SHA512: 2c1694727aea0c658d07566c7d11d7afe91218053f84d568fac97413348fa5a977243d6cdeebd1c6550816489e35cb3a31667c8354d9b350de99f979d641d605
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this issue Jul 7, 2020
fd9b3a7 test: Output should be unlocked when spent (João Barbosa)
54c3bb4 wallet: Unlock spent outputs (João Barbosa)

Pull request description:

  Fixes bitcoin#12738.

Tree-SHA512: 2c1694727aea0c658d07566c7d11d7afe91218053f84d568fac97413348fa5a977243d6cdeebd1c6550816489e35cb3a31667c8354d9b350de99f979d641d605
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this issue Jul 8, 2020
fd9b3a7 test: Output should be unlocked when spent (João Barbosa)
54c3bb4 wallet: Unlock spent outputs (João Barbosa)

Pull request description:

  Fixes bitcoin#12738.

Tree-SHA512: 2c1694727aea0c658d07566c7d11d7afe91218053f84d568fac97413348fa5a977243d6cdeebd1c6550816489e35cb3a31667c8354d9b350de99f979d641d605
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this issue Jun 27, 2021
fd9b3a7 test: Output should be unlocked when spent (João Barbosa)
54c3bb4 wallet: Unlock spent outputs (João Barbosa)

Pull request description:

  Fixes bitcoin#12738.

Tree-SHA512: 2c1694727aea0c658d07566c7d11d7afe91218053f84d568fac97413348fa5a977243d6cdeebd1c6550816489e35cb3a31667c8354d9b350de99f979d641d605
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this issue Jun 28, 2021
fd9b3a7 test: Output should be unlocked when spent (João Barbosa)
54c3bb4 wallet: Unlock spent outputs (João Barbosa)

Pull request description:

  Fixes bitcoin#12738.

Tree-SHA512: 2c1694727aea0c658d07566c7d11d7afe91218053f84d568fac97413348fa5a977243d6cdeebd1c6550816489e35cb3a31667c8354d9b350de99f979d641d605
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this issue Jun 29, 2021
fd9b3a7 test: Output should be unlocked when spent (João Barbosa)
54c3bb4 wallet: Unlock spent outputs (João Barbosa)

Pull request description:

  Fixes bitcoin#12738.

Tree-SHA512: 2c1694727aea0c658d07566c7d11d7afe91218053f84d568fac97413348fa5a977243d6cdeebd1c6550816489e35cb3a31667c8354d9b350de99f979d641d605
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
gades pushed a commit to cosanta/cosanta-core that referenced this issue Feb 15, 2022
fd9b3a7 test: Output should be unlocked when spent (João Barbosa)
54c3bb4 wallet: Unlock spent outputs (João Barbosa)

Pull request description:

  Fixes bitcoin#12738.

Tree-SHA512: 2c1694727aea0c658d07566c7d11d7afe91218053f84d568fac97413348fa5a977243d6cdeebd1c6550816489e35cb3a31667c8354d9b350de99f979d641d605
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants