diff --git a/cashtab/src/components/Common/Ticker.js b/cashtab/src/components/Common/Ticker.js --- a/cashtab/src/components/Common/Ticker.js +++ b/cashtab/src/components/Common/Ticker.js @@ -103,6 +103,7 @@ airdrop: '64726f70', aliasRegistration: '2e786563', }, + tokenGenesisMaxByteCount: 180, /* encryptedMsgByteLimit context: As per `convertToEncryptStruct()` in cashMethods.js which breaks down the ecies-lite library's encryption logic, the encrypted OP_RETURN message that follows pushdata1 (4c) and pushdata (d1) prefixes is 209 bytes, based on a 127 byte message supplied via the frontend. These 209 bytes can be broken down into the following: diff --git a/cashtab/src/utils/__tests__/cashMethods.test.js b/cashtab/src/utils/__tests__/cashMethods.test.js --- a/cashtab/src/utils/__tests__/cashMethods.test.js +++ b/cashtab/src/utils/__tests__/cashMethods.test.js @@ -887,7 +887,7 @@ mockCreateTokenTxBuilderObj.toString(), ); expect(tokenInputObj.remainderXecValue).toStrictEqual( - new BigNumber(698999), // tokenInputObj.inputXecUtxos - currency.etokenSats 546 - txFee + new BigNumber(698637), // tokenInputObj.inputXecUtxos - currency.etokenSats 546 - txFee ); }); diff --git a/cashtab/src/utils/__tests__/transactions.test.js b/cashtab/src/utils/__tests__/transactions.test.js --- a/cashtab/src/utils/__tests__/transactions.test.js +++ b/cashtab/src/utils/__tests__/transactions.test.js @@ -383,6 +383,29 @@ ); }); + it('creates a token correctly using max length inputs', async () => { + const { expectedTxId, wallet } = createTokenMock; + const configObj = { + name: 'maxtokennameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', + ticker: 'dddddddddddd', + documentUrl: + 'https://www.longurl.com/asdfasdfasdfddddddddddddddddddddddddddddddd', + decimals: '9', + initialQty: '10000000000', + documentHash: '', + mintBatonVout: null, + }; + const chronik = new ChronikClient( + 'https://FakeChronikUrlToEnsureMocksOnly.com', + ); + chronik.broadcastTx = jest + .fn() + .mockResolvedValue({ txid: expectedTxId }); + expect(await createToken(chronik, wallet, 5.01, configObj)).toBe( + `${currency.blockExplorerUrl}/tx/${expectedTxId}`, + ); + }); + it('Throws correct error if user attempts to create a token with an invalid wallet', async () => { const { invalidWallet, configObj } = createTokenMock; const chronik = new ChronikClient( diff --git a/cashtab/src/utils/cashMethods.js b/cashtab/src/utils/cashMethods.js --- a/cashtab/src/utils/cashMethods.js +++ b/cashtab/src/utils/cashMethods.js @@ -483,7 +483,12 @@ txBuilder.addInput(txid, vout); totalXecInputUtxos.push(thisXecUtxo); - txFee = calcFee(totalXecInputUtxos, txOutputs, feeInSatsPerByte); + txFee = calcFee( + totalXecInputUtxos, + txOutputs, + feeInSatsPerByte, + currency.opReturn.tokenGenesisMaxByteCount, + ); remainderXecValue = tokenAction === 'GENESIS'