Browse Source

Transaction: Use Script toString for transaction JSON output

patch-2
Braydon Fuller 10 years ago
parent
commit
ad4bc9324f
  1. 2
      lib/transaction/input/input.js
  2. 4
      lib/transaction/output.js
  3. 4
      test/transaction.js

2
lib/transaction/input/input.js

@ -45,7 +45,7 @@ Input.prototype.toObject = function toObject() {
prevTxId: this.prevTxId.toString('hex'),
outputIndex: this.outputIndex,
sequenceNumber: this.sequenceNumber,
script: this._scriptBuffer.toString('hex')
script: this._script.toString()
};
};

4
lib/transaction/output.js

@ -38,7 +38,7 @@ Object.defineProperty(Output.prototype, 'satoshis', {
if (num instanceof BN) {
this._satoshis = num;
} else {
this._satoshis = BN().fromNumber(num);
this._satoshis = BN(num, 'hex');
}
}
});
@ -54,7 +54,7 @@ Output.prototype._fromObject = function(param) {
Output.prototype.toObject = function toObject() {
return {
satoshis: this.satoshis,
script: this._scriptBuffer.toString('hex')
script: this._script.toString()
};
};

4
test/transaction.js

@ -68,10 +68,10 @@ var tx_1_json = JSON.stringify({
prevTxId:"a477af6b2667c29670467e4e0728b685ee07b240235771862318e29ddbe58458",
outputIndex:0,
sequenceNumber:4294967295,
script:"473044022013fa3089327b50263029265572ae1b022a91d10ac80eb4f32f291c914533670b02200d8a5ed5f62634a7e1a0dc9188a3cc460a986267ae4d58faf50c79105431327501210223078d2942df62c45621d209fab84ea9a7a23346201b7727b9b45a29c4e76f5e"}],
script:'71 0x3044022013fa3089327b50263029265572ae1b022a91d10ac80eb4f32f291c914533670b02200d8a5ed5f62634a7e1a0dc9188a3cc460a986267ae4d58faf50c79105431327501 33 0x0223078d2942df62c45621d209fab84ea9a7a23346201b7727b9b45a29c4e76f5e'}],
outputs:[{
satoshis:1010000,
script:"76a9147821c0a3768aa9d1a37e16cf76002aef5373f1a888ac"
script:'OP_DUP OP_HASH160 20 0x7821c0a3768aa9d1a37e16cf76002aef5373f1a8 OP_EQUALVERIFY OP_CHECKSIG'
}],
nLockTime:0
});

Loading…
Cancel
Save