Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(new Opcode(opCodes[1]).toString() === new Opcode(Opcode.OP_RIPEMD160).toString()) &&
(parseInt(opCodes[2]) === 20) &&
(new Opcode(opCodes[3]).toString() === new Opcode(Opcode.OP_EQUALVERIFY).toString()) &&
(new Opcode(opCodes[4]).toString() === new Opcode(Opcode.OP_DUP).toString()) &&
(new Opcode(opCodes[5]).toString() === new Opcode(Opcode.OP_HASH160).toString()) &&
(parseInt(opCodes[6]) === 20) &&
(new Opcode(opCodes[7]).toString() === new Opcode(Opcode.OP_ELSE).toString()) &&
(parseInt(opCodes[8])) &&
(new Opcode(opCodes[9]).toString() === new Opcode(Opcode.OP_CHECKLOCKTIMEVERIFY).toString()) &&
(new Opcode(opCodes[10]).toString() === new Opcode(Opcode.OP_DROP).toString()) &&
(new Opcode(opCodes[11]).toString() === new Opcode(Opcode.OP_DUP).toString()) &&
(new Opcode(opCodes[12]).toString() === new Opcode(Opcode.OP_HASH160).toString()) &&
(parseInt(opCodes[13]) === 20) &&
(new Opcode(opCodes[14]).toString() === new Opcode(Opcode.OP_ENDIF).toString()) &&
(new Opcode(opCodes[15]).toString() === new Opcode(Opcode.OP_EQUALVERIFY).toString()) &&
(new Opcode(opCodes[16]).toString() === new Opcode(Opcode.OP_CHECKSIG).toString());
if (!isAtomicSwap) {
console.error('contract is not an atomic swap script!');
return;
}
const data = pops.filter(opcode => opcode.indexOf('0x') !== -1);
const secretHash = data[0];
const recipientHash = data[1];
const lockTime = data[2].replace('0x', '');
const refundHash160 = data[3];
return {
secretHash,
recipientHash,
(new Opcode(opCodes[1]).toString() === new Opcode(Opcode.OP_RIPEMD160).toString()) &&
(parseInt(opCodes[2]) === 20) &&
(new Opcode(opCodes[3]).toString() === new Opcode(Opcode.OP_EQUALVERIFY).toString()) &&
(new Opcode(opCodes[4]).toString() === new Opcode(Opcode.OP_DUP).toString()) &&
(new Opcode(opCodes[5]).toString() === new Opcode(Opcode.OP_HASH160).toString()) &&
(parseInt(opCodes[6]) === 20) &&
(new Opcode(opCodes[7]).toString() === new Opcode(Opcode.OP_ELSE).toString()) &&
(parseInt(opCodes[8])) &&
(new Opcode(opCodes[9]).toString() === new Opcode(Opcode.OP_CHECKLOCKTIMEVERIFY).toString()) &&
(new Opcode(opCodes[10]).toString() === new Opcode(Opcode.OP_DROP).toString()) &&
(new Opcode(opCodes[11]).toString() === new Opcode(Opcode.OP_DUP).toString()) &&
(new Opcode(opCodes[12]).toString() === new Opcode(Opcode.OP_HASH160).toString()) &&
(parseInt(opCodes[13]) === 20) &&
(new Opcode(opCodes[14]).toString() === new Opcode(Opcode.OP_ENDIF).toString()) &&
(new Opcode(opCodes[15]).toString() === new Opcode(Opcode.OP_EQUALVERIFY).toString()) &&
(new Opcode(opCodes[16]).toString() === new Opcode(Opcode.OP_CHECKSIG).toString());
if (!isAtomicSwap) {
console.error('contract is not an atomic swap script!')
return;
}
const data = pops.filter(opcode => opcode.indexOf('0x') !== -1);
const secretHash = data[0];
const recipientHash = data[1];
const lockTime = data[2].replace('0x', '');
const refundHash160 = data[3];
return {
secretHash,
recipientHash,
value: function payToPubKeyHashScript(pubKeyHash) {
var script = new Script();
script.add(Opcode.OP_DUP);
script.add(Opcode.OP_HASH160);
script.add(new Buffer(pubKeyHash, 'hex'));
script.add(Opcode.OP_EQUALVERIFY);
script.add(Opcode.OP_CHECKSIG);
return script;
}
}]);
script.add(Opcode.OP_DUP);
script.add(Opcode.OP_HASH160);
script.add(new Buffer(pkhThem, 'hex'));
script.add(Opcode.OP_ELSE);
script.add(new Buffer(decimalToHexString(conv(lockTime)[0]), 'hex'));
script.add('OP_CHECKLOCKTIMEVERIFY');
script.add(Opcode.OP_DROP);
script.add(Opcode.OP_DUP);
script.add(Opcode.OP_HASH160);
script.add(new Buffer(refundAddress, 'hex'));
script.add(Opcode.OP_ENDIF);
script.add(Opcode.OP_EQUALVERIFY);
script.add(Opcode.OP_CHECKSIG);
return script;
};
script.add(Opcode.OP_DUP);
script.add(Opcode.OP_HASH160);
script.add(new Buffer(pkhThem, 'hex'));
script.add(Opcode.OP_ELSE);
script.add(new Buffer(decimalToHexString(conv(lockTime)[0]), 'hex'));
script.add('OP_CHECKLOCKTIMEVERIFY');
script.add(Opcode.OP_DROP);
script.add(Opcode.OP_DUP);
script.add(Opcode.OP_HASH160);
script.add(new Buffer(refundAddress, 'hex'));
script.add(Opcode.OP_ENDIF);
script.add(Opcode.OP_EQUALVERIFY);
script.add(Opcode.OP_CHECKSIG);
return script;
}
}
script.add(Opcode.OP_DUP);
script.add(Opcode.OP_HASH160);
script.add(new Buffer(pkhThem, 'hex'));
script.add(Opcode.OP_ELSE);
script.add(new Buffer(String(lockTime), 'hex'));
script.add('OP_CHECKLOCKTIMEVERIFY');
script.add(Opcode.OP_DROP);
script.add(Opcode.OP_DUP);
script.add(Opcode.OP_HASH160);
script.add(new Buffer(refundAddress, 'hex'));
script.add(Opcode.OP_ENDIF);
script.add(Opcode.OP_EQUALVERIFY);
script.add(Opcode.OP_CHECKSIG);
return script;
};
script.add(Opcode.OP_DUP);
script.add(Opcode.OP_HASH160);
script.add(new Buffer(pkhThem, 'hex'));
script.add(Opcode.OP_ELSE);
script.add(new Buffer(decimalToHexString(conv(lockTime)[0]), 'hex'));
script.add('OP_CHECKLOCKTIMEVERIFY');
script.add(Opcode.OP_DROP);
script.add(Opcode.OP_DUP);
script.add(Opcode.OP_HASH160);
script.add(new Buffer(refundAddress, 'hex'));
script.add(Opcode.OP_ENDIF);
script.add(Opcode.OP_EQUALVERIFY);
script.add(Opcode.OP_CHECKSIG);
return script;
};
script.add(Opcode.OP_DUP);
script.add(Opcode.OP_HASH160);
script.add(Buffer.from(pkhThem));
script.add(Opcode.OP_ELSE);
script.add(Buffer.from(String(lockTime)));
script.add('OP_CHECKLOCKTIMEVERIFY');
script.add(Opcode.OP_DROP);
script.add(Opcode.OP_DUP);
script.add(Opcode.OP_HASH160);
script.add(Buffer.from(refundAddress));
script.add(Opcode.OP_ENDIF);
script.add(Opcode.OP_EQUALVERIFY);
script.add(Opcode.OP_CHECKSIG);
return script;
};