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

Withdrawal error when unspent xact has native segwit outputs #14

bitcoinhodler opened this issue Jan 25, 2018 · 1 comment


Copy link

bitcoinhodler commented Jan 25, 2018


If a user sends funds to their Glacier cold storage address, and the funding transaction also includes an output to a native segwit address, the Glacier withdrawal process will fail with a nasty error from


All such funds will be frozen and unspendable until an updated version of Glacier is released.

This kind of transaction is generated by the latest version of Electrum, if a user creates a Segwit wallet and then sends less than 100% of his wallet balance to his Glacier cold storage address. The resulting transaction will have a change output that is native segwit, and this will break Glacier.


I created this testnet Glacier cold-storage address 2NAVkgszAvjZZwWpHpbCaxSaNqCCXPD8Bts and funded it with a variety of segwit-related transactions. This transaction is the one that broke

Traceback (most recent call last):
  File "./", line 798, in <module>
  File "./", line 663, in withdraw_interactive
    utxos += get_utxos(tx, source_address)
  File "./", line 301, in get_utxos
    out_addresses = output["scriptPubKey"]["addresses"]
keyError: 'addresses'

The problem is that the native segwit output is not decoded by Bitcoin Core 0.15.1:

{   u'hash': u'8fa47175147306685c842f077efebbacd70125b5acdd58e74dc20678b91afcea',
    u'locktime': 1260359,
    u'size': 223,
    u'txid': u'92cc97cc3a1110e5d08fdae9a142561982a2f2fc96d7f4072722b3e8ef321edf',
    u'version': 1,
    u'vin': [   {   u'scriptSig': {   u'asm': u'', u'hex': u''},
                    u'sequence': 4294967294L,
                    u'txid': u'bfe9054a55d0c03d1770e9bc4e367fd0f47586f542df2246e1c7b3744b437c0a',
                    u'txinwitness': [   u'30440220519ddc39c2dae10381c8af6b04d7792f59623faa70b417ad05caf453677bc23c022012674cfcd0b3abace75b81616618469e3d36b57ea27f98dd1e98a2fa28fb674401',
                    u'vout': 1}],
    u'vout': [   {   u'n': 0,
                     u'scriptPubKey': {   u'addresses': [   u'2NAVkgszAvjZZwWpHpbCaxSaNqCCXPD8Bts'],
                                          u'asm': u'OP_HASH160 bd3996bb9a6c401da7e65d4dbb3a9b978cd045ec OP_EQUAL',
                                          u'hex': u'a914bd3996bb9a6c401da7e65d4dbb3a9b978cd045ec87',
                                          u'reqSigs': 1,
                                          u'type': u'scripthash'},
                     u'value': 0.42421},
                 {   u'n': 1,
                     u'scriptPubKey': {   u'asm': u'0 2cc6ea9ff95d8f4ce870e184cc0c2f13eb85f94b',
                                          u'hex': u'00142cc6ea9ff95d8f4ce870e184cc0c2f13eb85f94b',
                                          u'type': u'witness_v0_keyhash'},
                     u'value': 0.425788}],
    u'vsize': 142}

The second output's scriptPubKey does not have any addresses in this data structure.

To recreate

See branch segwit-tests in my fork for an automated test that shows the issue, along with a fix which I will PR shortly.


I will file an errata for the website to explain how to avoid the problem (by avoiding change outputs altogether).

Copy link
Collaborator Author

bitcoinhodler commented Mar 6, 2018

Bug is fixed in Glacier v0.92

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

1 participant