rpc: add witness nonce for submitted blocks.
This commit is contained in:
parent
6d1eb9fd36
commit
2e26909e85
@ -1438,6 +1438,16 @@ RPC.prototype.submitblock = co(function* submitblock(args) {
|
||||
|
||||
block = Block.fromRaw(toString(args[0]), 'hex');
|
||||
|
||||
if (block.getCommitmentHash()) {
|
||||
if (!block.txs[0].hasWitness()) {
|
||||
this.logger.warning('Submitted block had no witness nonce.');
|
||||
this.logger.debug(block.txs[0]);
|
||||
block.txs[0].inputs[0].witness.set(0, constants.ZERO_HASH);
|
||||
block.txs[0].clearCache();
|
||||
block.clearCache();
|
||||
}
|
||||
}
|
||||
|
||||
return yield this._submitblock(block);
|
||||
});
|
||||
|
||||
|
||||
@ -57,7 +57,7 @@ function AbstractBlock(options) {
|
||||
this._hash = null;
|
||||
this._hhash = null;
|
||||
this._size = null;
|
||||
this._witnessSize = null;
|
||||
this._witness = null;
|
||||
|
||||
if (options)
|
||||
this.parseOptions(options);
|
||||
|
||||
@ -76,6 +76,20 @@ Block.fromOptions = function fromOptions(options) {
|
||||
return new Block().fromOptions(options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Clear any cached values.
|
||||
*/
|
||||
|
||||
Block.prototype.clearCache = function clearCache() {
|
||||
this._valid = null;
|
||||
this._validHeaders = null;
|
||||
this._hash = null;
|
||||
this._hhash = null;
|
||||
this._raw = null;
|
||||
this._size = -1;
|
||||
this._witness = -1;
|
||||
};
|
||||
|
||||
/**
|
||||
* Serialize the block. Include witnesses if present.
|
||||
* @returns {Buffer}
|
||||
|
||||
@ -140,6 +140,26 @@ TX.prototype.clone = function clone() {
|
||||
return new TX(this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Clear any cached values.
|
||||
*/
|
||||
|
||||
TX.prototype.clearCache = function clearCache() {
|
||||
this._hash = null;
|
||||
this._hhash = null;
|
||||
this._whash = null;
|
||||
|
||||
this._raw = null;
|
||||
this._size = -1;
|
||||
this._witness = -1;
|
||||
|
||||
this._outputValue = -1;
|
||||
this._inputValue = -1;
|
||||
this._hashPrevouts = null;
|
||||
this._hashSequence = null;
|
||||
this._hashOutputs = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Hash the transaction with the non-witness serialization.
|
||||
* @param {String?} enc - Can be `'hex'` or `null`.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user