Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Exception: KeyError: 'sends'. when calling asset BTC. #91

Open
dan-da opened this issue Aug 22, 2016 · 7 comments
Open

Exception: KeyError: 'sends'. when calling asset BTC. #91

dan-da opened this issue Aug 22, 2016 · 7 comments
Labels

Comments

@dan-da
Copy link

dan-da commented Aug 22, 2016

Got this error.

$ counterparty-client asset BTC
[2016-08-22 10:51:07][INFO] Running v1.1.2 of counterparty-client.
Unhandled Exception
Traceback (most recent call last):
  File "/usr/local/bin/counterparty-client", line 9, in <module>
    load_entry_point('counterparty-cli==1.1.2', 'console_scripts', 'counterparty-client')()
  File "/home/counterpartycoin/counterparty-cli/counterpartycli/__init__.py", line 12, in client_main
    client.main()
  File "/home/counterpartycoin/counterparty-cli/counterpartycli/client.py", line 252, in main
    print_method(view)
  File "/home/counterpartycoin/counterparty-cli/counterpartycli/console.py", line 73, in print_asset
    if asset['sends']:
KeyError: 'sends'

I fixed (or worked around) it with:


diff --git a/counterpartycli/console.py b/counterpartycli/console.py
index b76b139..1cd246e 100755
--- a/counterpartycli/console.py
+++ b/counterpartycli/console.py
@@ -70,7 +70,7 @@ def print_asset(asset):
             table.add_row([address, balance])
         lines.append(table.get_string())

-    if asset['sends']:
+    if 'sends' in asset and asset['sends']:
         lines.append('')
         lines.append('Sends')
         table = PrettyTable(['Type', 'Quantity', 'Source', 'Destination'])
@unsystemizer
Copy link
Contributor

Do you want submit a Pull Request for this to develop branch?

@unsystemizer
Copy link
Contributor

  • Largely duplicate of asset cmd KeyError #48
  • Note that this is consistent with the API behavior - BTC is not a Counterparty asset, so transaction history is not supposed to be looked up this way. I think if you want to look up tx history, you should submit a PR for the wallet or balances function in console.py.

Can we close this now?

@dan-da
Copy link
Author

dan-da commented Dec 30, 2016

I just submitted the issue because I thought the maintainers might like to be aware and do something about it.

Seems to me that a well designed software handling people's money should handle all user input as gracefully as possible. If looking up BTC is not supported, then it should probably give a friendly error message in that case.

@unsystemizer
Copy link
Contributor

unsystemizer commented Dec 30, 2016

Absolutely - thanks for taking time to let us know and share the patch, we appreciate it!
I just wanted to check if you want to submit a pull request by yourself (some people mind if others use their code to submit a pull request).

We'll try to improve console.py shortly, maybe by adding improvements to another (or new) command.
We should pass-through (as per your patch) or add a separate command.

@dan-da
Copy link
Author

dan-da commented Dec 30, 2016

I'm not going to submit a pull request. I would if I'd done something significant, but that was just a one-liner that quickly resolved the issue for me, so I included it as example -- likely not the correct fix.

of course feel free to use it if you like it.

@unsystemizer
Copy link
Contributor

unsystemizer commented Dec 31, 2016

For future reference:

  • Here's what the patch does:
$ counterparty-client asset BTC
[2016-12-31 12:34:01][INFO] Running v1.1.2 of counterparty-client.

Informations
+--------------+------------+
| Asset Name:  |    BTC     |
|  Asset ID:   |     0      |
|  Divisible:  |    True    |
|   Locked:    |   False    |
|   Supply:    | 16074587.5 |
|   Issuer:    |    None    |
| Description: |     ‘’     |
|   Balance:   | 0.00972442 |
+--------------+------------+

Addresses
+------------------------------------+------------+
|              Address               |  Balance   |
+------------------------------------+------------+
| xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | 0.01972442 |
+------------------------------------+------------+

(I wasn't sure whether the workaround was that with it the API returns a "not supported" message, or it actually treats BTC as another CP asset name. Interestingly the supply amount is correct too).

  • In the protocol specification BTC sends aren't considered to be Counterparty transactions and BTC isn't a CP asset, so we could adopt this patch but also create a different action that would provide similar functionality (maybe just proxy certain Bitcoin Core commands the way wallet action does it). Ideas and contributions are welcome.

@chiguireitor
Copy link
Contributor

Guess the correct solution is to return a "not an asset" error (BTC is not an asset anyways)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants