Allow satoshis to be a string on output creation
This commit is contained in:
parent
b7ef077591
commit
614a228c79
|
@ -43,6 +43,9 @@ Object.defineProperty(Output.prototype, 'satoshis', {
|
||||||
if (num instanceof BN) {
|
if (num instanceof BN) {
|
||||||
this._satoshisBN = num;
|
this._satoshisBN = num;
|
||||||
this._satoshis = num.toNumber();
|
this._satoshis = num.toNumber();
|
||||||
|
} else if (_.isString(num)) {
|
||||||
|
this._satoshis = parseInt(num);
|
||||||
|
this._satoshisBN = BN.fromNumber(this._satoshis);
|
||||||
} else {
|
} else {
|
||||||
this._satoshisBN = BN.fromNumber(num);
|
this._satoshisBN = BN.fromNumber(num);
|
||||||
this._satoshis = num;
|
this._satoshis = num;
|
||||||
|
|
|
@ -49,6 +49,11 @@ describe('Transaction', function() {
|
||||||
object.outputs[0].satoshis.should.equal(testAmount - 10000);
|
object.outputs[0].satoshis.should.equal(testAmount - 10000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can take a string argument as an amount', function() {
|
||||||
|
var stringTx = new Transaction().to('mrU9pEmAx26HcbKVrABvgL7AwA5fjNFoDc', '10000');
|
||||||
|
(stringTx._outputAmount).should.equal(10000);
|
||||||
|
});
|
||||||
|
|
||||||
it('returns the fee correctly', function() {
|
it('returns the fee correctly', function() {
|
||||||
testTransaction.getFee().should.equal(10000);
|
testTransaction.getFee().should.equal(10000);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue