witness parsing.
This commit is contained in:
parent
aff7c0e360
commit
96a92ae29b
@ -24,8 +24,6 @@ function Input(options, tx) {
|
||||
this.script = options.script || new bcoin.script([]);
|
||||
this.sequence = options.sequence == null ? 0xffffffff : options.sequence;
|
||||
this.witness = options.witness || new bcoin.script.witness([]);
|
||||
this._witnessSize = options._witnessSize || 0;
|
||||
this._witnessOffset = options._witnessOffset || 0;
|
||||
this._mutable = !tx || (tx instanceof bcoin.mtx);
|
||||
|
||||
if (options.output)
|
||||
@ -293,7 +291,7 @@ Input._fromExtended = function _fromExtended(data, enc) {
|
||||
p = new BufferReader(data);
|
||||
p.start();
|
||||
input = bcoin.protocol.parser.parseInput(p);
|
||||
input.witness = bcoin.protocol.parser.parseWitness(p).witness;
|
||||
input.witness = bcoin.protocol.parser.parseWitness(p);
|
||||
p.end();
|
||||
|
||||
return input;
|
||||
|
||||
@ -589,7 +589,7 @@ Parser.parseWitnessTX = function parseWitnessTX(p) {
|
||||
|
||||
for (i = 0; i < inCount; i++) {
|
||||
tx = Parser.parseWitness(p);
|
||||
txIn[i].witness = tx.witness;
|
||||
txIn[i].witness = tx;
|
||||
witnessSize += tx._size;
|
||||
}
|
||||
|
||||
@ -611,8 +611,8 @@ Parser.parseWitnessTX = function parseWitnessTX(p) {
|
||||
};
|
||||
|
||||
Parser.parseWitness = function parseWitness(p) {
|
||||
var witness = [];
|
||||
var chunkCount, i;
|
||||
var items = [];
|
||||
var witness, chunkCount, i;
|
||||
|
||||
p = new BufferReader(p);
|
||||
p.start();
|
||||
@ -620,12 +620,12 @@ Parser.parseWitness = function parseWitness(p) {
|
||||
chunkCount = p.readVarint();
|
||||
|
||||
for (i = 0; i < chunkCount; i++)
|
||||
witness.push(p.readVarBytes());
|
||||
items.push(p.readVarBytes());
|
||||
|
||||
return {
|
||||
witness: new bcoin.script.witness(witness),
|
||||
_size: p.end()
|
||||
};
|
||||
witness = new bcoin.script.witness(items);
|
||||
witness._size = p.end();
|
||||
|
||||
return witness;
|
||||
};
|
||||
|
||||
Parser.parseReject = function parseReject(p) {
|
||||
|
||||
@ -36,7 +36,7 @@ Witness.encode = function encode(witness) {
|
||||
};
|
||||
|
||||
Witness.decode = function decode(buf) {
|
||||
return bcoin.protocol.parser.parseWitness(buf).witness.items;
|
||||
return bcoin.protocol.parser.parseWitness(buf).items;
|
||||
};
|
||||
|
||||
Witness.prototype.clone = function clone() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user