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

Problem with rounding and 40 max bytes #5

Open
carlinhoxapo opened this issue Oct 28, 2016 · 1 comment
Open

Problem with rounding and 40 max bytes #5

carlinhoxapo opened this issue Oct 28, 2016 · 1 comment

Comments

@carlinhoxapo
Copy link

Hi, i been testing this lib and i louve it, i found two things that can be improved:

one is to change the OP_RETURN_MAX_BYTES=40 to 80 as the field is now bigger

the other is that i found sometimes a problem with rounding the change amount. It sometimes goes to more than 8 decimal and this is a problem.

I added this small modification to prevent it from happening on the OP_RETURN_send function :

# Calculate amounts and choose inputs
send_amount = round(send_amount,8)

output_amount=round(send_amount+OP_RETURN_BTC_FEE,8)

inputs_spend=OP_RETURN_select_inputs(output_amount, testnet)

if 'error' in inputs_spend:
    return {'error': inputs_spend['error']}

change_amount=round(inputs_spend['total']-output_amount,8)

Regards

Carlos

@gidgreen
Copy link
Contributor

Thanks - we'll incorporate when we next update the library.

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