coins and input.
This commit is contained in:
parent
4cd018c31a
commit
2cbe8ff411
@ -190,7 +190,6 @@ Coins.prototype.toRaw = function toRaw(writer) {
|
|||||||
hash = output.script.code[1];
|
hash = output.script.code[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// p.writeU8(((output.spent ? 1 : 0) << 2) | prefix);
|
|
||||||
p.writeU8(prefix);
|
p.writeU8(prefix);
|
||||||
|
|
||||||
if (prefix)
|
if (prefix)
|
||||||
@ -215,17 +214,20 @@ Coins.prototype.toRaw = function toRaw(writer) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Coins.parseRaw = function parseRaw(data, hash) {
|
Coins.parseRaw = function parseRaw(data, hash) {
|
||||||
var coins = {};
|
|
||||||
var p = new BufferReader(data);
|
var p = new BufferReader(data);
|
||||||
var i = 0;
|
var i = 0;
|
||||||
var coin, mask, prefix;
|
var version, height, coins, coin, mask, prefix;
|
||||||
|
|
||||||
coins.version = p.readVarint();
|
version = p.readVarint();
|
||||||
coins.height = p.readU32();
|
height = p.readU32();
|
||||||
coins.hash = hash;
|
|
||||||
coins.coinbase = (coins.height & 1) !== 0;
|
coins = {
|
||||||
coins.height >>>= 1;
|
version: version,
|
||||||
coins.outputs = [];
|
height: height >>> 1,
|
||||||
|
hash: hash,
|
||||||
|
coinbase: (height & 1) !== 0,
|
||||||
|
outputs: []
|
||||||
|
};
|
||||||
|
|
||||||
if (coins.height === 0x7fffffff)
|
if (coins.height === 0x7fffffff)
|
||||||
coins.height = -1;
|
coins.height = -1;
|
||||||
@ -239,14 +241,16 @@ Coins.parseRaw = function parseRaw(data, hash) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
coin = {};
|
coin = {
|
||||||
coin.version = coins.version;
|
version: coins.version,
|
||||||
coin.coinbase = coins.coinbase;
|
coinbase: coins.coinbase,
|
||||||
coin.height = coins.height;
|
height: coins.height,
|
||||||
coin.hash = coins.hash;
|
hash: coins.hash,
|
||||||
coin.index = i++;
|
index: i++,
|
||||||
|
script: null,
|
||||||
|
value: null
|
||||||
|
};
|
||||||
|
|
||||||
// coin.spent = (mask & 4) !== 0;
|
|
||||||
prefix = mask & 3;
|
prefix = mask & 3;
|
||||||
|
|
||||||
if (prefix === 0)
|
if (prefix === 0)
|
||||||
@ -297,7 +301,6 @@ Coins.parseCoin = function parseCoin(data, hash, index) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// spent = (mask & 4) !== 0;
|
|
||||||
prefix = mask & 3;
|
prefix = mask & 3;
|
||||||
|
|
||||||
if (i !== index) {
|
if (i !== index) {
|
||||||
@ -329,7 +332,6 @@ Coins.parseCoin = function parseCoin(data, hash, index) {
|
|||||||
height: height,
|
height: height,
|
||||||
hash: hash,
|
hash: hash,
|
||||||
index: i,
|
index: i,
|
||||||
// spent: spent,
|
|
||||||
script: script,
|
script: script,
|
||||||
value: value
|
value: value
|
||||||
});
|
});
|
||||||
|
|||||||
@ -41,6 +41,7 @@ function Input(options, mutable) {
|
|||||||
this.script = bcoin.script(options.script, this.mutable);
|
this.script = bcoin.script(options.script, this.mutable);
|
||||||
this.sequence = options.sequence == null ? 0xffffffff : options.sequence;
|
this.sequence = options.sequence == null ? 0xffffffff : options.sequence;
|
||||||
this.witness = bcoin.witness(options.witness, this.mutable);
|
this.witness = bcoin.witness(options.witness, this.mutable);
|
||||||
|
this.coin = null;
|
||||||
|
|
||||||
if (options.coin)
|
if (options.coin)
|
||||||
this.coin = bcoin.coin(options.coin);
|
this.coin = bcoin.coin(options.coin);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user