How to use the bitcore.Opcode.OP_DROP function in bitcore

To help you get started, we’ve selected a few bitcore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AltCoinExchange / altcoin-atomic-trading-platform / wallet-ts / src / common / contract.ts View on Github external
const contract = new Script(ct);
        const pops = contract.toString().split(' ');
        const opCodes = pops.filter(opcode => opcode.indexOf('0x') === -1);

        const isAtomicSwap =
          (new Opcode(opCodes[0]).toString() === new Opcode(Opcode.OP_IF).toString()) &&
          (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];
github AltCoinExchange / altcoin-atomic-trading-platform / legacy / btcatomicswap / src / contract / extract-atomic-swap-contract.js View on Github external
const contract = new Script(ct);
  const pops = contract.toString().split(' ');
  const opCodes = pops.filter(opcode => opcode.indexOf('0x') === -1);

  const isAtomicSwap =
    (new Opcode(opCodes[0]).toString() === new Opcode(Opcode.OP_IF).toString()) &&
    (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];
github AltCoinExchange / altcoin-atomic-trading-platform / btcatomicswap / dist / contract / atomic-swap-contract.js View on Github external
return number.toString(16).toUpperCase();
  };

  var script = new Script();
  script.add(Opcode.OP_IF);
  script.add(Opcode.OP_RIPEMD160);
  script.add(new Buffer(secretHash, 'hex'));
  script.add(Opcode.OP_EQUALVERIFY);
  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;
};
github AltCoinExchange / altcoin-atomic-trading-platform / btcatomicswap / dist / atomic-swap-contract.js View on Github external
var atomicSwapContract = exports.atomicSwapContract = function atomicSwapContract(refundAddress, pkhThem, lockTime, secretHash) {
  var script = new Script();
  script.add(Opcode.OP_IF);
  script.add(Opcode.OP_RIPEMD160);
  script.add(new Buffer(secretHash, 'hex'));
  script.add(Opcode.OP_EQUALVERIFY);
  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;
};
github AltCoinExchange / altcoin-atomic-trading-platform / wallet-ts / src / common / contract.ts View on Github external
return number.toString(16).toUpperCase();
        };

        const script = new Script();
        script.add(Opcode.OP_IF);
            script.add(Opcode.OP_RIPEMD160);
            script.add(new Buffer(secretHash, 'hex'));
            script.add(Opcode.OP_EQUALVERIFY);
            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;
    }
}
github AltCoinExchange / altcoin-atomic-trading-platform / btcatomicswap / src / contract / atomic-swap-contract.js View on Github external
export const atomicSwapContract = (refundAddress, pkhThem, lockTime, secretHash) => {
  const script = new Script();
  script.add(Opcode.OP_IF);
  script.add(Opcode.OP_RIPEMD160);
  script.add(Buffer.from(secretHash));
  script.add(Opcode.OP_EQUALVERIFY);
  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;
};
github AltCoinExchange / altcoin-atomic-trading-platform / legacy / btcatomicswap / src / contract / atomic-swap-contract.js View on Github external
return number.toString(16).toUpperCase();
  };

  const script = new Script();
  script.add(Opcode.OP_IF);
  script.add(Opcode.OP_RIPEMD160);
  script.add(new Buffer(secretHash, 'hex'));
  script.add(Opcode.OP_EQUALVERIFY);
  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;
};