fix utils.toBTC
This commit is contained in:
parent
cb2bcc21c6
commit
75afb6d953
@ -543,7 +543,7 @@ utils.assert.equal = function assertEqual(l, r, msg) {
|
|||||||
|
|
||||||
utils.toBTC = function toBTC(satoshi, strict) {
|
utils.toBTC = function toBTC(satoshi, strict) {
|
||||||
var m = new bn(10000000).mul(new bn(10));
|
var m = new bn(10000000).mul(new bn(10));
|
||||||
var lo = satoshi.mod(m);
|
var lo;
|
||||||
|
|
||||||
if (typeof satoshi === 'string' && /^\d+(?:\.\d+)?$/.test(satoshi)) {
|
if (typeof satoshi === 'string' && /^\d+(?:\.\d+)?$/.test(satoshi)) {
|
||||||
satoshi = new bn(satoshi, 10);
|
satoshi = new bn(satoshi, 10);
|
||||||
@ -556,6 +556,8 @@ utils.toBTC = function toBTC(satoshi, strict) {
|
|||||||
if (!(satoshi instanceof bn))
|
if (!(satoshi instanceof bn))
|
||||||
throw new Error('could not calculate btc');
|
throw new Error('could not calculate btc');
|
||||||
|
|
||||||
|
lo = satoshi.mod(m);
|
||||||
|
|
||||||
if (lo.cmpn(0) !== 0) {
|
if (lo.cmpn(0) !== 0) {
|
||||||
lo = lo.toString(10);
|
lo = lo.toString(10);
|
||||||
while (lo.length < 8)
|
while (lo.length < 8)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user