diff --git a/scripts/dashboard/Dashboard.vue b/scripts/dashboard/Dashboard.vue index 88819e0cb..585d52f79 100644 --- a/scripts/dashboard/Dashboard.vue +++ b/scripts/dashboard/Dashboard.vue @@ -269,7 +269,7 @@ async function lockWallet() { * @param {number} amount - Amount of PIVs to send */ async function send(address, amount) { - // Ensure a wallet is loaded + // Ensure a wallet is unlocked if (wallet.isViewOnly.value) { return createAlert( 'warning', @@ -280,16 +280,14 @@ async function send(address, amount) { : 'import/create', }, ]), - 3500 + 3000 ); } - // Ensure the wallet is unlocked - if ( - wallet.isViewOnly.value && - !(await restoreWallet(translation.walletUnlockTx)) - ) - return; + // Ensure wallet is synced + if (!getNetwork()?.fullSynced) { + return createAlert('warning', `${ALERTS.WALLET_NOT_SYNCED}`, 3000); + } // Sanity check the receiver address = address.trim(); @@ -352,6 +350,11 @@ async function send(address, amount) { const nValue = Math.round(amount * COIN); if (!validateAmount(nValue)) return; + // Close the send screen and clear inputs + showTransferMenu.value = false; + transferAddress.value = ''; + transferAmount.value = ''; + // Create and send the TX await createAndSendTransaction({ address, diff --git a/scripts/index.js b/scripts/index.js index e5cf6a266..22a1a3852 100644 --- a/scripts/index.js +++ b/scripts/index.js @@ -44,7 +44,6 @@ export { changePassword, } from './settings.js'; export { - createTxGUI, undelegateGUI, delegateGUI, createMasternode, diff --git a/scripts/transactions.js b/scripts/transactions.js index 19d7b1062..66bd3f7ad 100644 --- a/scripts/transactions.js +++ b/scripts/transactions.js @@ -64,110 +64,6 @@ export function validateAmount(nAmountSats, nMinSats = 10000) { return true; } -/** - * Create a transaction using input from the user interface - */ -export async function createTxGUI() { - // Ensure a wallet is loaded - if (!(await wallet.hasWalletUnlocked(true))) return; - - // Ensure the wallet is unlocked - if ( - wallet.isViewOnly() && - !(await restoreWallet(translation.walletUnlockTx)) - ) - return; - - // Sanity check the receiver - const strRawReceiver = doms.domAddress1s.value.trim(); - - // Cache the "end" receiver, which will be an Address - let strReceiverAddress = strRawReceiver; - - // Check for any contacts that match the input - const cDB = await Database.getInstance(); - const cAccount = await cDB.getAccount(); - - // If we have an Account, then check our Contacts for anything matching too - const cContact = cAccount?.getContactBy({ - name: strRawReceiver, - pubkey: strRawReceiver, - }); - // If a Contact were found, we use it's Pubkey - if (cContact) strReceiverAddress = cContact.pubkey; - - // If this is an XPub, we'll fetch their last used 'index', and derive a new public key for enhanced privacy - if (isXPub(strReceiverAddress)) { - const cNet = getNetwork(); - if (!cNet.enabled) - return createAlert( - 'warning', - ALERTS.WALLET_OFFLINE_AUTOMATIC, - 3500 - ); - - // Fetch the XPub info - const cXPub = await cNet.getXPubInfo(strReceiverAddress); - - // Use the latest index plus one (or if the XPub is unused, then the second address) - const nIndex = (cXPub.usedTokens || 0) + 1; - - // Create a receiver master-key - const cReceiverWallet = new HdMasterKey({ xpub: strReceiverAddress }); - const strPath = cReceiverWallet.getDerivationPath(0, 0, nIndex); - - // Set the 'receiver address' as the unused XPub-derived address - strReceiverAddress = cReceiverWallet.getAddress(strPath); - } - - // If Staking address: redirect to staking page - if (isColdAddress(strReceiverAddress)) { - createAlert('warning', ALERTS.STAKE_NOT_SEND, 7500); - // Close the current Send Popup - toggleBottomMenu('transferMenu', 'transferAnimation'); - // Open the Staking Dashboard - return doms.domStakeTab.click(); - } - - // Check if the Receiver Address is a valid P2PKH address - if (!isStandardAddress(strReceiverAddress)) - return createAlert( - 'warning', - tr(ALERTS.INVALID_ADDRESS, [{ address: strReceiverAddress }]), - 2500 - ); - - // Sanity check the amount - const nValue = Math.round( - Number(doms.domSendAmountCoins.value.trim()) * COIN - ); - if (!validateAmount(nValue)) return; - - // Create and send the TX - const cRes = await createAndSendTransaction({ - address: strReceiverAddress, - amount: nValue, - isDelegation: false, - }); - - // If successful, wipe Tx input - if (cRes.ok) { - // Address - doms.domAddress1s.value = ''; - // Amount - doms.domSendAmountCoins.value = ''; - // Price - doms.domSendAmountValue.value = ''; - - // Wipe any Payment Request info - if (doms.domReqDesc.value) { - // Description - doms.domReqDesc.value = ''; - doms.domReqDisplay.style.display = 'none'; - } - } -} - /** * Create a Cold Staking delegation transaction */