:: Re: [Libbitcoin] Duplicated Bitcoin…
Startseite
Nachricht löschen
Nachricht beantworten
Autor: William Swanson
Datum:  
To: libbitcoin@lists.dyne.org
Betreff: Re: [Libbitcoin] Duplicated Bitcoin amount string <-> text routines
Ok, this is done now
(https://github.com/libbitcoin/libbitcoin/pull/137). Neither of the
existing solutions were capable of doing everything, so I ended up
writing new routines from scratch.

The new routines support Bitcoins, millibits, and µBTC, so the old
`btc_to_satoshi` and `satoshi_to_btc` names aren't really appropriate
anymore. The new routines are called `parse_amount` and
`format_amount`, but their function signatures are more in line with
the old `btc_to_satoshi` and `satoshi_to_btc`. The old `parse_amount`
and `format_amount` are gone.

The new routines also support rounding. If the input describes an
impossible fractional satoshi, the routines can round that up to the
nearest whole satoshi. Bad Javascript wallets sometimes produce these
impossible payment requests, so rounding upwards (i.e. paying a little
extra) is the best approach for real-world interoperability. The
rounding is turned off by default, so impossible fractional satoshis
still produce an error unless you specify otherwise.

-William

On Sun, Nov 30, 2014 at 4:33 AM, William Swanson <swansontec@???> wrote:
> I just chatted with Eric on IRC about this, and it looks like the best
> solution is to keep parse_amount, but to make the rounding optional.
> If the rounding is turned off, the routine will return failure if the
> input has more than 8 digits after the decimal point. This maintains
> compatibility with the existing btc_to_satoshi routine.
>
> -William