diff --git a/web/cashtab/src/components/Send/Send.js b/web/cashtab/src/components/Send/Send.js --- a/web/cashtab/src/components/Send/Send.js +++ b/web/cashtab/src/components/Send/Send.js @@ -130,7 +130,7 @@ chronik, } = ContextValue; const walletState = getWalletState(wallet); - const { balances, slpBalancesAndUtxos } = walletState; + const { balances, nonSlpUtxos } = walletState; // Modal settings const [isOneToManyXECSend, setIsOneToManyXECSend] = useState(false); const [opReturnMsg, setOpReturnMsg] = useState(false); @@ -337,7 +337,7 @@ const link = await sendXec( chronik, wallet, - slpBalancesAndUtxos.nonSlpUtxos, + nonSlpUtxos, currency.defaultFee, opReturnMsg, true, // indicate send mode is one to many @@ -398,7 +398,7 @@ const link = await sendXec( chronik, wallet, - slpBalancesAndUtxos.nonSlpUtxos, + nonSlpUtxos, currency.defaultFee, optionalOpReturnMsg, false, // sendToMany boolean flag @@ -576,7 +576,7 @@ // Set currency to BCH setSelectedCurrency(currency.ticker); try { - const txFeeSats = calcFee(slpBalancesAndUtxos.nonSlpUtxos); + const txFeeSats = calcFee(nonSlpUtxos); const txFeeBch = txFeeSats / 10 ** currency.cashDecimals; let value = diff --git a/web/cashtab/src/hooks/__mocks__/burnToken.js b/web/cashtab/src/hooks/__mocks__/burnToken.js new file mode 100644 --- /dev/null +++ b/web/cashtab/src/hooks/__mocks__/burnToken.js @@ -0,0 +1,682 @@ +export const burnTokenWallet = { + mnemonic: 'Nope', + name: 'TripDos', + Path245: { + cashAddress: 'bitcoincash:qq0mw6nah9huwaxt45qw3fegjpszkjlrqsvttwy36p', + slpAddress: 'simpleledger:qq0mw6nah9huwaxt45qw3fegjpszkjlrqsqsq433yl', + fundingWif: 'Nope', + fundingAddress: + 'simpleledger:qq0mw6nah9huwaxt45qw3fegjpszkjlrqsqsq433yl', + legacyAddress: '13thfuvhCA1dGE7nVgyU61BZfoD8ApXJsg', + }, + Path145: { + cashAddress: 'bitcoincash:qz5lf9pxde9neq3hzte8mmwts03sktl9nuz6m3dynu', + slpAddress: 'simpleledger:qz5lf9pxde9neq3hzte8mmwts03sktl9nuwps2cydz', + fundingWif: 'Nope', + fundingAddress: + 'simpleledger:qz5lf9pxde9neq3hzte8mmwts03sktl9nuwps2cydz', + legacyAddress: '1GVeC3gB6V3EStcQbJiry5BJn4fRdHjKyc', + }, + Path1899: { + cashAddress: 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + slpAddress: 'simpleledger:qz2708636snqhsxu8wnlka78h6fdp77ar5syue64fa', + fundingWif: 'Nope', + fundingAddress: + 'simpleledger:qz2708636snqhsxu8wnlka78h6fdp77ar5syue64fa', + legacyAddress: '1Efd9z9GRVJK2r73nUpFmBnsKUmfXNm2y2', + }, + state: { + balances: { + totalBalanceInSatoshis: '1503017804', + totalBalance: '15030178.04', + }, + tokens: [ + { + info: { + height: 680782, + tx_hash: + '525457276f1b6984170c9b35a8312d4988fce495723eabadd2afcdb3b872b2f1', + tx_pos: 1, + value: 546, + txid: '525457276f1b6984170c9b35a8312d4988fce495723eabadd2afcdb3b872b2f1', + vout: 1, + utxoType: 'token', + transactionType: 'send', + tokenId: + 'bf24d955f59351e738ecd905966606a6837e478e1982943d724eab10caad82fd', + tokenTicker: 'ST', + tokenName: 'ST', + tokenDocumentUrl: 'developer.bitcoin.com', + tokenDocumentHash: '', + decimals: 0, + tokenType: 1, + tokenQty: '1', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + tokenId: + 'bf24d955f59351e738ecd905966606a6837e478e1982943d724eab10caad82fd', + balance: { + s: 1, + e: 0, + c: [1], + }, + hasBaton: false, + }, + { + info: { + height: 680784, + tx_hash: + 'daa98a872b7d88fefd2257b006db001ef82a601f3943b92e0c753076598a7b75', + tx_pos: 1, + value: 546, + txid: 'daa98a872b7d88fefd2257b006db001ef82a601f3943b92e0c753076598a7b75', + vout: 1, + utxoType: 'token', + transactionType: 'send', + tokenId: + 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', + tokenTicker: 'CTP', + tokenName: 'Cash Tab Points', + tokenDocumentUrl: 'https://cashtabapp.com/', + tokenDocumentHash: '', + decimals: 9, + tokenType: 1, + tokenQty: '1e-9', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + tokenId: + 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', + balance: { + s: 1, + e: -9, + c: [100000], + }, + hasBaton: false, + }, + { + info: { + height: 681189, + tx_hash: + 'f38ccfa615e38f0c871f4eb35db420157808014f1f5743f1522529253c0c4c56', + tx_pos: 2, + value: 546, + txid: 'f38ccfa615e38f0c871f4eb35db420157808014f1f5743f1522529253c0c4c56', + vout: 2, + utxoType: 'token', + transactionType: 'send', + tokenId: + '7443f7c831cdf2b2b04d5f0465ed0bcf348582675b0e4f17906438c232c22f3d', + tokenTicker: 'WDT', + tokenName: + 'Test Token With Exceptionally Long Name For CSS And Style Revisions', + tokenDocumentUrl: + 'https://www.ImpossiblyLongWebsiteDidYouThinkWebDevWouldBeFun.org', + tokenDocumentHash: + '����\\�IS\u001e9�����k+���\u0018���\u001b]�߷2��', + decimals: 7, + tokenType: 1, + tokenQty: '523512277.7961432', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + tokenId: + '7443f7c831cdf2b2b04d5f0465ed0bcf348582675b0e4f17906438c232c22f3d', + balance: { + s: 1, + e: 8, + c: [523512277, 79614320000000], + }, + hasBaton: false, + }, + { + info: { + height: 681190, + tx_hash: + 'e9dca9aa954131a0004325fff11dfddcd6e5843c468116cf4d38cb264032cdc0', + tx_pos: 2, + value: 546, + txid: 'e9dca9aa954131a0004325fff11dfddcd6e5843c468116cf4d38cb264032cdc0', + vout: 2, + utxoType: 'token', + transactionType: 'send', + tokenId: + '1f6a65e7a4bde92c0a012de2bcf4007034504a765377cdf08a3ee01d1eaa6901', + tokenTicker: '🍔', + tokenName: 'Burger', + tokenDocumentUrl: + 'https://c4.wallpaperflare.com/wallpaper/58/564/863/giant-hamburger-wallpaper-preview.jpg', + tokenDocumentHash: '', + decimals: 0, + tokenType: 1, + tokenQty: '1', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + tokenId: + '1f6a65e7a4bde92c0a012de2bcf4007034504a765377cdf08a3ee01d1eaa6901', + balance: { + s: 1, + e: 0, + c: [1], + }, + hasBaton: false, + }, + { + info: { + height: 681191, + tx_hash: + '091c9f32deb2f4f3733673803f51acf050b65d8042d1561824c6cd22d14bb43b', + tx_pos: 2, + value: 546, + txid: '091c9f32deb2f4f3733673803f51acf050b65d8042d1561824c6cd22d14bb43b', + vout: 2, + utxoType: 'token', + transactionType: 'send', + tokenId: + '4bd147fc5d5ff26249a9299c46b80920c0b81f59a60e05428262160ebee0b0c3', + tokenTicker: 'NOCOVID', + tokenName: 'Covid19 Lifetime Immunity', + tokenDocumentUrl: + 'https://www.who.int/emergencies/diseases/novel-coronavirus-2019/covid-19-vaccines', + tokenDocumentHash: '', + decimals: 0, + tokenType: 1, + tokenQty: '996797', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + tokenId: + '4bd147fc5d5ff26249a9299c46b80920c0b81f59a60e05428262160ebee0b0c3', + balance: { + s: 1, + e: 5, + c: [996797], + }, + hasBaton: false, + }, + { + info: { + height: 681191, + tx_hash: + 'b35c502f388cdfbdd6841b7a73e973149b3c8deca76295a3e4665939e0562796', + tx_pos: 2, + value: 546, + txid: 'b35c502f388cdfbdd6841b7a73e973149b3c8deca76295a3e4665939e0562796', + vout: 2, + utxoType: 'token', + transactionType: 'send', + tokenId: + 'dd84ca78db4d617221b58eabc6667af8fe2f7eadbfcc213d35be9f1b419beb8d', + tokenTicker: 'TAP', + tokenName: 'Thoughts and Prayers', + tokenDocumentUrl: '', + tokenDocumentHash: '', + decimals: 0, + tokenType: 1, + tokenQty: '1', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + tokenId: + 'dd84ca78db4d617221b58eabc6667af8fe2f7eadbfcc213d35be9f1b419beb8d', + balance: { + s: 1, + e: 0, + c: [1], + }, + hasBaton: false, + }, + { + info: { + height: 681191, + tx_hash: + 'c70408fca1a5bf48f338f7ef031e586293be6948a5bff1fbbdd4eb923ef11e59', + tx_pos: 2, + value: 546, + txid: 'c70408fca1a5bf48f338f7ef031e586293be6948a5bff1fbbdd4eb923ef11e59', + vout: 2, + utxoType: 'token', + transactionType: 'send', + tokenId: + 'df808a41672a0a0ae6475b44f272a107bc9961b90f29dc918d71301f24fe92fb', + tokenTicker: 'NAKAMOTO', + tokenName: 'NAKAMOTO', + tokenDocumentUrl: '', + tokenDocumentHash: '', + decimals: 8, + tokenType: 1, + tokenQty: '0.99999999', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + tokenId: + 'df808a41672a0a0ae6475b44f272a107bc9961b90f29dc918d71301f24fe92fb', + balance: { + s: 1, + e: -1, + c: [99999999000000], + }, + hasBaton: false, + }, + { + info: { + height: 681191, + tx_hash: + 'e1097932e5a607c100dc73fa18169be2e501e1782c7c94500742974d6353476c', + tx_pos: 2, + value: 546, + txid: 'e1097932e5a607c100dc73fa18169be2e501e1782c7c94500742974d6353476c', + vout: 2, + utxoType: 'token', + transactionType: 'send', + tokenId: + '7f8889682d57369ed0e32336f8b7e0ffec625a35cca183f4e81fde4e71a538a1', + tokenTicker: 'HONK', + tokenName: 'HONK HONK', + tokenDocumentUrl: 'THE REAL HONK SLP TOKEN', + tokenDocumentHash: '', + decimals: 0, + tokenType: 1, + tokenQty: '1', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + tokenId: + '7f8889682d57369ed0e32336f8b7e0ffec625a35cca183f4e81fde4e71a538a1', + balance: { + s: 1, + e: 0, + c: [1], + }, + hasBaton: false, + }, + { + info: { + height: 681329, + tx_hash: + '08e9a7b9537e60f630eba0f339be6b97e9d8061d5fc0c4d3247226fc86574ce9', + tx_pos: 2, + value: 546, + txid: '08e9a7b9537e60f630eba0f339be6b97e9d8061d5fc0c4d3247226fc86574ce9', + vout: 2, + utxoType: 'token', + transactionType: 'send', + tokenId: + '1101bd5d7b6bbc3176fb2b93d08e76ab532b04ff731d71502249e3cb9b6fcb1a', + tokenTicker: 'XBIT', + tokenName: 'eBits', + tokenDocumentUrl: 'https://boomertakes.com/', + tokenDocumentHash: '', + decimals: 9, + tokenType: 1, + tokenQty: '999997.999999994', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + tokenId: + '1101bd5d7b6bbc3176fb2b93d08e76ab532b04ff731d71502249e3cb9b6fcb1a', + balance: { + s: 1, + e: 5, + c: [999997, 99999999400000], + }, + hasBaton: false, + }, + ], + + nonSlpUtxos: [ + { + height: 682107, + tx_hash: + '8d4c90ecf069e3a1494339724ddbb8bf28e3b38315a009ca5c49237b3ae7687a', + tx_pos: 1, + value: 1503017804, + txid: '8d4c90ecf069e3a1494339724ddbb8bf28e3b38315a009ca5c49237b3ae7687a', + isValid: false, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + outpoint: { + outIdx: 1, + txid: '8d4c90ecf069e3a1494339724ddbb8bf28e3b38315a009ca5c49237b3ae7687a', + }, + }, + ], + slpUtxos: [ + { + height: 680782, + tx_hash: + '525457276f1b6984170c9b35a8312d4988fce495723eabadd2afcdb3b872b2f1', + tx_pos: 1, + value: 546, + txid: '525457276f1b6984170c9b35a8312d4988fce495723eabadd2afcdb3b872b2f1', + vout: 1, + utxoType: 'token', + transactionType: 'send', + tokenTicker: 'ST', + tokenName: 'ST', + tokenDocumentUrl: 'developer.bitcoin.com', + tokenDocumentHash: '', + decimals: 0, + tokenType: 1, + tokenQty: '1', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + slpMeta: { + tokenId: + 'bf24d955f59351e738ecd905966606a6837e478e1982943d724eab10caad82fd', + }, + }, + { + height: 680784, + tx_hash: + 'daa98a872b7d88fefd2257b006db001ef82a601f3943b92e0c753076598a7b75', + tx_pos: 1, + value: 546, + txid: 'daa98a872b7d88fefd2257b006db001ef82a601f3943b92e0c753076598a7b75', + vout: 1, + utxoType: 'token', + transactionType: 'send', + slpMeta: { + tokenId: + 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', + }, + tokenTicker: 'CTP', + tokenName: 'Cash Tab Points', + tokenDocumentUrl: 'https://cashtabapp.com/', + tokenDocumentHash: '', + decimals: 9, + tokenType: 1, + tokenQty: '1e-9', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + { + height: 681189, + tx_hash: + 'f38ccfa615e38f0c871f4eb35db420157808014f1f5743f1522529253c0c4c56', + tx_pos: 2, + value: 546, + txid: 'f38ccfa615e38f0c871f4eb35db420157808014f1f5743f1522529253c0c4c56', + vout: 2, + utxoType: 'token', + transactionType: 'send', + slpMeta: { + tokenId: + '7443f7c831cdf2b2b04d5f0465ed0bcf348582675b0e4f17906438c232c22f3d', + }, + tokenTicker: 'WDT', + tokenName: + 'Test Token With Exceptionally Long Name For CSS And Style Revisions', + tokenDocumentUrl: + 'https://www.ImpossiblyLongWebsiteDidYouThinkWebDevWouldBeFun.org', + tokenDocumentHash: + '����\\�IS\u001e9�����k+���\u0018���\u001b]�߷2��', + decimals: 7, + tokenType: 1, + tokenQty: '523512277.7961432', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + { + height: 681190, + tx_hash: + 'e9dca9aa954131a0004325fff11dfddcd6e5843c468116cf4d38cb264032cdc0', + tx_pos: 2, + value: 546, + txid: 'e9dca9aa954131a0004325fff11dfddcd6e5843c468116cf4d38cb264032cdc0', + vout: 2, + utxoType: 'token', + transactionType: 'send', + slpMeta: { + tokenId: + '1f6a65e7a4bde92c0a012de2bcf4007034504a765377cdf08a3ee01d1eaa6901', + }, + tokenTicker: '🍔', + tokenName: 'Burger', + tokenDocumentUrl: + 'https://c4.wallpaperflare.com/wallpaper/58/564/863/giant-hamburger-wallpaper-preview.jpg', + tokenDocumentHash: '', + decimals: 0, + tokenType: 1, + tokenQty: '1', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + { + height: 681191, + tx_hash: + '091c9f32deb2f4f3733673803f51acf050b65d8042d1561824c6cd22d14bb43b', + tx_pos: 2, + value: 546, + txid: '091c9f32deb2f4f3733673803f51acf050b65d8042d1561824c6cd22d14bb43b', + vout: 2, + utxoType: 'token', + transactionType: 'send', + slpMeta: { + tokenId: + '4bd147fc5d5ff26249a9299c46b80920c0b81f59a60e05428262160ebee0b0c3', + }, + tokenTicker: 'NOCOVID', + tokenName: 'Covid19 Lifetime Immunity', + tokenDocumentUrl: + 'https://www.who.int/emergencies/diseases/novel-coronavirus-2019/covid-19-vaccines', + tokenDocumentHash: '', + decimals: 0, + tokenType: 1, + tokenQty: '996797', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + { + height: 681191, + tx_hash: + 'b35c502f388cdfbdd6841b7a73e973149b3c8deca76295a3e4665939e0562796', + tx_pos: 2, + value: 546, + txid: 'b35c502f388cdfbdd6841b7a73e973149b3c8deca76295a3e4665939e0562796', + vout: 2, + utxoType: 'token', + transactionType: 'send', + slpMeta: { + tokenId: + 'dd84ca78db4d617221b58eabc6667af8fe2f7eadbfcc213d35be9f1b419beb8d', + }, + tokenTicker: 'TAP', + tokenName: 'Thoughts and Prayers', + tokenDocumentUrl: '', + tokenDocumentHash: '', + decimals: 0, + tokenType: 1, + tokenQty: '1', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + { + height: 681191, + tx_hash: + 'c70408fca1a5bf48f338f7ef031e586293be6948a5bff1fbbdd4eb923ef11e59', + tx_pos: 2, + value: 546, + txid: 'c70408fca1a5bf48f338f7ef031e586293be6948a5bff1fbbdd4eb923ef11e59', + vout: 2, + utxoType: 'token', + transactionType: 'send', + slpMeta: { + tokenId: + 'df808a41672a0a0ae6475b44f272a107bc9961b90f29dc918d71301f24fe92fb', + }, + tokenTicker: 'NAKAMOTO', + tokenName: 'NAKAMOTO', + tokenDocumentUrl: '', + tokenDocumentHash: '', + decimals: 8, + tokenType: 1, + tokenQty: '0.99999999', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + { + height: 681191, + tx_hash: + 'e1097932e5a607c100dc73fa18169be2e501e1782c7c94500742974d6353476c', + tx_pos: 2, + value: 546, + txid: 'e1097932e5a607c100dc73fa18169be2e501e1782c7c94500742974d6353476c', + vout: 2, + utxoType: 'token', + transactionType: 'send', + slpMeta: { + tokenId: + '7f8889682d57369ed0e32336f8b7e0ffec625a35cca183f4e81fde4e71a538a1', + }, + tokenTicker: 'HONK', + tokenName: 'HONK HONK', + tokenDocumentUrl: 'THE REAL HONK SLP TOKEN', + tokenDocumentHash: '', + decimals: 0, + tokenType: 1, + tokenQty: '1', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + { + height: 681329, + tx_hash: + '08e9a7b9537e60f630eba0f339be6b97e9d8061d5fc0c4d3247226fc86574ce9', + tx_pos: 2, + value: 546, + txid: '08e9a7b9537e60f630eba0f339be6b97e9d8061d5fc0c4d3247226fc86574ce9', + vout: 2, + utxoType: 'token', + transactionType: 'send', + slpMeta: { + tokenId: + '1101bd5d7b6bbc3176fb2b93d08e76ab532b04ff731d71502249e3cb9b6fcb1a', + }, + tokenTicker: 'XBIT', + tokenName: 'eBits', + tokenDocumentUrl: 'https://boomertakes.com/', + tokenDocumentHash: '', + decimals: 9, + tokenType: 1, + tokenQty: '999997.999999994', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + ], + parsedTxHistory: [ + { + txid: '8d4c90ecf069e3a1494339724ddbb8bf28e3b38315a009ca5c49237b3ae7687a', + confirmations: 644, + height: 682107, + blocktime: 1618439595, + amountSent: 0.00002, + amountReceived: 0, + tokenTx: false, + outgoingTx: true, + destinationAddress: + 'bitcoincash:qqartrrq3npyzpcqswq2hcslstzu38mq8gvgtuqfpf', + }, + { + txid: '08e9a7b9537e60f630eba0f339be6b97e9d8061d5fc0c4d3247226fc86574ce9', + confirmations: 1422, + height: 681329, + blocktime: 1617988189, + amountSent: 0.00000546, + amountReceived: 0, + tokenTx: true, + outgoingTx: true, + destinationAddress: + 'bitcoincash:qqartrrq3npyzpcqswq2hcslstzu38mq8gvgtuqfpf', + tokenInfo: { + qtySent: '1e-9', + qtyReceived: '0', + tokenId: + '1101bd5d7b6bbc3176fb2b93d08e76ab532b04ff731d71502249e3cb9b6fcb1a', + tokenName: 'eBits', + tokenTicker: 'XBIT', + }, + }, + { + txid: 'f27ff24c15b01c30d44218c6dc8706fd33cc7bc9b4b38399075f0f41d8e412af', + confirmations: 1559, + height: 681192, + blocktime: 1617923457, + amountSent: 0.00000546, + amountReceived: 0, + tokenTx: true, + outgoingTx: true, + destinationAddress: + 'bitcoincash:qqartrrq3npyzpcqswq2hcslstzu38mq8gvgtuqfpf', + tokenInfo: { + qtySent: '5e-9', + qtyReceived: '0', + tokenId: + '1101bd5d7b6bbc3176fb2b93d08e76ab532b04ff731d71502249e3cb9b6fcb1a', + tokenName: 'eBits', + tokenTicker: 'XBIT', + }, + }, + { + txid: 'b7f8b23f5ce12842eb655239919b6142052a2fa2b2ce974a4baac36b0137f332', + confirmations: 1559, + height: 681192, + blocktime: 1617923457, + amountSent: 0.00000546, + amountReceived: 0, + tokenTx: true, + outgoingTx: true, + destinationAddress: + 'bitcoincash:qqartrrq3npyzpcqswq2hcslstzu38mq8gvgtuqfpf', + tokenInfo: { + qtySent: '4e-9', + qtyReceived: '0', + tokenId: + '1101bd5d7b6bbc3176fb2b93d08e76ab532b04ff731d71502249e3cb9b6fcb1a', + tokenName: 'eBits', + tokenTicker: 'XBIT', + }, + }, + { + txid: '880baf5691c2b4c5a22ae4032e2004c0c54bfabf003468044a2e341846137136', + confirmations: 1559, + height: 681192, + blocktime: 1617923457, + amountSent: 0.00000546, + amountReceived: 0, + tokenTx: true, + outgoingTx: true, + destinationAddress: + 'bitcoincash:qqartrrq3npyzpcqswq2hcslstzu38mq8gvgtuqfpf', + tokenInfo: { + qtySent: '3e-9', + qtyReceived: '0', + tokenId: + '1101bd5d7b6bbc3176fb2b93d08e76ab532b04ff731d71502249e3cb9b6fcb1a', + tokenName: 'eBits', + tokenTicker: 'XBIT', + }, + }, + ], + }, +}; diff --git a/web/cashtab/src/hooks/__mocks__/createToken.js b/web/cashtab/src/hooks/__mocks__/createToken.js --- a/web/cashtab/src/hooks/__mocks__/createToken.js +++ b/web/cashtab/src/hooks/__mocks__/createToken.js @@ -36,25 +36,24 @@ balances: [], utxos: [], tokens: [], - slpBalancesAndUtxos: { - nonSlpUtxos: [ - { - height: 0, - tx_hash: - 'e0d6d7d46d5fc6aaa4512a7aca9223c6d7ca30b8253dee1b40b8978fe7dc501e', - tx_pos: 0, - value: 1000000, + nonSlpUtxos: [ + { + height: 0, + tx_hash: + 'e0d6d7d46d5fc6aaa4512a7aca9223c6d7ca30b8253dee1b40b8978fe7dc501e', + tx_pos: 0, + value: 1000000, + txid: 'e0d6d7d46d5fc6aaa4512a7aca9223c6d7ca30b8253dee1b40b8978fe7dc501e', + isValid: false, + address: + 'bitcoincash:qpuvjl7l3crt3apc62gmtf49pfsluu7s9gsex3qnhn', + outpoint: { + outIdx: 0, txid: 'e0d6d7d46d5fc6aaa4512a7aca9223c6d7ca30b8253dee1b40b8978fe7dc501e', - isValid: false, - address: - 'bitcoincash:qpuvjl7l3crt3apc62gmtf49pfsluu7s9gsex3qnhn', - outpoint: { - outIdx: 0, - txid: 'e0d6d7d46d5fc6aaa4512a7aca9223c6d7ca30b8253dee1b40b8978fe7dc501e', - }, }, - ], - }, + }, + ], + slpUtxos: [], }, }, configObj: { diff --git a/web/cashtab/src/hooks/__tests__/useBCH.test.js b/web/cashtab/src/hooks/__tests__/useBCH.test.js --- a/web/cashtab/src/hooks/__tests__/useBCH.test.js +++ b/web/cashtab/src/hooks/__tests__/useBCH.test.js @@ -2,7 +2,7 @@ import useBCH from '../useBCH'; import sendBCHMock from '../__mocks__/sendBCH'; import createTokenMock from '../__mocks__/createToken'; -import { validStoredWallet } from '../../utils/__mocks__/mockStoredWallets'; +import { burnTokenWallet } from '../__mocks__/burnToken'; import { currency } from '../../components/Common/Ticker'; import BigNumber from 'bignumber.js'; import { fromSatoshisToXec } from 'utils/cashMethods'; @@ -190,7 +190,7 @@ it("Throws error attempting to burn an eToken ID that is not within the wallet's utxo", async () => { const { burnToken } = useBCH(); - const wallet = validStoredWallet; + const wallet = burnTokenWallet; const burnAmount = 10; const eTokenId = '0203c768a66eba24affNOTVALID103b772de4d9f8f63ba79e'; const expectedError = diff --git a/web/cashtab/src/hooks/useBCH.js b/web/cashtab/src/hooks/useBCH.js --- a/web/cashtab/src/hooks/useBCH.js +++ b/web/cashtab/src/hooks/useBCH.js @@ -43,7 +43,7 @@ const walletError = new Error(`Invalid wallet`); throw walletError; } - const utxos = wallet.state.slpBalancesAndUtxos.nonSlpUtxos; + const utxos = wallet.state.nonSlpUtxos; const CREATION_ADDR = wallet.Path1899.cashAddress; let txBuilder = new TransactionBuilder(); @@ -121,17 +121,12 @@ wallet, { tokenId, amount, tokenReceiverAddress }, ) => { - const slpBalancesAndUtxos = wallet.state.slpBalancesAndUtxos; - const xecUtxos = slpBalancesAndUtxos.nonSlpUtxos; - const tokenUtxos = slpBalancesAndUtxos.slpUtxos; + const xecUtxos = wallet.state.nonSlpUtxos; + const tokenUtxos = wallet.state.slpUtxos; const CREATION_ADDR = wallet.Path1899.cashAddress; // Handle error of user having no XEC - if ( - !slpBalancesAndUtxos || - !slpBalancesAndUtxos.nonSlpUtxos || - slpBalancesAndUtxos.nonSlpUtxos.length === 0 - ) { + if (!xecUtxos || xecUtxos.length === 0) { throw new Error( `You need some ${currency.ticker} to send ${currency.tokenTicker}`, ); @@ -197,17 +192,12 @@ }; const burnToken = async (chronik, wallet, { tokenId, amount }) => { - const slpBalancesAndUtxos = wallet.state.slpBalancesAndUtxos; - const xecUtxos = slpBalancesAndUtxos.nonSlpUtxos; - const tokenUtxos = slpBalancesAndUtxos.slpUtxos; + const xecUtxos = wallet.state.nonSlpUtxos; + const tokenUtxos = wallet.state.slpUtxos; const CREATION_ADDR = wallet.Path1899.cashAddress; // Handle error of user having no XEC - if ( - !slpBalancesAndUtxos || - !slpBalancesAndUtxos.nonSlpUtxos || - slpBalancesAndUtxos.nonSlpUtxos.length === 0 - ) { + if (!xecUtxos || xecUtxos.length === 0) { throw new Error(`You need some ${currency.ticker} to burn eTokens`); } diff --git a/web/cashtab/src/hooks/useWallet.js b/web/cashtab/src/hooks/useWallet.js --- a/web/cashtab/src/hooks/useWallet.js +++ b/web/cashtab/src/hooks/useWallet.js @@ -254,10 +254,8 @@ const newState = { balances: getWalletBalanceFromUtxos(nonSlpUtxos), tokens: finalTokenArray, - slpBalancesAndUtxos: { - slpUtxos: finalizedSlpUtxos, - nonSlpUtxos, - }, + slpUtxos: finalizedSlpUtxos, + nonSlpUtxos, parsedTxHistory: chronikTxHistory, }; @@ -444,7 +442,7 @@ try { await localforage.setItem('wallet', wallet); console.log( - `Wallet ${wallet.name} saved without duplicate token object`, + `Wallet ${wallet.name} saved without slpBalancesAndUtxos parent object`, ); } catch (err) { console.log(`Error in writeWalletState()`); diff --git a/web/cashtab/src/utils/__mocks__/chronikTxHistory.js b/web/cashtab/src/utils/__mocks__/chronikTxHistory.js --- a/web/cashtab/src/utils/__mocks__/chronikTxHistory.js +++ b/web/cashtab/src/utils/__mocks__/chronikTxHistory.js @@ -5558,13 +5558,9 @@ totalBalance: '554214.22', }, tokens: [], - slpBalancesAndUtxos: { - slpUtxos: [], - nonSlpUtxos: [], - tokens: [], - }, + slpUtxos: [], + nonSlpUtxos: [], parsedTxHistory: [], - utxos: [], }, }; @@ -5607,13 +5603,9 @@ totalBalance: '554214.22', }, tokens: [], - slpBalancesAndUtxos: { - slpUtxos: [], - nonSlpUtxos: [], - tokens: [], - }, + slpUtxos: [], + nonSlpUtxos: [], parsedTxHistory: [], - utxos: [], }, }; @@ -6923,36 +6915,33 @@ totalBalance: '495.45', }, tokens: [], - slpBalancesAndUtxos: { - slpUtxos: [], - nonSlpUtxos: [ - { - outpoint: { - txid: '45411aa786288b679d1c1874f7b126d5ea0c83380304950d364b5b8279a460de', - outIdx: 1, - }, - blockHeight: -1, - isCoinbase: false, - value: '48445', - network: 'XEC', - address: - 'bitcoincash:qrhxmjw5p72a3cgx5cect3h63q5erw0gfc4l80hyqu', - }, - { - outpoint: { - txid: '66974f4a22ca1a4aa36c932b4effafcb9dd8a32b8766dfc7644ba5922252c4c6', - outIdx: 1, - }, - blockHeight: -1, - isCoinbase: false, - value: '1100', - network: 'XEC', - address: - 'bitcoincash:qrhxmjw5p72a3cgx5cect3h63q5erw0gfc4l80hyqu', + slpUtxos: [], + nonSlpUtxos: [ + { + outpoint: { + txid: '45411aa786288b679d1c1874f7b126d5ea0c83380304950d364b5b8279a460de', + outIdx: 1, }, - ], - tokens: [], - }, + blockHeight: -1, + isCoinbase: false, + value: '48445', + network: 'XEC', + address: + 'bitcoincash:qrhxmjw5p72a3cgx5cect3h63q5erw0gfc4l80hyqu', + }, + { + outpoint: { + txid: '66974f4a22ca1a4aa36c932b4effafcb9dd8a32b8766dfc7644ba5922252c4c6', + outIdx: 1, + }, + blockHeight: -1, + isCoinbase: false, + value: '1100', + network: 'XEC', + address: + 'bitcoincash:qrhxmjw5p72a3cgx5cect3h63q5erw0gfc4l80hyqu', + }, + ], parsedTxHistory: [ { txid: '66974f4a22ca1a4aa36c932b4effafcb9dd8a32b8766dfc7644ba5922252c4c6', @@ -7132,32 +7121,6 @@ }, }, ], - utxos: [ - { - outpoint: { - txid: '45411aa786288b679d1c1874f7b126d5ea0c83380304950d364b5b8279a460de', - outIdx: 1, - }, - blockHeight: -1, - isCoinbase: false, - value: '48445', - network: 'XEC', - address: - 'bitcoincash:qrhxmjw5p72a3cgx5cect3h63q5erw0gfc4l80hyqu', - }, - { - outpoint: { - txid: '66974f4a22ca1a4aa36c932b4effafcb9dd8a32b8766dfc7644ba5922252c4c6', - outIdx: 1, - }, - blockHeight: -1, - isCoinbase: false, - value: '1100', - network: 'XEC', - address: - 'bitcoincash:qrhxmjw5p72a3cgx5cect3h63q5erw0gfc4l80hyqu', - }, - ], }, }; export const mockSentEncryptedTx = { @@ -7612,42 +7575,39 @@ totalBalance: '19.97', }, tokens: [], - slpBalancesAndUtxos: { - slpUtxos: [], - nonSlpUtxos: [ - { - outpoint: { - txid: '0417094d2011c967e2ad8fe917415876f2e6a249bb486edb638d5659920a88ee', - outIdx: 0, - }, - blockHeight: 767064, - isCoinbase: false, - value: '997', - network: 'XEC', - address: - 'bitcoincash:qznaw38py34zpunz8rs9zrac9kxlsnxg95m2sf5czz', - }, - { - outpoint: { - txid: '2f030de7c8f80a1ecac3645092dd22f0943c34d54cb734e12d7dfda0641fdfcf', - outIdx: 3, - }, - blockHeight: 767064, - isCoinbase: false, - value: '1000', - slpMeta: { - tokenType: 'FUNGIBLE', - txType: 'SEND', - tokenId: - '54dc2ecd5251f8dfda4c4f15ce05272116b01326076240e2b9cc0104d33b1484', - }, - network: 'XEC', - address: - 'bitcoincash:qznaw38py34zpunz8rs9zrac9kxlsnxg95m2sf5czz', + slpUtxos: [], + nonSlpUtxos: [ + { + outpoint: { + txid: '0417094d2011c967e2ad8fe917415876f2e6a249bb486edb638d5659920a88ee', + outIdx: 0, }, - ], - tokens: [], - }, + blockHeight: 767064, + isCoinbase: false, + value: '997', + network: 'XEC', + address: + 'bitcoincash:qznaw38py34zpunz8rs9zrac9kxlsnxg95m2sf5czz', + }, + { + outpoint: { + txid: '2f030de7c8f80a1ecac3645092dd22f0943c34d54cb734e12d7dfda0641fdfcf', + outIdx: 3, + }, + blockHeight: 767064, + isCoinbase: false, + value: '1000', + slpMeta: { + tokenType: 'FUNGIBLE', + txType: 'SEND', + tokenId: + '54dc2ecd5251f8dfda4c4f15ce05272116b01326076240e2b9cc0104d33b1484', + }, + network: 'XEC', + address: + 'bitcoincash:qznaw38py34zpunz8rs9zrac9kxlsnxg95m2sf5czz', + }, + ], parsedTxHistory: [ { txid: '2f030de7c8f80a1ecac3645092dd22f0943c34d54cb734e12d7dfda0641fdfcf', @@ -7813,37 +7773,5 @@ }, }, ], - utxos: [ - { - outpoint: { - txid: '0417094d2011c967e2ad8fe917415876f2e6a249bb486edb638d5659920a88ee', - outIdx: 0, - }, - blockHeight: 767064, - isCoinbase: false, - value: '997', - network: 'XEC', - address: - 'bitcoincash:qznaw38py34zpunz8rs9zrac9kxlsnxg95m2sf5czz', - }, - { - outpoint: { - txid: '2f030de7c8f80a1ecac3645092dd22f0943c34d54cb734e12d7dfda0641fdfcf', - outIdx: 3, - }, - blockHeight: 767064, - isCoinbase: false, - value: '1000', - slpMeta: { - tokenType: 'FUNGIBLE', - txType: 'SEND', - tokenId: - '54dc2ecd5251f8dfda4c4f15ce05272116b01326076240e2b9cc0104d33b1484', - }, - network: 'XEC', - address: - 'bitcoincash:qznaw38py34zpunz8rs9zrac9kxlsnxg95m2sf5czz', - }, - ], }, }; diff --git a/web/cashtab/src/utils/__mocks__/mockCachedUtxos.js b/web/cashtab/src/utils/__mocks__/mockCachedUtxos.js --- a/web/cashtab/src/utils/__mocks__/mockCachedUtxos.js +++ b/web/cashtab/src/utils/__mocks__/mockCachedUtxos.js @@ -1,9 +1,7 @@ -// @generated - import BigNumber from 'bignumber.js'; export const cachedUtxos = { - slpBalancesAndUtxos: { nonSlpUtxos: [] }, + nonSlpUtxos: [], tokens: [ { info: { @@ -281,9 +279,7 @@ totalBalance: '0', totalBalanceInSatoshis: '0', }, - slpBalancesAndUtxos: { - nonSlpUtxos: [], - }, + nonSlpUtxos: [], tokens: [ { info: { diff --git a/web/cashtab/src/utils/__mocks__/mockStoredWallets.js b/web/cashtab/src/utils/__mocks__/mockStoredWallets.js --- a/web/cashtab/src/utils/__mocks__/mockStoredWallets.js +++ b/web/cashtab/src/utils/__mocks__/mockStoredWallets.js @@ -1424,257 +1424,257 @@ hasBaton: false, }, ], - slpBalancesAndUtxos: { - nonSlpUtxos: [ - { - height: 682107, - tx_hash: - '8d4c90ecf069e3a1494339724ddbb8bf28e3b38315a009ca5c49237b3ae7687a', - tx_pos: 1, - value: 1503017804, + + nonSlpUtxos: [ + { + height: 682107, + tx_hash: + '8d4c90ecf069e3a1494339724ddbb8bf28e3b38315a009ca5c49237b3ae7687a', + tx_pos: 1, + value: 1503017804, + txid: '8d4c90ecf069e3a1494339724ddbb8bf28e3b38315a009ca5c49237b3ae7687a', + isValid: false, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + outpoint: { + outIdx: 1, txid: '8d4c90ecf069e3a1494339724ddbb8bf28e3b38315a009ca5c49237b3ae7687a', - isValid: false, - address: - 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', - outpoint: { - outIdx: 1, - txid: '8d4c90ecf069e3a1494339724ddbb8bf28e3b38315a009ca5c49237b3ae7687a', - }, }, - ], - slpUtxos: [ - { - height: 680782, - tx_hash: - '525457276f1b6984170c9b35a8312d4988fce495723eabadd2afcdb3b872b2f1', - tx_pos: 1, - value: 546, - txid: '525457276f1b6984170c9b35a8312d4988fce495723eabadd2afcdb3b872b2f1', - vout: 1, - utxoType: 'token', - transactionType: 'send', - tokenTicker: 'ST', - tokenName: 'ST', - tokenDocumentUrl: 'developer.bitcoin.com', - tokenDocumentHash: '', - decimals: 0, - tokenType: 1, - tokenQty: '1', - isValid: true, - address: - 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', - slpMeta: { - tokenId: - 'bf24d955f59351e738ecd905966606a6837e478e1982943d724eab10caad82fd', - }, + }, + ], + slpUtxos: [ + { + height: 680782, + tx_hash: + '525457276f1b6984170c9b35a8312d4988fce495723eabadd2afcdb3b872b2f1', + tx_pos: 1, + value: 546, + txid: '525457276f1b6984170c9b35a8312d4988fce495723eabadd2afcdb3b872b2f1', + vout: 1, + utxoType: 'token', + transactionType: 'send', + tokenTicker: 'ST', + tokenName: 'ST', + tokenDocumentUrl: 'developer.bitcoin.com', + tokenDocumentHash: '', + decimals: 0, + tokenType: 1, + tokenQty: '1', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + slpMeta: { + tokenId: + 'bf24d955f59351e738ecd905966606a6837e478e1982943d724eab10caad82fd', }, - { - height: 680784, - tx_hash: - 'daa98a872b7d88fefd2257b006db001ef82a601f3943b92e0c753076598a7b75', - tx_pos: 1, - value: 546, - txid: 'daa98a872b7d88fefd2257b006db001ef82a601f3943b92e0c753076598a7b75', - vout: 1, - utxoType: 'token', - transactionType: 'send', - slpMeta: { - tokenId: - 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', - }, - tokenTicker: 'CTP', - tokenName: 'Cash Tab Points', - tokenDocumentUrl: 'https://cashtabapp.com/', - tokenDocumentHash: '', - decimals: 9, - tokenType: 1, - tokenQty: '1e-9', - isValid: true, - address: - 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + { + height: 680784, + tx_hash: + 'daa98a872b7d88fefd2257b006db001ef82a601f3943b92e0c753076598a7b75', + tx_pos: 1, + value: 546, + txid: 'daa98a872b7d88fefd2257b006db001ef82a601f3943b92e0c753076598a7b75', + vout: 1, + utxoType: 'token', + transactionType: 'send', + slpMeta: { + tokenId: + 'bef614aac85c0c866f4d39e4d12a96851267d38d1bca5bdd6488bbd42e28b6b1', }, - { - height: 681189, - tx_hash: - 'f38ccfa615e38f0c871f4eb35db420157808014f1f5743f1522529253c0c4c56', - tx_pos: 2, - value: 546, - txid: 'f38ccfa615e38f0c871f4eb35db420157808014f1f5743f1522529253c0c4c56', - vout: 2, - utxoType: 'token', - transactionType: 'send', - slpMeta: { - tokenId: - '7443f7c831cdf2b2b04d5f0465ed0bcf348582675b0e4f17906438c232c22f3d', - }, - tokenTicker: 'WDT', - tokenName: - 'Test Token With Exceptionally Long Name For CSS And Style Revisions', - tokenDocumentUrl: - 'https://www.ImpossiblyLongWebsiteDidYouThinkWebDevWouldBeFun.org', - tokenDocumentHash: - '����\\�IS\u001e9�����k+���\u0018���\u001b]�߷2��', - decimals: 7, - tokenType: 1, - tokenQty: '523512277.7961432', - isValid: true, - address: - 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + tokenTicker: 'CTP', + tokenName: 'Cash Tab Points', + tokenDocumentUrl: 'https://cashtabapp.com/', + tokenDocumentHash: '', + decimals: 9, + tokenType: 1, + tokenQty: '1e-9', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + { + height: 681189, + tx_hash: + 'f38ccfa615e38f0c871f4eb35db420157808014f1f5743f1522529253c0c4c56', + tx_pos: 2, + value: 546, + txid: 'f38ccfa615e38f0c871f4eb35db420157808014f1f5743f1522529253c0c4c56', + vout: 2, + utxoType: 'token', + transactionType: 'send', + slpMeta: { + tokenId: + '7443f7c831cdf2b2b04d5f0465ed0bcf348582675b0e4f17906438c232c22f3d', }, - { - height: 681190, - tx_hash: - 'e9dca9aa954131a0004325fff11dfddcd6e5843c468116cf4d38cb264032cdc0', - tx_pos: 2, - value: 546, - txid: 'e9dca9aa954131a0004325fff11dfddcd6e5843c468116cf4d38cb264032cdc0', - vout: 2, - utxoType: 'token', - transactionType: 'send', - slpMeta: { - tokenId: - '1f6a65e7a4bde92c0a012de2bcf4007034504a765377cdf08a3ee01d1eaa6901', - }, - tokenTicker: '🍔', - tokenName: 'Burger', - tokenDocumentUrl: - 'https://c4.wallpaperflare.com/wallpaper/58/564/863/giant-hamburger-wallpaper-preview.jpg', - tokenDocumentHash: '', - decimals: 0, - tokenType: 1, - tokenQty: '1', - isValid: true, - address: - 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + tokenTicker: 'WDT', + tokenName: + 'Test Token With Exceptionally Long Name For CSS And Style Revisions', + tokenDocumentUrl: + 'https://www.ImpossiblyLongWebsiteDidYouThinkWebDevWouldBeFun.org', + tokenDocumentHash: + '����\\�IS\u001e9�����k+���\u0018���\u001b]�߷2��', + decimals: 7, + tokenType: 1, + tokenQty: '523512277.7961432', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + { + height: 681190, + tx_hash: + 'e9dca9aa954131a0004325fff11dfddcd6e5843c468116cf4d38cb264032cdc0', + tx_pos: 2, + value: 546, + txid: 'e9dca9aa954131a0004325fff11dfddcd6e5843c468116cf4d38cb264032cdc0', + vout: 2, + utxoType: 'token', + transactionType: 'send', + slpMeta: { + tokenId: + '1f6a65e7a4bde92c0a012de2bcf4007034504a765377cdf08a3ee01d1eaa6901', }, - { - height: 681191, - tx_hash: - '091c9f32deb2f4f3733673803f51acf050b65d8042d1561824c6cd22d14bb43b', - tx_pos: 2, - value: 546, - txid: '091c9f32deb2f4f3733673803f51acf050b65d8042d1561824c6cd22d14bb43b', - vout: 2, - utxoType: 'token', - transactionType: 'send', - slpMeta: { - tokenId: - '4bd147fc5d5ff26249a9299c46b80920c0b81f59a60e05428262160ebee0b0c3', - }, - tokenTicker: 'NOCOVID', - tokenName: 'Covid19 Lifetime Immunity', - tokenDocumentUrl: - 'https://www.who.int/emergencies/diseases/novel-coronavirus-2019/covid-19-vaccines', - tokenDocumentHash: '', - decimals: 0, - tokenType: 1, - tokenQty: '996797', - isValid: true, - address: - 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + tokenTicker: '🍔', + tokenName: 'Burger', + tokenDocumentUrl: + 'https://c4.wallpaperflare.com/wallpaper/58/564/863/giant-hamburger-wallpaper-preview.jpg', + tokenDocumentHash: '', + decimals: 0, + tokenType: 1, + tokenQty: '1', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + { + height: 681191, + tx_hash: + '091c9f32deb2f4f3733673803f51acf050b65d8042d1561824c6cd22d14bb43b', + tx_pos: 2, + value: 546, + txid: '091c9f32deb2f4f3733673803f51acf050b65d8042d1561824c6cd22d14bb43b', + vout: 2, + utxoType: 'token', + transactionType: 'send', + slpMeta: { + tokenId: + '4bd147fc5d5ff26249a9299c46b80920c0b81f59a60e05428262160ebee0b0c3', }, - { - height: 681191, - tx_hash: - 'b35c502f388cdfbdd6841b7a73e973149b3c8deca76295a3e4665939e0562796', - tx_pos: 2, - value: 546, - txid: 'b35c502f388cdfbdd6841b7a73e973149b3c8deca76295a3e4665939e0562796', - vout: 2, - utxoType: 'token', - transactionType: 'send', - slpMeta: { - tokenId: - 'dd84ca78db4d617221b58eabc6667af8fe2f7eadbfcc213d35be9f1b419beb8d', - }, - tokenTicker: 'TAP', - tokenName: 'Thoughts and Prayers', - tokenDocumentUrl: '', - tokenDocumentHash: '', - decimals: 0, - tokenType: 1, - tokenQty: '1', - isValid: true, - address: - 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + tokenTicker: 'NOCOVID', + tokenName: 'Covid19 Lifetime Immunity', + tokenDocumentUrl: + 'https://www.who.int/emergencies/diseases/novel-coronavirus-2019/covid-19-vaccines', + tokenDocumentHash: '', + decimals: 0, + tokenType: 1, + tokenQty: '996797', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + { + height: 681191, + tx_hash: + 'b35c502f388cdfbdd6841b7a73e973149b3c8deca76295a3e4665939e0562796', + tx_pos: 2, + value: 546, + txid: 'b35c502f388cdfbdd6841b7a73e973149b3c8deca76295a3e4665939e0562796', + vout: 2, + utxoType: 'token', + transactionType: 'send', + slpMeta: { + tokenId: + 'dd84ca78db4d617221b58eabc6667af8fe2f7eadbfcc213d35be9f1b419beb8d', }, - { - height: 681191, - tx_hash: - 'c70408fca1a5bf48f338f7ef031e586293be6948a5bff1fbbdd4eb923ef11e59', - tx_pos: 2, - value: 546, - txid: 'c70408fca1a5bf48f338f7ef031e586293be6948a5bff1fbbdd4eb923ef11e59', - vout: 2, - utxoType: 'token', - transactionType: 'send', - slpMeta: { - tokenId: - 'df808a41672a0a0ae6475b44f272a107bc9961b90f29dc918d71301f24fe92fb', - }, - tokenTicker: 'NAKAMOTO', - tokenName: 'NAKAMOTO', - tokenDocumentUrl: '', - tokenDocumentHash: '', - decimals: 8, - tokenType: 1, - tokenQty: '0.99999999', - isValid: true, - address: - 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + tokenTicker: 'TAP', + tokenName: 'Thoughts and Prayers', + tokenDocumentUrl: '', + tokenDocumentHash: '', + decimals: 0, + tokenType: 1, + tokenQty: '1', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + { + height: 681191, + tx_hash: + 'c70408fca1a5bf48f338f7ef031e586293be6948a5bff1fbbdd4eb923ef11e59', + tx_pos: 2, + value: 546, + txid: 'c70408fca1a5bf48f338f7ef031e586293be6948a5bff1fbbdd4eb923ef11e59', + vout: 2, + utxoType: 'token', + transactionType: 'send', + slpMeta: { + tokenId: + 'df808a41672a0a0ae6475b44f272a107bc9961b90f29dc918d71301f24fe92fb', }, - { - height: 681191, - tx_hash: - 'e1097932e5a607c100dc73fa18169be2e501e1782c7c94500742974d6353476c', - tx_pos: 2, - value: 546, - txid: 'e1097932e5a607c100dc73fa18169be2e501e1782c7c94500742974d6353476c', - vout: 2, - utxoType: 'token', - transactionType: 'send', - slpMeta: { - tokenId: - '7f8889682d57369ed0e32336f8b7e0ffec625a35cca183f4e81fde4e71a538a1', - }, - tokenTicker: 'HONK', - tokenName: 'HONK HONK', - tokenDocumentUrl: 'THE REAL HONK SLP TOKEN', - tokenDocumentHash: '', - decimals: 0, - tokenType: 1, - tokenQty: '1', - isValid: true, - address: - 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + tokenTicker: 'NAKAMOTO', + tokenName: 'NAKAMOTO', + tokenDocumentUrl: '', + tokenDocumentHash: '', + decimals: 8, + tokenType: 1, + tokenQty: '0.99999999', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + { + height: 681191, + tx_hash: + 'e1097932e5a607c100dc73fa18169be2e501e1782c7c94500742974d6353476c', + tx_pos: 2, + value: 546, + txid: 'e1097932e5a607c100dc73fa18169be2e501e1782c7c94500742974d6353476c', + vout: 2, + utxoType: 'token', + transactionType: 'send', + slpMeta: { + tokenId: + '7f8889682d57369ed0e32336f8b7e0ffec625a35cca183f4e81fde4e71a538a1', }, - { - height: 681329, - tx_hash: - '08e9a7b9537e60f630eba0f339be6b97e9d8061d5fc0c4d3247226fc86574ce9', - tx_pos: 2, - value: 546, - txid: '08e9a7b9537e60f630eba0f339be6b97e9d8061d5fc0c4d3247226fc86574ce9', - vout: 2, - utxoType: 'token', - transactionType: 'send', - slpMeta: { - tokenId: - '1101bd5d7b6bbc3176fb2b93d08e76ab532b04ff731d71502249e3cb9b6fcb1a', - }, - tokenTicker: 'XBIT', - tokenName: 'eBits', - tokenDocumentUrl: 'https://boomertakes.com/', - tokenDocumentHash: '', - decimals: 9, - tokenType: 1, - tokenQty: '999997.999999994', - isValid: true, - address: - 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + tokenTicker: 'HONK', + tokenName: 'HONK HONK', + tokenDocumentUrl: 'THE REAL HONK SLP TOKEN', + tokenDocumentHash: '', + decimals: 0, + tokenType: 1, + tokenQty: '1', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + { + height: 681329, + tx_hash: + '08e9a7b9537e60f630eba0f339be6b97e9d8061d5fc0c4d3247226fc86574ce9', + tx_pos: 2, + value: 546, + txid: '08e9a7b9537e60f630eba0f339be6b97e9d8061d5fc0c4d3247226fc86574ce9', + vout: 2, + utxoType: 'token', + transactionType: 'send', + slpMeta: { + tokenId: + '1101bd5d7b6bbc3176fb2b93d08e76ab532b04ff731d71502249e3cb9b6fcb1a', }, - ], - }, + tokenTicker: 'XBIT', + tokenName: 'eBits', + tokenDocumentUrl: 'https://boomertakes.com/', + tokenDocumentHash: '', + decimals: 9, + tokenType: 1, + tokenQty: '999997.999999994', + isValid: true, + address: + 'bitcoincash:qz2708636snqhsxu8wnlka78h6fdp77ar5ulhz04hr', + }, + ], + parsedTxHistory: [ { txid: '8d4c90ecf069e3a1494339724ddbb8bf28e3b38315a009ca5c49237b3ae7687a', diff --git a/web/cashtab/src/utils/__tests__/cashMethods.test.js b/web/cashtab/src/utils/__tests__/cashMethods.test.js --- a/web/cashtab/src/utils/__tests__/cashMethods.test.js +++ b/web/cashtab/src/utils/__tests__/cashMethods.test.js @@ -1144,15 +1144,13 @@ it(`Correctly determines a wallet's balance from its set of non-eToken utxos (nonSlpUtxos)`, () => { expect( getWalletBalanceFromUtxos( - validStoredWallet.state.slpBalancesAndUtxos.nonSlpUtxos, + validStoredWalletAfter20221123Streamline.state.nonSlpUtxos, ), ).toStrictEqual(validStoredWallet.state.balances); }); it(`Correctly determines a wallet's zero balance from its empty set of non-eToken utxos (nonSlpUtxos)`, () => { expect( - getWalletBalanceFromUtxos( - utxosLoadedFromCache.slpBalancesAndUtxos.nonSlpUtxos, - ), + getWalletBalanceFromUtxos(utxosLoadedFromCache.nonSlpUtxos), ).toStrictEqual(utxosLoadedFromCache.balances); }); it(`Recognizes a stored wallet as valid if it has all required fields prior to 20221123 updated format`, () => { diff --git a/web/cashtab/src/utils/__tests__/chronik.test.js b/web/cashtab/src/utils/__tests__/chronik.test.js --- a/web/cashtab/src/utils/__tests__/chronik.test.js +++ b/web/cashtab/src/utils/__tests__/chronik.test.js @@ -570,7 +570,7 @@ replyAddress: 'ecash:qrhxmjw5p72a3cgx5cect3h63q5erw0gfcvjnyv7xt', }); }); -it(`Correctly parses a received encyrpted message transaction`, () => { +it(`Correctly parses a received encrypted message transaction`, () => { const BCH = new BCHJS({ restURL: 'https://FakeBchApiUrlToEnsureMocksOnly.com', }); diff --git a/web/cashtab/src/utils/cashMethods.js b/web/cashtab/src/utils/cashMethods.js --- a/web/cashtab/src/utils/cashMethods.js +++ b/web/cashtab/src/utils/cashMethods.js @@ -859,7 +859,7 @@ // See BigNumber.js api for how to create a BigNumber object from an object // https://mikemcl.github.io/bignumber.js/ const liveWalletState = walletStateFromStorage; - const { slpBalancesAndUtxos, tokens } = liveWalletState; + const { tokens } = liveWalletState; for (let i = 0; i < tokens.length; i += 1) { const thisTokenBalance = tokens[i].balance; thisTokenBalance._isBigNumber = true; @@ -868,8 +868,16 @@ // Also confirm balance is correct // Necessary step in case currency.decimals changed since last startup + let nonSlpUtxosToParseForBalance; + if (Object.keys(liveWalletState).includes('slpBalancesAndUtxos')) { + // If this wallet still includes the wallet.state.slpBalancesAndUtxos field + nonSlpUtxosToParseForBalance = + liveWalletState.slpBalancesAndUtxos.nonSlpUtxos; + } else { + nonSlpUtxosToParseForBalance = liveWalletState.nonSlpUtxos; + } const balancesRebased = getWalletBalanceFromUtxos( - slpBalancesAndUtxos.nonSlpUtxos, + nonSlpUtxosToParseForBalance, ); liveWalletState.balances = balancesRebased; return liveWalletState; @@ -894,7 +902,9 @@ typeof walletStateFromStorage.state === 'object' && 'balances' in walletStateFromStorage.state && !('hydratedUtxoDetails' in walletStateFromStorage.state) && - 'slpBalancesAndUtxos' in walletStateFromStorage.state && + ('slpBalancesAndUtxos' in walletStateFromStorage.state || + ('slpUtxos' in walletStateFromStorage.state && + 'nonSlpUtxos' in walletStateFromStorage.state)) && 'tokens' in walletStateFromStorage.state ); }; @@ -905,7 +915,8 @@ balances: { totalBalance: 0, totalBalanceInSatoshis: 0 }, hydratedUtxoDetails: {}, tokens: [], - slpBalancesAndUtxos: {}, + slpUtxos: [], + nonSlpUtxos: [], parsedTxHistory: [], utxos: [], }; diff --git a/web/cashtab/src/utils/chronik.js b/web/cashtab/src/utils/chronik.js --- a/web/cashtab/src/utils/chronik.js +++ b/web/cashtab/src/utils/chronik.js @@ -131,7 +131,7 @@ /* Convert chronik utxos (returned by getUtxosChronik function, above) to match - shape of existing slpBalancesAndUtxos object + wallet storage pattern This means sequestering eToken utxos from non-eToken utxos @@ -584,11 +584,11 @@ if ( wallet && wallet.state && - wallet.state.slpBalancesAndUtxos && - wallet.state.slpBalancesAndUtxos.nonSlpUtxos[0] + wallet.state.nonSlpUtxos && + wallet.state.nonSlpUtxos[0] ) { fundingWif = getUtxoWif( - wallet.state.slpBalancesAndUtxos.nonSlpUtxos[0], + wallet.state.nonSlpUtxos[0], wallet, ); privateKeyObj = wif.decode(fundingWif);