Merge pull request #1321 from matiu/builderOtps

fix sighash opts + add tests
This commit is contained in:
Gustavo Maximiliano Cortez 2014-09-09 10:00:34 -03:00
commit 887c507767
2 changed files with 20 additions and 2 deletions

View File

@ -107,7 +107,7 @@ inherits(Wallet, events.EventEmitter);
*/
Wallet.builderOpts = {
lockTime: null,
signhash: bitcore.Transaction.SIGNHASH_ALL,
signhash: bitcore.Transaction.SIGHASH_ALL,
fee: undefined,
feeSat: undefined,
};

View File

@ -205,8 +205,26 @@ describe('Wallet model', function() {
f.should.throw(Error);
});
it('#create, 1 sign', function() {
it('#create, check builder opts', function() {
var w = cachedCreateW2();
unspentTest[0].address = w.publicKeyRing.getAddress(1, true, w.publicKey).toString();
unspentTest[0].scriptPubKey = w.publicKeyRing.getScriptPubKeyHex(1, true, w.publicKey);
var ntxid = w.createTxSync(
'mgGJEugdPnvhmRuFdbdQcFfoFLc1XXeB79',
'123456789',
null,
unspentTest
);
var t = w.txProposals;
var opts = JSON.parse(t.txps[ntxid].builder.vanilla.opts);
opts.signhash.should.equal(1);
(opts.lockTime===null).should.be.true;
should.not.exist(opts.fee);
should.not.exist(opts.feeSat);
});
it('#create, 1 sign', function() {
var w = cachedCreateW2();
unspentTest[0].address = w.publicKeyRing.getAddress(1, true, w.publicKey).toString();