0

I'm trying to develop a non-custodial wallet and would like to understand how I can manage unlocked balances in Monero. If every 20 minutes I can use my balance for each transaction, will users from my front end necessarily have to wait for these times to be able to operate?

Anyway, I wrote this code, I waited about 20min and I managed to get the Unlocked Balance, it creates the tx with creatTx but it returns this error at the end in the submit:

async function signAndSend(toAddress, amount) {
    // Ottenimento del saldo del portafoglio
    //await syncWallet(wallet)
    let wallet = await openWallet("MoneroRoot",51)
    let height=await wallet.getHeight()
    let sync=await syncWallet(wallet,height)
    console.log("!!!!!!!")
    console.log(sync)

    const balance=await getBalance(wallet)
    console.log(balance)

    let fromAddress=await wallet.getAddress(0,0)
    console.log(fromAddress)

    let unlockedBalance = await getUnlockedBalance(wallet)
    console.log(unlockedBalance)
    // Creazione della configurazione della transazione
    
    let amountInAtomic= ATOMICUNIT_PER_XMR*amount
    console.log("!!!!!!!!!!!!!!TXCONFIG!!!!!!!!!")

    // Creazione della transazione
    const unsignedTx = await wallet.createTx({
      accountIndex: 0,  
      address: toAddress,
      amount: amountInAtomic.toString(), 
      relay: true 
    });

    console.log(unsignedTx)
    console.log("!!!!!!!!!!!!!!33333333")
    
    
    let signedTxHex=unsignedTx.getHash()
    console.log(signedTxHex)
    console.log("ERROR here")
    // Connessione al daemon per inviare la transazione
    let txHashes = await wallet.submitTxs(signedTxHex);
    console.log(txHashes)
}

Logs this error:

MoneroError: Failed to parse signed tx: Failed to parse signed tx data.

1 Answer 1

1
  1. You don't mention which Monero javascript library you're using. I'm going to assume monero-ecosystem/monero-javascript.

  2. createTx you are creating a signed transaction, and broadcasting it (relay: true).

  3. Because of the above point, you can't call submitTxs (it's already submitted/broadcast, as far as the wallet is concerned), and so you'll get some error.

  4. If every 20 minutes I can use my balance for each transaction, will users from my front end necessarily have to wait for these times to be able to operate??

    Nobody can spend any output until the output 10 blocks confirmed (~20 minutes).

4
  • I understand. Do you know how can i handle the signing part when i use the createTx function, because monero needs that i confirm it with the wallet password.
    – AlexCav
    Jul 19, 2023 at 16:35
  • "Do you know how can i handle the signing part" <- please read my answer for point 2.
    – jtgrassie
    Jul 19, 2023 at 20:27
  • i read your answer. When i use the function, Monero requires the insert of the passward. Is it normal?
    – AlexCav
    Jul 19, 2023 at 23:56
  • There are several types of wallet that that 3rd-party library offers. You do not specify which type. Calling openWallet you need to provide a number of parameters, one of which is the password. There's also no documented global openWallet method (it would be openWalletFull).
    – jtgrassie
    Jul 20, 2023 at 1:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.