coins and input.

This commit is contained in:
Christopher Jeffrey 2016-06-08 16:00:43 -07:00
parent 4cd018c31a
commit 2cbe8ff411
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 21 additions and 18 deletions

View File

@ -190,7 +190,6 @@ Coins.prototype.toRaw = function toRaw(writer) {
hash = output.script.code[1];
}
// p.writeU8(((output.spent ? 1 : 0) << 2) | prefix);
p.writeU8(prefix);
if (prefix)
@ -215,17 +214,20 @@ Coins.prototype.toRaw = function toRaw(writer) {
*/
Coins.parseRaw = function parseRaw(data, hash) {
var coins = {};
var p = new BufferReader(data);
var i = 0;
var coin, mask, prefix;
var version, height, coins, coin, mask, prefix;
coins.version = p.readVarint();
coins.height = p.readU32();
coins.hash = hash;
coins.coinbase = (coins.height & 1) !== 0;
coins.height >>>= 1;
coins.outputs = [];
version = p.readVarint();
height = p.readU32();
coins = {
version: version,
height: height >>> 1,
hash: hash,
coinbase: (height & 1) !== 0,
outputs: []
};
if (coins.height === 0x7fffffff)
coins.height = -1;
@ -239,14 +241,16 @@ Coins.parseRaw = function parseRaw(data, hash) {
continue;
}
coin = {};
coin.version = coins.version;
coin.coinbase = coins.coinbase;
coin.height = coins.height;
coin.hash = coins.hash;
coin.index = i++;
coin = {
version: coins.version,
coinbase: coins.coinbase,
height: coins.height,
hash: coins.hash,
index: i++,
script: null,
value: null
};
// coin.spent = (mask & 4) !== 0;
prefix = mask & 3;
if (prefix === 0)
@ -297,7 +301,6 @@ Coins.parseCoin = function parseCoin(data, hash, index) {
continue;
}
// spent = (mask & 4) !== 0;
prefix = mask & 3;
if (i !== index) {
@ -329,7 +332,6 @@ Coins.parseCoin = function parseCoin(data, hash, index) {
height: height,
hash: hash,
index: i,
// spent: spent,
script: script,
value: value
});

View File

@ -41,6 +41,7 @@ function Input(options, mutable) {
this.script = bcoin.script(options.script, this.mutable);
this.sequence = options.sequence == null ? 0xffffffff : options.sequence;
this.witness = bcoin.witness(options.witness, this.mutable);
this.coin = null;
if (options.coin)
this.coin = bcoin.coin(options.coin);