Skip to content

Commit

Permalink
fix: error message for electrs unavailability
Browse files Browse the repository at this point in the history
  • Loading branch information
DhananjayPurohit committed Jun 20, 2024
1 parent 01b0337 commit 8e26312
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions clients/apps/nodejs/test_basic_workflow2.js
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ async function interruptSignWithElectrumUnavailability(clientConfig, wallet_1_na
assert.fail("Expected error when transferring from wallet one, but no error was thrown");
} catch (error) {
console.log("Expected error received: ", error.message);
assert(error.message.includes("Error getting fee rate from electrum server"),
assert(error.message.includes("Error getting fee rate from electrs server"),
`Unexpected error message: ${error.message}`);
}
console.log("Connect mercurylayer_electrs_1 from network");
Expand Down Expand Up @@ -801,7 +801,7 @@ async function interruptTransferReceiveWithElectrumUnavailability(clientConfig,
assert.fail("Expected error when receiving into wallet two, but no error was thrown");
} catch (error) {
console.log("Expected error received: ", error.message);
assert(error.message.includes("Error getting fee rate from electrum server"),
assert(error.message.includes("Error getting unspent list from electrs server"),
`Unexpected error message: ${error.message}`);
}
console.log("Connect mercurylayer_electrs_1 from network");
Expand Down
8 changes: 6 additions & 2 deletions clients/libs/nodejs/coin_status.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ const checkDeposit = async (clientConfig, electrumClient, coin, wallet_network)
reversedHash = reversedHash.toString('hex');

let utxo = null;

let utxo_list = await electrumClient.request('blockchain.scripthash.listunspent', [reversedHash]);
let utxo_list = null;
try {
utxo_list = await electrumClient.request('blockchain.scripthash.listunspent', [reversedHash]);
} catch (error) {
throw new Error("Error getting unspent list from electrs server");
}

for (let unspent of utxo_list) {
if (unspent.value === coin.amount) {
Expand Down
2 changes: 1 addition & 1 deletion clients/libs/nodejs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const infoConfig = async (clientConfig, ecl) => {
try {
fee_rate_btc_per_kb = await ecl.request('blockchain.estimatefee', [3]); // request(promise)
} catch (error) {
throw new Error("Error getting fee rate from electrum server");
throw new Error("Error getting fee rate from electrs server");
}

console.log("fee_rate_btc_per_kb:", fee_rate_btc_per_kb);
Expand Down

0 comments on commit 8e26312

Please sign in to comment.