complete validation tests for txProposal SIGHASH
This commit is contained in:
parent
d7650f30ff
commit
b5c144d48c
4 changed files with 97 additions and 5 deletions
|
|
@ -5,10 +5,11 @@ var imports = require('soop').imports();
|
|||
var bitcore = require('bitcore');
|
||||
var util = bitcore.util;
|
||||
var Transaction = bitcore.Transaction;
|
||||
var Builder = bitcore.TransactionBuilder;
|
||||
var BuilderMockV0 = require('./BuilderMockV0');;
|
||||
var TransactionBuilder = bitcore.TransactionBuilder;
|
||||
var Script = bitcore.Script;
|
||||
var buffertools = bitcore.buffertools;
|
||||
var preconditions = require('preconditions').instance();
|
||||
|
||||
function TxProposal(opts) {
|
||||
this.creator = opts.creator;
|
||||
|
|
@ -44,7 +45,7 @@ TxProposal.prototype.setSent = function(sentTxid) {
|
|||
TxProposal.fromObj = function(o) {
|
||||
var t = new TxProposal(o);
|
||||
try {
|
||||
t.builder = new Builder.fromObj(o.builderObj);
|
||||
t.builder = new TransactionBuilder.fromObj(o.builderObj);
|
||||
} catch (e) {
|
||||
if (!o.version) {
|
||||
t.builder = new BuilderMockV0(o.builderObj);
|
||||
|
|
@ -54,6 +55,14 @@ TxProposal.fromObj = function(o) {
|
|||
return t;
|
||||
};
|
||||
|
||||
|
||||
TxProposal.prototype.isValid = function() {
|
||||
if (this.builder.signhash !== Transaction.SIGHASH_ALL) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
TxProposal.getSentTs = function() {
|
||||
return this.sentTs;
|
||||
};
|
||||
|
|
@ -218,7 +227,6 @@ TxProposals.prototype.merge = function(inTxp, author) {
|
|||
return ret;
|
||||
};
|
||||
|
||||
var preconditions = require('preconditions').instance();
|
||||
TxProposals.prototype.add = function(data) {
|
||||
preconditions.checkArgument(data.inputChainPaths);
|
||||
preconditions.checkArgument(data.signedBy);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue