From 7bf50657420d02bcd3d8d0019f0797bbe409f5ab Mon Sep 17 00:00:00 2001 From: void-57 Date: Wed, 17 Dec 2025 20:53:23 +0530 Subject: [PATCH] feat: Improve Stellar fee calculation, fix XDR parsing, and enhance send address UI with full address display and copy button. --- index.html | 19 ++++++++++++------- stellarBlockchainAPI.js | 8 +++++--- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index 244acf4..dd64556 100644 --- a/index.html +++ b/index.html @@ -417,9 +417,14 @@
0 XLM
-
- Address: - - +
+ +
+ - + +
@@ -1155,7 +1160,7 @@ const balanceEl = document.getElementById('send-balance'); balanceEl.innerHTML = accountInfo.balanceXlm.toFixed(7) + ' XLM'; - document.getElementById('send-from-address').textContent = address.substring(0, 12) + '...' + address.substring(address.length - 12); + document.getElementById('send-from-address').textContent = address; document.getElementById('send-wallet-info').style.display = 'block'; } catch (error) { document.getElementById('send-wallet-info').style.display = 'none'; @@ -1613,15 +1618,15 @@
Transaction Fee - ${feeXLM.toFixed(6)} XLM + ${feeXlm.toFixed(6)} XLM
Total Required - ${totalXLM.toFixed(6)} XLM + ${totalXlm.toFixed(6)} XLM
Shortfall - ${(totalXLM - currentBalance).toFixed(6)} XLM + ${(totalXlm - currentBalance).toFixed(6)} XLM
diff --git a/stellarBlockchainAPI.js b/stellarBlockchainAPI.js index 61c7093..948ae4b 100644 --- a/stellarBlockchainAPI.js +++ b/stellarBlockchainAPI.js @@ -247,7 +247,9 @@ // Get fee stats const feeStats = await server.feeStats(); - const fee = feeStats.max_fee.mode || (StellarSdk.BASE_FEE || '100'); + + // fee_charged.mode is typically 100 stroops (0.00001 XLM) + const fee = feeStats.fee_charged?.mode || feeStats.last_ledger_base_fee || '100'; // Build transaction let transaction = new StellarSdk.TransactionBuilder(sourceAccount, { @@ -311,8 +313,8 @@ } try { - // Parse the XDR back to a transaction - const transaction = new StellarSdk.Transaction(transactionXDR, StellarSdk.Networks.PUBLIC); + // Parse the XDR back to a transaction using TransactionBuilder + const transaction = StellarSdk.TransactionBuilder.fromXDR(transactionXDR, StellarSdk.Networks.PUBLIC); // Submit to network const result = await server.submitTransaction(transaction);