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

Feature/method get transaction only returns in wallet transactions #111

Conversation

bridgedragon
Copy link
Collaborator

Description

The method getTransaction has been standardized to be run for any transaction (not only in-wallet ones).

  • At first I tought I could make the method work with ElectrumX-ElectRs RPC. This could be useful in a future when issue Remove electrum completely #110 will be merged, and adds the possibility of disabling bitcoind -txindex, saving precious hard disk space (cool cool cool).
  • It wasn't that cool... ElectRs does not index block height of a transaction... So, for that reason, we can't remove the -txindex, and it can't work without -txindex. (More on: Implement blockchain.transaction.get verbose support Blockstream/electrs#36). - my joy in a well :'(
  • I left the methods and classes that can be used in resolving issue Remove electrum completely #110, allowing to call ElectRs Rpc directly.
  • I realized that issue Abstract and standarize getTransaction() method #27 had a lot of disadvantages while I was coding this: If transaction are broken down in senders and destinations, it makes us work with decimal numbers and a lot of potential errors. Not cool. So, instead of "transactions", the getTransaction method now returns "inputs" and "outputs", with "address" and "amount" fields on each one. If i/o is not standard, null is returned.

Fixes #88

Dependencies (if any)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Good practices to consider

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Connector/btc/apirpc.py Outdated Show resolved Hide resolved
Connector/btc/apirpc.py Outdated Show resolved Hide resolved
Connector/btc/apirpc.py Outdated Show resolved Hide resolved
value = inputTransaction["decoded"]["vout"][vin["vout"]]["value"]
vinAddressBalances[address] = value
# Converting all transaction details to str
transactionDetails["fee"] = str(transactionDetails["fee"])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to store the string value, just return the string value in response variable, "fee":str(transactionDetails["fee"])

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree with this, because we are converting all elements in the array at once. I do not want to mix str variables with not-str ones in the same array.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is that the behaviour is the same if you delete this line and add "fee":str(transactionDetails["fee"]) in line 434

Copy link
Collaborator

@phoenix-web3 phoenix-web3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the requested changes of @swapper-pegasus this can be merged

Thanks @bridgedragon , beautiful code!

@bridgedragon bridgedragon merged commit d9971d7 into swapper-org:staging Mar 2, 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

Successfully merging this pull request may close these issues.

Method getTransaction only returns 'in-wallet' transactions
3 participants