another tx test. minor.
This commit is contained in:
parent
50ab39aafb
commit
1e0394cc0b
@ -598,7 +598,7 @@ HDPrivateKey.prototype.derivePath = function derivePath(path) {
|
||||
* for passing to the HDPrivateKey constructor).
|
||||
*/
|
||||
|
||||
HDPrivateKey._fromSeed = function _fromSeed(seed, networkType) {
|
||||
HDPrivateKey.parseSeed = function parseSeed(seed, networkType) {
|
||||
var data, hash;
|
||||
|
||||
if (!seed)
|
||||
@ -642,7 +642,7 @@ HDPrivateKey._fromSeed = function _fromSeed(seed, networkType) {
|
||||
*/
|
||||
|
||||
HDPrivateKey.fromSeed = function fromSeed(seed, networkType) {
|
||||
return new HDPrivateKey(HDPrivateKey._fromSeed(seed, networkType));
|
||||
return new HDPrivateKey(HDPrivateKey.parseSeed(seed, networkType));
|
||||
};
|
||||
|
||||
/**
|
||||
@ -966,6 +966,7 @@ HDPublicKey.prototype.derive = function derive(index, hardened) {
|
||||
publicPoint = ec.elliptic.curve.decodePoint(this.publicKey);
|
||||
point = ec.elliptic.curve.g.mul(leftPart).add(publicPoint);
|
||||
publicKey = new Buffer(point.encode('array', true));
|
||||
assert(publicKey.length === 33);
|
||||
|
||||
if (!this.fingerPrint) {
|
||||
this.fingerPrint = utils.ripesha(this.publicKey)
|
||||
|
||||
@ -159,7 +159,7 @@ KeyPair.toSecret = function toSecret(privateKey, compressed) {
|
||||
* @returns {Object} A "naked" keypair object.
|
||||
*/
|
||||
|
||||
KeyPair._fromSecret = function _fromSecret(secret) {
|
||||
KeyPair.parseSecret = function parseSecret(secret) {
|
||||
var data = utils.fromBase58(secret);
|
||||
var p = new BufferReader(data, true);
|
||||
var compressed = false;
|
||||
@ -189,7 +189,7 @@ KeyPair._fromSecret = function _fromSecret(secret) {
|
||||
*/
|
||||
|
||||
KeyPair.fromSecret = function fromSecret(secret) {
|
||||
return new KeyPair(KeyPair._fromSecret(secret));
|
||||
return new KeyPair(KeyPair.parseSecret(secret));
|
||||
};
|
||||
|
||||
/**
|
||||
@ -238,7 +238,7 @@ KeyPair.parseJSON = function parseJSON(json, passphrase) {
|
||||
privateKey = json.privateKey;
|
||||
if (json.encrypted)
|
||||
privateKey = utils.decrypt(privateKey, passphrase);
|
||||
return KeyPair._fromSecret(privateKey);
|
||||
return KeyPair.parseSecret(privateKey);
|
||||
}
|
||||
|
||||
if (json.publicKey) {
|
||||
|
||||
@ -2293,16 +2293,16 @@ LoadRequest.prototype.start = function start() {
|
||||
LoadRequest.prototype.finish = function finish() {
|
||||
var index;
|
||||
|
||||
if (!this.active)
|
||||
return;
|
||||
|
||||
if (this.pool.request.map[this.hash]) {
|
||||
delete this.pool.request.map[this.hash];
|
||||
this.pool.request.active--;
|
||||
if (this.type === this.pool.tx.type)
|
||||
this.pool.request.activeTX--;
|
||||
else
|
||||
this.pool.request.activeBlocks--;
|
||||
if (this.active) {
|
||||
this.pool.request.active--;
|
||||
if (this.type === this.pool.tx.type)
|
||||
this.pool.request.activeTX--;
|
||||
else
|
||||
this.pool.request.activeBlocks--;
|
||||
this.active = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.type === this.pool.tx.type) {
|
||||
|
||||
@ -498,7 +498,7 @@ BufferReader.prototype.seek = function seek(off) {
|
||||
BufferReader.prototype.createChecksum = function createChecksum() {
|
||||
var start = this.stack[this.stack.length - 1] || 0;
|
||||
var data = this.data.slice(start, this.offset);
|
||||
return utils.readU32BE(utils.checksum(data), 0);
|
||||
return utils.readU32(utils.checksum(data), 0);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -509,7 +509,7 @@ BufferReader.prototype.createChecksum = function createChecksum() {
|
||||
|
||||
BufferReader.prototype.verifyChecksum = function verifyChecksum() {
|
||||
var chk = this.createChecksum();
|
||||
var checksum = this.readU32BE();
|
||||
var checksum = this.readU32();
|
||||
assert(chk === checksum, 'Checksum mismatch.');
|
||||
return checksum;
|
||||
};
|
||||
|
||||
1
test/data/tx4.hex
Normal file
1
test/data/tx4.hex
Normal file
@ -0,0 +1 @@
|
||||
01000000018759d7397a86d6c42dfe2c55612e523d171e51708fec9e289118deb5ba99400101000000dc00493046022100da3264579decba370d0b5d896c5f4664dfdf06119cc3ca5cef937389e61b5bf1022100a5584aa704578d35080129edb22d2bea7a24f16f0603cc22a9390cdc0a8f6e6301483045022018478cf5c7ef4cf0b0b6583937bba83b76bf87461825f44130dbb854111a62d8022100e431be966081676b2d785a3260e2a50e250d8a2f5d8364309fe1195dfa87a31d01475221030c341a91e5de82732d6bfb1c3676585b817096cd8bf076cf0ea88c339b9815072102f3f450d36aced52de6023ca5e9d7e256d5c5183f3316211d53bb151c3585222e52ae000000000104c70300000000001976a914a532649591196c7ff3ebd5783c29c9a08d54a3a288ac370c05004a0c0500749180fd60334bdcbb7cfadad26ca3746367047cdd218635b315380200000000010000000db72b550000000001290100000098d9040014ee03000000000017a914195bde4cd150acf910b5c83a024fd2d9f33306af8700
|
||||
@ -61,7 +61,6 @@ var vector2 = {
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
describe('HD', function() {
|
||||
var phrase = 'volume doll flush federal inflict tomato result property total curtain shield aisle';
|
||||
|
||||
@ -161,6 +160,7 @@ describe('HD', function() {
|
||||
}
|
||||
|
||||
function equal(a, b) {
|
||||
assert.equal(a, b);
|
||||
assert.equal(ub58(a), ub58(b));
|
||||
}
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ var fs = require('fs');
|
||||
var tx1 = parseTX('data/tx1.hex');
|
||||
var tx2 = parseTX('data/tx2.hex');
|
||||
var tx3 = parseTX('data/tx3.hex');
|
||||
var tx4 = parseExtended('data/tx4.hex');
|
||||
|
||||
function parseTX(file) {
|
||||
file = fs.readFileSync(__dirname + '/' + file, 'utf8').trim().split(/\n+/);
|
||||
@ -22,6 +23,11 @@ function parseTX(file) {
|
||||
return tx;
|
||||
}
|
||||
|
||||
function parseExtended(file) {
|
||||
file = fs.readFileSync(__dirname + '/' + file, 'utf8').trim();
|
||||
return bcoin.tx.fromExtended(file, 'hex', true);
|
||||
}
|
||||
|
||||
function clearCache(tx, nocache) {
|
||||
var i, input, output;
|
||||
|
||||
@ -127,6 +133,11 @@ describe('TX', function() {
|
||||
assert(tx3.verify(null, true, constants.flags.VERIFY_P2SH));
|
||||
});
|
||||
|
||||
it('should verify high S value with only DERSIG enabled' + suffix, function() {
|
||||
clearCache(tx4, nocache);
|
||||
assert(tx4.verify(0, true, constants.flags.VERIFY_P2SH | constants.flags.VERIFY_DERSIG));
|
||||
});
|
||||
|
||||
function parseTest(data) {
|
||||
var coins = data[0];
|
||||
var tx = bcoin.tx.fromRaw(data[1], 'hex');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user