lib: update bn.js and elliptic
This commit is contained in:
parent
048bca0b8a
commit
26516085f2
@ -74,7 +74,7 @@ TXPool.prototype.add = function add(tx, noWrite) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Add orphan, if no parent transaction is yet known
|
// Add orphan, if no parent transaction is yet known
|
||||||
this._orphans[key] = { tx: tx, index: i };
|
this._orphans[key] = { tx: tx, index: input.out.index };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!own)
|
if (!own)
|
||||||
|
|||||||
@ -17,6 +17,7 @@ function TX(data, block) {
|
|||||||
this.outputs = [];
|
this.outputs = [];
|
||||||
this.lock = data.lock || 0;
|
this.lock = data.lock || 0;
|
||||||
this.ts = data.ts || 0;
|
this.ts = data.ts || 0;
|
||||||
|
this.funds = new bn(0);
|
||||||
|
|
||||||
this._hash = null;
|
this._hash = null;
|
||||||
this._raw = data._raw || null;
|
this._raw = data._raw || null;
|
||||||
@ -77,6 +78,9 @@ TX.prototype.input = function input(i, index) {
|
|||||||
seq: i.seq === undefined ? 0xffffffff : i.seq
|
seq: i.seq === undefined ? 0xffffffff : i.seq
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (input.out.tx)
|
||||||
|
this.funds.iadd(input.out.tx.outputs[input.out.index].value);
|
||||||
|
|
||||||
// Try modifying existing input first
|
// Try modifying existing input first
|
||||||
for (var i = 0; i < this.inputs.length; i++) {
|
for (var i = 0; i < this.inputs.length; i++) {
|
||||||
var ex = this.inputs[i];
|
var ex = this.inputs[i];
|
||||||
|
|||||||
@ -60,7 +60,7 @@ utils.toBase58 = function toBase58(arr) {
|
|||||||
var r = n.mod(mod);
|
var r = n.mod(mod);
|
||||||
n = n.div(mod);
|
n = n.div(mod);
|
||||||
|
|
||||||
var end = n.cmp(0) === 0;
|
var end = n.cmpn(0) === 0;
|
||||||
|
|
||||||
assert.equal(r.length, 1);
|
assert.equal(r.length, 1);
|
||||||
r = r.words[0];
|
r = r.words[0];
|
||||||
@ -106,7 +106,7 @@ utils.fromBase58 = function fromBase58(str) {
|
|||||||
w *= 58;
|
w *= 58;
|
||||||
w += c;
|
w += c;
|
||||||
if (i === str.length - 1 || q === 0xacad10) {
|
if (i === str.length - 1 || q === 0xacad10) {
|
||||||
res = res.mul(q).add(w);
|
res = res.mul(new bn(q)).add(new bn(w));
|
||||||
q = 1;
|
q = 1;
|
||||||
w = 0;
|
w = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,8 +22,8 @@
|
|||||||
"homepage": "https://github.com/indutny/bcoin",
|
"homepage": "https://github.com/indutny/bcoin",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": "^0.8.0",
|
"async": "^0.8.0",
|
||||||
"bn.js": "^0.3.0",
|
"bn.js": "^0.4.0",
|
||||||
"elliptic": "^0.9.0",
|
"elliptic": "^0.10.0",
|
||||||
"hash.js": "^0.2.0"
|
"hash.js": "^0.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@ -85,6 +85,13 @@ describe('Wallet', function() {
|
|||||||
var t4 = bcoin.tx().input(t2.hash(), 1)
|
var t4 = bcoin.tx().input(t2.hash(), 1)
|
||||||
.input(t3.hash(), 0)
|
.input(t3.hash(), 0)
|
||||||
.out(w, 22000);
|
.out(w, 22000);
|
||||||
|
|
||||||
|
// Just for debugging
|
||||||
|
t1.hint = 't1';
|
||||||
|
t2.hint = 't2';
|
||||||
|
t3.hint = 't3';
|
||||||
|
t4.hint = 't4';
|
||||||
|
|
||||||
w.addTX(t4);
|
w.addTX(t4);
|
||||||
assert.equal(w.balance().toString(10), '22000');
|
assert.equal(w.balance().toString(10), '22000');
|
||||||
w.addTX(t1);
|
w.addTX(t1);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user