fuck slashes.
This commit is contained in:
parent
b77c0995ba
commit
fbce69dbad
@ -1012,7 +1012,7 @@ HDPrivateKey.prototype.derive = function derive(index, hardened) {
|
|||||||
HDPrivateKey.prototype.getID = function getID(index) {
|
HDPrivateKey.prototype.getID = function getID(index) {
|
||||||
return this.network.keyPrefix.xprivkey58
|
return this.network.keyPrefix.xprivkey58
|
||||||
+ this.publicKey.toString('hex')
|
+ this.publicKey.toString('hex')
|
||||||
+ '/' + index;
|
+ index;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1663,7 +1663,7 @@ HDPublicKey.prototype.derive = function derive(index, hardened) {
|
|||||||
HDPublicKey.prototype.getID = function getID(index) {
|
HDPublicKey.prototype.getID = function getID(index) {
|
||||||
return this.network.keyPrefix.xpubkey58
|
return this.network.keyPrefix.xpubkey58
|
||||||
+ this.publicKey.toString('hex')
|
+ this.publicKey.toString('hex')
|
||||||
+ '/' + index;
|
+ index;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -2118,7 +2118,7 @@ function mergeSigs(a, b) {
|
|||||||
for (i = 0; i < b.inputs.length; i++) {
|
for (i = 0; i < b.inputs.length; i++) {
|
||||||
input = b.inputs[i];
|
input = b.inputs[i];
|
||||||
prev = input.prevout;
|
prev = input.prevout;
|
||||||
key = prev.hash + '/' + prev.index;
|
key = prev.hash + prev.index;
|
||||||
map[key] = input;
|
map[key] = input;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2126,7 +2126,7 @@ function mergeSigs(a, b) {
|
|||||||
ia = a.inputs[i];
|
ia = a.inputs[i];
|
||||||
if (!ia || ia.length !== 0)
|
if (!ia || ia.length !== 0)
|
||||||
break;
|
break;
|
||||||
key = prev.hash + '/' + prev.index;
|
key = prev.hash + prev.index;
|
||||||
ib = map[key];
|
ib = map[key];
|
||||||
if (ib)
|
if (ib)
|
||||||
ia.script = ib.script;
|
ia.script = ib.script;
|
||||||
|
|||||||
@ -972,7 +972,7 @@ TX.prototype.fillCoins = function fillCoins(coins) {
|
|||||||
} else if (coin instanceof bcoin.coin) {
|
} else if (coin instanceof bcoin.coin) {
|
||||||
assert(typeof coin.hash === 'string');
|
assert(typeof coin.hash === 'string');
|
||||||
assert(typeof coin.index === 'number');
|
assert(typeof coin.index === 'number');
|
||||||
map[coin.hash + '/' + coin.index] = coin;
|
map[coin.hash + coin.index] = coin;
|
||||||
} else {
|
} else {
|
||||||
assert(false, 'Non-coin object passed to fillCoins.');
|
assert(false, 'Non-coin object passed to fillCoins.');
|
||||||
}
|
}
|
||||||
@ -995,7 +995,7 @@ TX.prototype.fillCoins = function fillCoins(coins) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
coin = coins[hash + '/' + index];
|
coin = coins[hash + index];
|
||||||
|
|
||||||
if (coin) {
|
if (coin) {
|
||||||
input.coin = coin;
|
input.coin = coin;
|
||||||
@ -1195,7 +1195,7 @@ TX.prototype.isSane = function isSane(ret) {
|
|||||||
|
|
||||||
for (i = 0; i < this.inputs.length; i++) {
|
for (i = 0; i < this.inputs.length; i++) {
|
||||||
input = this.inputs[i];
|
input = this.inputs[i];
|
||||||
key = input.prevout.hash + '/' + input.prevout.index;
|
key = input.prevout.hash + input.prevout.index;
|
||||||
if (prevout[key]) {
|
if (prevout[key]) {
|
||||||
ret.reason = 'bad-txns-inputs-duplicate';
|
ret.reason = 'bad-txns-inputs-duplicate';
|
||||||
ret.score = 100;
|
ret.score = 100;
|
||||||
|
|||||||
@ -780,7 +780,7 @@ TXDB.prototype.add = function add(tx, info, callback) {
|
|||||||
if (!path)
|
if (!path)
|
||||||
return next();
|
return next();
|
||||||
|
|
||||||
key = prevout.hash + '/' + prevout.index;
|
key = prevout.hash + prevout.index;
|
||||||
|
|
||||||
// s/[outpoint-key] -> [spender-hash]|[spender-input-index]
|
// s/[outpoint-key] -> [spender-hash]|[spender-input-index]
|
||||||
outpoint = bcoin.outpoint.fromTX(tx, i).toRaw();
|
outpoint = bcoin.outpoint.fromTX(tx, i).toRaw();
|
||||||
@ -807,7 +807,7 @@ TXDB.prototype.add = function add(tx, info, callback) {
|
|||||||
// Add unspent outputs or resolve orphans
|
// Add unspent outputs or resolve orphans
|
||||||
utils.forEachSerial(tx.outputs, function(output, next, i) {
|
utils.forEachSerial(tx.outputs, function(output, next, i) {
|
||||||
var address = output.getHash('hex');
|
var address = output.getHash('hex');
|
||||||
var key = hash + '/' + i;
|
var key = hash + i;
|
||||||
var coin;
|
var coin;
|
||||||
|
|
||||||
path = info.getPath(address);
|
path = info.getPath(address);
|
||||||
@ -1054,7 +1054,7 @@ TXDB.prototype._confirm = function _confirm(tx, info, callback) {
|
|||||||
|
|
||||||
utils.forEachSerial(tx.outputs, function(output, next, i) {
|
utils.forEachSerial(tx.outputs, function(output, next, i) {
|
||||||
var address = output.getHash('hex');
|
var address = output.getHash('hex');
|
||||||
var key = hash + '/' + i;
|
var key = hash + i;
|
||||||
|
|
||||||
// Only update coins if this output is ours.
|
// Only update coins if this output is ours.
|
||||||
if (!info.hasPath(address))
|
if (!info.hasPath(address))
|
||||||
@ -1180,7 +1180,7 @@ TXDB.prototype._remove = function remove(tx, info, callback) {
|
|||||||
|
|
||||||
for (i = 0; i < tx.inputs.length; i++) {
|
for (i = 0; i < tx.inputs.length; i++) {
|
||||||
input = tx.inputs[i];
|
input = tx.inputs[i];
|
||||||
key = input.prevout.hash + '/' + input.prevout.index;
|
key = input.prevout.hash + input.prevout.index;
|
||||||
var prevout = input.prevout;
|
var prevout = input.prevout;
|
||||||
address = input.getHash('hex');
|
address = input.getHash('hex');
|
||||||
|
|
||||||
@ -1210,7 +1210,7 @@ TXDB.prototype._remove = function remove(tx, info, callback) {
|
|||||||
|
|
||||||
for (i = 0; i < tx.outputs.length; i++) {
|
for (i = 0; i < tx.outputs.length; i++) {
|
||||||
output = tx.outputs[i];
|
output = tx.outputs[i];
|
||||||
key = hash + '/' + i;
|
key = hash + i;
|
||||||
address = output.getHash('hex');
|
address = output.getHash('hex');
|
||||||
|
|
||||||
path = info.getPath(address);
|
path = info.getPath(address);
|
||||||
@ -1314,7 +1314,7 @@ TXDB.prototype._unconfirm = function unconfirm(tx, info, callback, force) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
utils.forEachSerial(tx.outputs, function(output, next, i) {
|
utils.forEachSerial(tx.outputs, function(output, next, i) {
|
||||||
var key = hash + '/' + i;
|
var key = hash + i;
|
||||||
self.getCoin(hash, i, function(err, coin) {
|
self.getCoin(hash, i, function(err, coin) {
|
||||||
if (err)
|
if (err)
|
||||||
return next(err);
|
return next(err);
|
||||||
@ -1769,7 +1769,7 @@ TXDB.prototype.getCoins = function getCoins(account, callback) {
|
|||||||
var coin = bcoin.coin.fromRaw(data);
|
var coin = bcoin.coin.fromRaw(data);
|
||||||
coin.hash = hash;
|
coin.hash = hash;
|
||||||
coin.index = index;
|
coin.index = index;
|
||||||
key = hash + '/' + index;
|
key = hash + index;
|
||||||
self.coinCache.set(key, data);
|
self.coinCache.set(key, data);
|
||||||
return coin;
|
return coin;
|
||||||
}
|
}
|
||||||
@ -1980,7 +1980,7 @@ TXDB.prototype.hasTX = function hasTX(hash, callback) {
|
|||||||
|
|
||||||
TXDB.prototype.getCoin = function getCoin(hash, index, callback) {
|
TXDB.prototype.getCoin = function getCoin(hash, index, callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var key = hash + '/' + index;
|
var key = hash + index;
|
||||||
var coin = this.coinCache.get(key);
|
var coin = this.coinCache.get(key);
|
||||||
|
|
||||||
if (coin) {
|
if (coin) {
|
||||||
@ -2010,7 +2010,7 @@ TXDB.prototype.getCoin = function getCoin(hash, index, callback) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
TXDB.prototype.hasCoin = function hasCoin(hash, index, callback) {
|
TXDB.prototype.hasCoin = function hasCoin(hash, index, callback) {
|
||||||
var key = hash + '/' + index;
|
var key = hash + index;
|
||||||
|
|
||||||
if (this.coinCache.has(key))
|
if (this.coinCache.has(key))
|
||||||
return callback(null, true);
|
return callback(null, true);
|
||||||
@ -2065,7 +2065,7 @@ TXDB.prototype.getBalance = function getBalance(account, callback) {
|
|||||||
else
|
else
|
||||||
balance.confirmed += value;
|
balance.confirmed += value;
|
||||||
|
|
||||||
key = hash + '/' + index;
|
key = hash + index;
|
||||||
|
|
||||||
self.coinCache.set(key, data);
|
self.coinCache.set(key, data);
|
||||||
}
|
}
|
||||||
@ -2107,7 +2107,7 @@ TXDB.prototype.getAccountBalance = function getBalance(account, callback) {
|
|||||||
return callback(err);
|
return callback(err);
|
||||||
|
|
||||||
utils.forEachSerial(hashes, function(hash, next) {
|
utils.forEachSerial(hashes, function(hash, next) {
|
||||||
key = hash[0] + '/' + hash[1];
|
key = hash[0] + hash[1];
|
||||||
coin = self.coinCache.get(key);
|
coin = self.coinCache.get(key);
|
||||||
|
|
||||||
if (coin) {
|
if (coin) {
|
||||||
|
|||||||
@ -737,7 +737,7 @@ WalletDB.prototype.getAccount = function getAccount(wid, name, callback) {
|
|||||||
|
|
||||||
WalletDB.prototype._getAccount = function getAccount(wid, index, callback) {
|
WalletDB.prototype._getAccount = function getAccount(wid, index, callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var key = pad32(wid) + '/' + pad32(index);
|
var key = wid + '/' + index;
|
||||||
var account = this.accountCache.get(key);
|
var account = this.accountCache.get(key);
|
||||||
|
|
||||||
if (account)
|
if (account)
|
||||||
@ -822,7 +822,7 @@ WalletDB.prototype.getAccountIndex = function getAccountIndex(wid, name, callbac
|
|||||||
WalletDB.prototype.saveAccount = function saveAccount(account) {
|
WalletDB.prototype.saveAccount = function saveAccount(account) {
|
||||||
var batch = this.batch(account.wid);
|
var batch = this.batch(account.wid);
|
||||||
var index = new Buffer(4);
|
var index = new Buffer(4);
|
||||||
var key = pad32(account.wid) + '/' + pad32(account.accountIndex);
|
var key = account.wid + '/' + account.accountIndex;
|
||||||
|
|
||||||
index.writeUInt32LE(account.accountIndex, 0, true);
|
index.writeUInt32LE(account.accountIndex, 0, true);
|
||||||
|
|
||||||
@ -893,7 +893,7 @@ WalletDB.prototype.hasAccount = function hasAccount(wid, account, callback) {
|
|||||||
if (index === -1)
|
if (index === -1)
|
||||||
return callback(null, false);
|
return callback(null, false);
|
||||||
|
|
||||||
key = pad32(wid) + '/' + pad32(index);
|
key = wid + '/' + index;
|
||||||
|
|
||||||
if (self.accountCache.has(key))
|
if (self.accountCache.has(key))
|
||||||
return callback(null, true);
|
return callback(null, true);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user