Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
createRefundableCollateralScript (borrowerPubKey, lenderPubKey, secretHashA2, secretHashB2, secretHashB3, loanExpiration, biddingExpiration) {
let loanExpirationHex = scriptNumEncode(loanExpiration)
let biddingExpirationHex = scriptNumEncode(biddingExpiration)
const borrowerPubKeyHash = hash160(borrowerPubKey)
const borrowerPubKeyPushDataOpcode = padHexStart((borrowerPubKey.length / 2).toString(16))
const lenderPubKeyPushDataOpcode = padHexStart((lenderPubKey.length / 2).toString(16))
const loanExpirationPushDataOpcode = padHexStart(loanExpirationHex.length.toString(16))
const loanExpirationHexEncoded = loanExpirationHex.toString('hex')
const biddingExpirationPushDataOpcode = padHexStart(biddingExpirationHex.length.toString(16))
const biddingExpirationHexEncoded = biddingExpirationHex.toString('hex')
return [
'63', // OP_IF
'82', // OP_SIZE
'01', // OP_PUSHDATA(1)
'20', // Hex 32
'88', // OP_EQUALVERIFY
'a8', // OP_SHA256
createSeizableCollateralScript (borrowerPubKey, lenderPubKey, secretHashA1, secretHashA2, secretHashB2, secretHashB3, loanExpiration, biddingExpiration, seizureExpiration) {
let loanExpirationHex = scriptNumEncode(loanExpiration)
let biddingExpirationHex = scriptNumEncode(biddingExpiration)
let seizureExpirationHex = scriptNumEncode(seizureExpiration)
const borrowerPubKeyHash = hash160(borrowerPubKey)
const borrowerPubKeyPushDataOpcode = padHexStart((borrowerPubKey.length / 2).toString(16))
const lenderPubKeyHash = hash160(lenderPubKey)
const lenderPubKeyPushDataOpcode = padHexStart((lenderPubKey.length / 2).toString(16))
const loanExpirationPushDataOpcode = padHexStart(loanExpirationHex.length.toString(16))
const loanExpirationHexEncoded = loanExpirationHex.toString('hex')
const biddingExpirationPushDataOpcode = padHexStart(biddingExpirationHex.length.toString(16))
const biddingExpirationHexEncoded = biddingExpirationHex.toString('hex')
const seizureExpirationPushDataOpcode = padHexStart(seizureExpirationHex.length.toString(16))
const seizureExpirationHexEncoded = seizureExpirationHex.toString('hex')
return [
'63', // OP_IF
'82', // OP_SIZE
'01', // OP_PUSHDATA(1)
createSeizableCollateralScript (borrowerPubKey, lenderPubKey, secretHashA1, secretHashA2, secretHashB2, secretHashB3, loanExpiration, biddingExpiration, seizureExpiration) {
let loanExpirationHex = scriptNumEncode(loanExpiration)
let biddingExpirationHex = scriptNumEncode(biddingExpiration)
let seizureExpirationHex = scriptNumEncode(seizureExpiration)
const borrowerPubKeyHash = hash160(borrowerPubKey)
const borrowerPubKeyPushDataOpcode = padHexStart((borrowerPubKey.length / 2).toString(16))
const lenderPubKeyHash = hash160(lenderPubKey)
const lenderPubKeyPushDataOpcode = padHexStart((lenderPubKey.length / 2).toString(16))
const loanExpirationPushDataOpcode = padHexStart(loanExpirationHex.length.toString(16))
const loanExpirationHexEncoded = loanExpirationHex.toString('hex')
const biddingExpirationPushDataOpcode = padHexStart(biddingExpirationHex.length.toString(16))
const biddingExpirationHexEncoded = biddingExpirationHex.toString('hex')
const seizureExpirationPushDataOpcode = padHexStart(seizureExpirationHex.length.toString(16))
const seizureExpirationHexEncoded = seizureExpirationHex.toString('hex')
return [
'63', // OP_IF
'82', // OP_SIZE
'01', // OP_PUSHDATA(1)
'20', // Hex 32
'88', // OP_EQUALVERIFY
'a8', // OP_SHA256