Skip to content

Problem with rounding and 40 max bytes #5

@carlinhoxapo

Description

@carlinhoxapo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions