Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function translateOutputScriptType (scriptType: BTCOutputScriptType): any {
switch (scriptType) {
case BTCOutputScriptType.PayToAddress:
return OutputScriptType.PAYTOADDRESS
case BTCOutputScriptType.PayToMultisig:
return OutputScriptType.PAYTOMULTISIG
case BTCOutputScriptType.PayToP2SHWitness:
return OutputScriptType.PAYTOP2SHWITNESS
case BTCOutputScriptType.PayToWitness:
return OutputScriptType.PAYTOWITNESS
}
throw new Error('unhandled OutputSriptType enum: ' + scriptType)
}
outExchangeType.setWithdrawalScriptType(translateInputScriptType(
output.exchangeType.withdrawalScriptType || BTCInputScriptType.SpendAddress))
outExchangeType.setReturnAddressNList(output.exchangeType.returnAddressNList)
outExchangeType.setReturnScriptType(translateInputScriptType(
output.exchangeType.returnScriptType || BTCInputScriptType.SpendAddress))
newOutput.setAmount(val)
newOutput.setAddress(signedExchange.toObject().responsev2.depositAddress.address)
newOutput.setScriptType(OutputScriptType.PAYTOADDRESS)
newOutput.setAddressType(OutputAddressType.EXCHANGE)
newOutput.setExchangeType(outExchangeType)
} else if (output.isChange) {
newOutput.setScriptType(translateOutputScriptType(output.scriptType))
newOutput.setAddressNList(output.addressNList)
newOutput.setAddressType(OutputAddressType.CHANGE)
} else {
newOutput.setScriptType(OutputScriptType.PAYTOADDRESS)
newOutput.setAddress(output.address)
newOutput.setAddressType(OutputAddressType.SPEND)
}
unsignedTx.addOutputs(newOutput, k)
})