Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/utils/cashMethods.js
Show First 20 Lines • Show All 209 Lines • ▼ Show 20 Lines | export const calcFee = ( | ||||
satoshisPerByte = currency.defaultFee, | satoshisPerByte = currency.defaultFee, | ||||
) => { | ) => { | ||||
const byteCount = getCashtabByteCount(utxos.length, p2pkhOutputNumber); | const byteCount = getCashtabByteCount(utxos.length, p2pkhOutputNumber); | ||||
const txFee = Math.ceil(satoshisPerByte * byteCount); | const txFee = Math.ceil(satoshisPerByte * byteCount); | ||||
return txFee; | return txFee; | ||||
}; | }; | ||||
export const generateTokenTxOutput = ( | export const generateTokenTxOutput = ( | ||||
BCH, | |||||
txBuilder, | txBuilder, | ||||
tokenAction, | tokenAction, | ||||
legacyCashOriginAddress, | legacyCashOriginAddress, | ||||
tokenUtxosBeingSpent = [], // optional - send or burn tx only | tokenUtxosBeingSpent = [], // optional - send or burn tx only | ||||
remainderXecValue = new BigNumber(0), // optional - only if > dust | remainderXecValue = new BigNumber(0), // optional - only if > dust | ||||
tokenConfigObj = {}, // optional - genesis only | tokenConfigObj = {}, // optional - genesis only | ||||
tokenRecipientAddress = false, // optional - send tx only | tokenRecipientAddress = false, // optional - send tx only | ||||
tokenAmount = false, // optional - send or burn amount for send/burn tx only | tokenAmount = false, // optional - send or burn amount for send/burn tx only | ||||
) => { | ) => { | ||||
try { | try { | ||||
if (!BCH || !tokenAction || !legacyCashOriginAddress || !txBuilder) { | if (!tokenAction || !legacyCashOriginAddress || !txBuilder) { | ||||
throw new Error('Invalid token tx output parameter'); | throw new Error('Invalid token tx output parameter'); | ||||
} | } | ||||
let script, opReturnObj, destinationAddress; | let script, opReturnObj, destinationAddress; | ||||
switch (tokenAction) { | switch (tokenAction) { | ||||
case 'GENESIS': | case 'GENESIS': | ||||
script = generateGenesisOpReturn(tokenConfigObj); | script = generateGenesisOpReturn(tokenConfigObj); | ||||
destinationAddress = legacyCashOriginAddress; | destinationAddress = legacyCashOriginAddress; | ||||
▲ Show 20 Lines • Show All 991 Lines • Show Last 20 Lines |