Beem: Blockchain.get_transaction / get_transaction_hex issues on appbase nodes

in #utopian-io6 years ago

Project Information

A GitHub issue and a PR to fix one aspect of the problem were created. The PO merged the PR and added a fix of the remaining aspect:

Expected behavior

Blockchain.get_transaction should return the transaction for a given transaction id. This is for example used by blockchain explorers like steemd to show individual transactions.
Blockchain.get_transaction_hex should return a hexdump of the serialized binary form of a transaction. This function can be used to offload the serialization of a transaction to the RPC node before signing.

Actual behavior

Blockchain.get_transaction and Blockchain.get_transaction_hex fail on appbase nodes with Could not find method get_transaction

How to reproduce

from beem import Steem
from beem.blockchain import Blockchain
trx_id = '6fde0190a97835ea6d9e651293e90c89911f933c'
s = Steem(node=['https://api.steemit.com'])
b = Blockchain(steem_instance=s)
print(b.get_transaction(trx_id))
from beem import Steem
from beem.blockchain import Blockchain
trx = {"ref_block_num":1097,"ref_block_prefix":2181793527,"expiration":"2016-03-24T18:00:21","operations":[{"type":"pow_operation","value":{"worker_account":"cloop3","block_id":"00000449f7860b82b4fbe2f317c670e9f01d6d9a","nonce":3899,"work":{"worker":"STM7P5TDnA87Pj9T4mf6YHrhzjC1KbPZpNxLWCcVcHxNYXakpoT4F","input":"ae8e7c677119d22385f8c48026fee7aad7bba693bf788d7f27047f40b47738c0","signature":"1f38fe9a3f9989f84bd94aa5bbc88beaf09b67f825aa4450cf5105d111149ba6db560b582c7dbb026c7fc9c2eb5051815a72b17f6896ed59d3851d9a0f9883ca7a","work":"000e7b209d58f2e64b36e9bf12b999c6c7af168cc3fc41eb7f8a4bf796c174c3"},"props":{"account_creation_fee":{"amount":"100000","precision":3,"nai":"@@000000021"},"maximum_block_size":131072,"sbd_interest_rate":1000}}}],"extensions":[],"signatures":[]}
s = Steem(node=['https://api.steemit.com'])
b = Blockchain(steem_instance=s)
print(b.get_transaction_hex(trx))

The problem with get_transaction_hex() is a typo, the function internally calls get_transaction() instead of get_transaction_hex().

get_transaction() tries to use database_api. However, this method is not part of database_api. According to the documentation, it's only part of condenser_api. Changing the API to "condenser" results in a account_history_api_plugin not enabled Exception. This exception is also thrown with the example in the official documentation.

The PO corrected the API method to account_history. The reason why the call still fails is that the specific node used here doesn't have that plugin enabled. The call will work now on a node with the appropriate plugins enabled.

Environment

# python --version
Python 3.6.6
# beempy --version
beempy, version 0.19.50

GitHub Account

https://github.com/crokkon

Sort:  

Hi @stmdev, thanks for making this contribution.

Good job on the hunting, you took every step necessary to replicate the bug, including testing with an example found in the documentation. And in the process successfully pulling the attention of the PO to an error that was missed.

Apart from analysing what led to the error, you made a PR that fixed an aspect of the bug. Kudos on that, this adds significant value to the open source community.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

Thanks for this great input, I look forward to your next contribution.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Thank you for your review, @fego!

So far this week you've reviewed 4 contributions. Keep up the good work!

Hey @stmdev
Thanks for contributing on Utopian.
Congratulations! Your contribution was Staff Picked to receive a maximum vote for the bug-hunting category on Utopian for being of significant value to the project and the open source community.

We’re already looking forward to your next contribution!

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.15
TRX 0.16
JST 0.028
BTC 68804.96
ETH 2441.52
USDT 1.00
SBD 2.33