Fixed bug in numToBytes and util -> conv
This commit is contained in:
parent
eb62360a49
commit
a753f069a5
3 changed files with 12 additions and 3 deletions
2
bitcoinjs-min.js
vendored
2
bitcoinjs-min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -398,7 +398,7 @@ Transaction.prototype.calcImpact = function (wallet) {
|
|||
if (wallet.hasHash(hash)) {
|
||||
var fromTx = wallet.txIndex[txin.outpoint.hash];
|
||||
if (fromTx) {
|
||||
valueIn = valueIn.add(util.valueToBigInt(fromTx.outs[txin.outpoint.index].value));
|
||||
valueIn = valueIn.add(conv.valueToBigInt(fromTx.outs[txin.outpoint.index].value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
11
src/util.js
11
src/util.js
|
@ -26,9 +26,18 @@ module.exports = {
|
|||
* Create a byte array representing a number with the given length
|
||||
*/
|
||||
numToBytes: function(num,bytes) {
|
||||
if (bytes == 0 || (bytes === undefined && num === 0)) return [];
|
||||
if (bytes === undefined) bytes = 8;
|
||||
if (bytes == 0) return [];
|
||||
else return [num % 256].concat(module.exports.numToBytes(Math.floor(num / 256),bytes-1));
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a byte array representing a number with the given length
|
||||
*/
|
||||
bytesToNum: function(bytes) {
|
||||
if (bytes.length == 0) return 0;
|
||||
else return bytes[0] + 256 * bytesToNum(bytes.slice(1));
|
||||
},
|
||||
/**
|
||||
* Turn an integer into a "var_int".
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue