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.