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

pset_swap_tutorial fails getting addresses index 0 from output #1191

Closed
wintercooled opened this issue Nov 18, 2022 · 3 comments
Closed

pset_swap_tutorial fails getting addresses index 0 from output #1191

wintercooled opened this issue Nov 18, 2022 · 3 comments

Comments

@wintercooled
Copy link
Contributor

Running

python contrib/assets_tutorial/pset_swap_tutorial.py

I get an error at line 215: address = out["scriptPubKey"]["addresses"][0] as out["scriptPubKey"] doesn't contain an array of addresses, just one address field.

The error output:

1. Start nodes and setup scenario
Alice datadir: /tmp/tmpbbxd89kj
Starting Alice
Carol datadir: /tmp/tmp93qh56am
Starting Carol
2. Create an unsigned swap transaction in PSET format.
2a. Exchange addresses
    Alice:  el1qqw9eu5pqra2jj2jhf99tlluly2qyy9zk7p98u9d9ud7m4aeeg22c9gc3wpktl4k5ur2eunduagq2xgv6f2kxz36vph86t83tn
    Carol:  el1qqdf2v3yh7tuwe82cmwt4nnwrwmd6py0352u929dx9qyg3kzw6cw5k2xghjm0u48mr72ehyzdhw2d7y8qmykpzqulk4nrdkhpy
2b. Exchange partial transaction data
2c. Check partial transactions
2d. Create combined transaction
Traceback (most recent call last):
  File "contrib/assets_tutorial/pset_swap_tutorial.py", line 215, in <module>
    address = out["scriptPubKey"]["addresses"][0]
KeyError: 'addresses'
Shutting down Alice
Shutting down Carol

This was running Elements 0.22.0.2.

I can fix this by replacing:

out["scriptPubKey"]["addresses"][0]

with

out["scriptPubKey"]["address"]

which allows the example to complete, but I'm not sure if this obvious looking fix is missing some other subtleties.

@wintercooled
Copy link
Contributor Author

A fix can be found here: master...wintercooled:elements:fix-pset-example

But it seems so simple a fix I might be missing something. If not I will create a PR.

@wintercooled
Copy link
Contributor Author

Raised #1192 to fix

@psgreco
Copy link
Contributor

psgreco commented Nov 18, 2022

Fixed by #1192, closing

@psgreco psgreco closed this as completed Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants