script fixes.
This commit is contained in:
parent
e5a82c7195
commit
b1d46206a8
@ -145,12 +145,6 @@ Peer.prototype._init = function init() {
|
||||
}));
|
||||
}, this._ping.interval);
|
||||
|
||||
// Send hello
|
||||
this._write(this.framer.version({
|
||||
height: this.pool.chain.getStartHeight(),
|
||||
relay: this.options.relay
|
||||
}));
|
||||
|
||||
this._req('verack', function(err, payload) {
|
||||
if (err) {
|
||||
self._error(err);
|
||||
@ -162,6 +156,12 @@ Peer.prototype._init = function init() {
|
||||
self.ts = utils.now();
|
||||
self._write(self.framer.packet('getaddr', []));
|
||||
});
|
||||
|
||||
// Send hello
|
||||
this._write(this.framer.version({
|
||||
height: this.pool.chain.getStartHeight(),
|
||||
relay: this.options.relay
|
||||
}));
|
||||
};
|
||||
|
||||
Peer.prototype.broadcast = function broadcast(items) {
|
||||
|
||||
@ -1463,11 +1463,10 @@ Pool.prototype.usableSeed = function usableSeed(addrs, force) {
|
||||
|
||||
assert(addrs.length);
|
||||
|
||||
addrs = addrs.slice().sort(function() {
|
||||
return Math.random() > 0.50 ? 1 : -1;
|
||||
});
|
||||
|
||||
if (this.peers.load) {
|
||||
addrs = addrs.slice().sort(function() {
|
||||
return Math.random() > 0.50 ? 1 : -1;
|
||||
});
|
||||
for (i = 0; i < addrs.length; i++) {
|
||||
if (!this.getPeer(addrs[i]))
|
||||
return addrs[i];
|
||||
|
||||
@ -285,8 +285,8 @@ script._next = function _next(to, s, pc) {
|
||||
return -1;
|
||||
};
|
||||
|
||||
script.execute = function execute(s, stack, tx, index, flags, recurse) {
|
||||
s = s.slice();
|
||||
script.execute = function execute(data, stack, tx, index, flags, recurse) {
|
||||
var s = data.slice();
|
||||
|
||||
if (!flags)
|
||||
flags = {};
|
||||
@ -338,7 +338,6 @@ script.execute = function execute(s, stack, tx, index, flags, recurse) {
|
||||
}
|
||||
case 'if_':
|
||||
case 'notif': {
|
||||
val = false;
|
||||
if (stack.length < 1)
|
||||
return false;
|
||||
v = stack.pop();
|
||||
@ -468,10 +467,10 @@ script.execute = function execute(s, stack, tx, index, flags, recurse) {
|
||||
case 'swap': {
|
||||
if (stack.length < 2)
|
||||
return false;
|
||||
v2 = stack[stack.length - 2];
|
||||
v1 = stack[stack.length - 1];
|
||||
stack[stack.length - 2] = v1;
|
||||
stack[stack.length - 1] = v2;
|
||||
v1 = stack[stack.length - 2];
|
||||
v2 = stack[stack.length - 1];
|
||||
stack[stack.length - 2] = v2;
|
||||
stack[stack.length - 1] = v1;
|
||||
break;
|
||||
}
|
||||
case 'tuck': {
|
||||
@ -490,8 +489,8 @@ script.execute = function execute(s, stack, tx, index, flags, recurse) {
|
||||
case 'dup2': {
|
||||
if (stack.length < 2)
|
||||
return false;
|
||||
v1 = stack[stack.length - 1];
|
||||
v2 = stack[stack.length - 2];
|
||||
v1 = stack[stack.length - 2];
|
||||
v2 = stack[stack.length - 1];
|
||||
stack.push(v1);
|
||||
stack.push(v2);
|
||||
break;
|
||||
@ -499,9 +498,9 @@ script.execute = function execute(s, stack, tx, index, flags, recurse) {
|
||||
case 'dup3': {
|
||||
if (stack.length < 3)
|
||||
return false;
|
||||
v1 = stack[stack.length - 1];
|
||||
v1 = stack[stack.length - 3];
|
||||
v2 = stack[stack.length - 2];
|
||||
v3 = stack[stack.length - 3];
|
||||
v3 = stack[stack.length - 1];
|
||||
stack.push(v1);
|
||||
stack.push(v2);
|
||||
stack.push(v3);
|
||||
@ -751,7 +750,7 @@ script.execute = function execute(s, stack, tx, index, flags, recurse) {
|
||||
if (!constants.hashTypeByVal[type & 0x1f])
|
||||
return false;
|
||||
|
||||
subscript = script.subscript(s, lastSep);
|
||||
subscript = script.subscript(data, lastSep);
|
||||
script.removeData(subscript, sig);
|
||||
|
||||
hash = tx.signatureHash(index, subscript, type);
|
||||
@ -796,7 +795,7 @@ script.execute = function execute(s, stack, tx, index, flags, recurse) {
|
||||
if (stack.length < m + 1)
|
||||
return false;
|
||||
|
||||
subscript = script.subscript(s, lastSep);
|
||||
subscript = script.subscript(data, lastSep);
|
||||
|
||||
for (i = 0; i < m; i++) {
|
||||
sig = stack[stack.length - 1 - i];
|
||||
@ -804,7 +803,7 @@ script.execute = function execute(s, stack, tx, index, flags, recurse) {
|
||||
}
|
||||
|
||||
succ = 0;
|
||||
for (i = 0, j = 0; i < m && j < n; i++) {
|
||||
for (i = 0, j = 0; i < m; i++) {
|
||||
sig = stack.pop();
|
||||
|
||||
if (!script.isSignature(sig))
|
||||
|
||||
@ -606,11 +606,15 @@ TX.prototype.getSubscript = function getSubscript(index) {
|
||||
|
||||
TX.prototype.signatureHash = function signatureHash(index, s, type) {
|
||||
var copy = this.clone();
|
||||
var i, input, msg, hash;
|
||||
var i, msg, hash;
|
||||
|
||||
if (!Array.isArray(s)) {
|
||||
type = s;
|
||||
s = this.inputs[index].out.tx.getSubscript(this.inputs[index].out.index);
|
||||
if (bcoin.script.isScripthash(s)) {
|
||||
s = this.inputs[index].script[this.inputs[index.script.length - 1]];
|
||||
s = bcoin.script.subscript(bcoin.script.decode(s));
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof index !== 'number')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user