Incorrect utxo amount due to floating point error
See original GitHub issueGet utxos list of address mgeZMQw3SuCLiMoWba49Ga78vjVBpt1tyW
return incorrect amount value.
unpack_vout: {'scriptPubKey': {'reqSigs': 1, 'hex': '76a9140c684d69c0929221e5918b81a9709b784dc6fd2f88ac', 'addresses': ['mgeZMQw3SuCLiMoWba49Ga78vjVBpt1tyW'], 'asm': 'OP_DUP OP_HASH160 0c684d69c0929221e5918b81a9709b784dc6fd2f OP_EQUALVERIFY OP_CHECKSIG', 'type': 'pubkeyhash'}, 'n': 1, 'value': 0.00015743}
int(vout["value"] * config.UNIT)
# python >
int(0.00015743 * 100000000) # Return 15742 (Incorrect value)
We should use bigdecimal to handle.
Solution:
from decimal import *
int(Decimal(str(0.00015743)) * 100000000) # 15743
I found other places also got this error
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
"Selected Coins Doesnt Cover Full Amount" · Issue #1241 ...
This is the error I get, which shows its missing less than a satoshi, pointing to a zero float issue. ERROR: Selected coins...
Read more >How many useable UTXOs are possible with BTC inside them?
A reasonable amount of sats within the UTXO higher than the dust limit to then send. Any other possible restricting factors on resources...
Read more >How to resolve the accuracy error with floating point arithmetic
When I get to pennies, I've done so much floating point arithmetic that the value becomes inaccurate. Here is the output:.
Read more >Counterparty - Bountysource
Incorrect utxo amount due to floating point error $ 0 ... Created 1 year ago in CounterpartyXCP/counterparty-lib with 2 comments. ... Get utxos...
Read more >Fuzz Your Mother If You Want Fuzz | Alekos Filini
Fee rates are expressed as floating point numbers, ... Bug #2: The Branch and Bound CS assumes UTXO effective values are always positive....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah, I should post my first comment to your PR wakumo/counterparty-lib#2 . I agree that there is no concern to fix addrindexrs.py. 👍
issue should be fixed now in pull https://github.com/CounterpartyXCP/counterparty-lib/pull/1127