make it impossible to "impersonate" blocks and txs.
This commit is contained in:
parent
e6f33b2793
commit
59ec8c54a2
@ -307,6 +307,8 @@ Bitcoin.prototype.close = function(callback) {
|
|||||||
* Block
|
* Block
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var _blockFlag = {};
|
||||||
|
|
||||||
function Block(data) {
|
function Block(data) {
|
||||||
if (!(this instanceof Block)) {
|
if (!(this instanceof Block)) {
|
||||||
return new Block(data);
|
return new Block(data);
|
||||||
@ -318,7 +320,7 @@ function Block(data) {
|
|||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this._isBlock = Block._blockFlag;
|
this._blockFlag = _blockFlag;
|
||||||
|
|
||||||
Object.keys(data).forEach(function(key) {
|
Object.keys(data).forEach(function(key) {
|
||||||
if (!self[key]) {
|
if (!self[key]) {
|
||||||
@ -331,10 +333,8 @@ function Block(data) {
|
|||||||
this.toHex();
|
this.toHex();
|
||||||
}
|
}
|
||||||
|
|
||||||
Block._blockFlag = {};
|
|
||||||
|
|
||||||
Block.isBlock = function(block) {
|
Block.isBlock = function(block) {
|
||||||
return block._isBlock === Block._blockFlag;
|
return block._blockFlag === _blockFlag;
|
||||||
};
|
};
|
||||||
|
|
||||||
// NOTE: Could just call tx.GetHash() in C++
|
// NOTE: Could just call tx.GetHash() in C++
|
||||||
@ -442,6 +442,8 @@ Block.toHex = function(block) {
|
|||||||
* Transaction
|
* Transaction
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var _txFlag = {};
|
||||||
|
|
||||||
function Transaction(data) {
|
function Transaction(data) {
|
||||||
if (!(this instanceof Transaction)) {
|
if (!(this instanceof Transaction)) {
|
||||||
return new Transaction(data);
|
return new Transaction(data);
|
||||||
@ -453,7 +455,7 @@ function Transaction(data) {
|
|||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this._isTx = Transaction._txFlag;
|
this._txFlag = _txFlag;
|
||||||
|
|
||||||
this.nMinTxFee = data.nMinTxFee || data.minTxFee || 1000;
|
this.nMinTxFee = data.nMinTxFee || data.minTxFee || 1000;
|
||||||
this.nMinRelayTxFee = data.nMinRelayTxFee || data.minRelayTxFee || 1000;
|
this.nMinRelayTxFee = data.nMinRelayTxFee || data.minRelayTxFee || 1000;
|
||||||
@ -481,11 +483,9 @@ function Transaction(data) {
|
|||||||
this.toHex();
|
this.toHex();
|
||||||
}
|
}
|
||||||
|
|
||||||
Transaction._txFlag = {};
|
|
||||||
|
|
||||||
Transaction.isTransaction =
|
Transaction.isTransaction =
|
||||||
Transaction.isTx = function(tx) {
|
Transaction.isTx = function(tx) {
|
||||||
return tx._isTx === Transaction._txFlag;
|
return tx._txFlag === _txFlag;
|
||||||
};
|
};
|
||||||
|
|
||||||
Transaction.prototype.verify = function() {
|
Transaction.prototype.verify = function() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user