Add P2SH change address test
This commit is contained in:
parent
e396bc5dc6
commit
c3ff63f041
|
@ -130,6 +130,7 @@ describe('Transaction', function() {
|
||||||
};
|
};
|
||||||
var toAddress = 'mrU9pEmAx26HcbKVrABvgL7AwA5fjNFoDc';
|
var toAddress = 'mrU9pEmAx26HcbKVrABvgL7AwA5fjNFoDc';
|
||||||
var changeAddress = 'mgBCJAsvzgT2qNNeXsoECg2uPKrUsZ76up';
|
var changeAddress = 'mgBCJAsvzgT2qNNeXsoECg2uPKrUsZ76up';
|
||||||
|
var changeAddressP2SH = '2N7T3TAetJrSCruQ39aNrJvYLhG1LJosujf';
|
||||||
var privateKey = 'cSBnVM4xvxarwGQuAfQFwqDg9k5tErHUHzgWsEfD4zdwUasvqRVY';
|
var privateKey = 'cSBnVM4xvxarwGQuAfQFwqDg9k5tErHUHzgWsEfD4zdwUasvqRVY';
|
||||||
|
|
||||||
it('can calculate simply the output amount', function() {
|
it('can calculate simply the output amount', function() {
|
||||||
|
@ -143,6 +144,15 @@ describe('Transaction', function() {
|
||||||
transaction.outputs[1].script.toString()
|
transaction.outputs[1].script.toString()
|
||||||
.should.equal(Script.fromAddress(changeAddress).toString());
|
.should.equal(Script.fromAddress(changeAddress).toString());
|
||||||
});
|
});
|
||||||
|
it('accepts a P2SH address for change', function() {
|
||||||
|
var transaction = new Transaction()
|
||||||
|
.from(simpleUtxoWith100000Satoshis)
|
||||||
|
.to(toAddress, 50000)
|
||||||
|
.change(changeAddressP2SH)
|
||||||
|
.sign(privateKey);
|
||||||
|
transaction.outputs.length.should.equal(2);
|
||||||
|
transaction.outputs[1].script.isScriptHashOut().should.equal(true);
|
||||||
|
});
|
||||||
it('can recalculate the change amount', function() {
|
it('can recalculate the change amount', function() {
|
||||||
var transaction = new Transaction()
|
var transaction = new Transaction()
|
||||||
.from(simpleUtxoWith100000Satoshis)
|
.from(simpleUtxoWith100000Satoshis)
|
||||||
|
|
Loading…
Reference in New Issue