diff --git a/clients/apps/nodejs/test_basic_workflow2.js b/clients/apps/nodejs/test_basic_workflow2.js index 83b72d3d..8f432928 100644 --- a/clients/apps/nodejs/test_basic_workflow2.js +++ b/clients/apps/nodejs/test_basic_workflow2.js @@ -909,7 +909,7 @@ async function transferSendAtCoinExpiry(clientConfig, wallet_1_name, wallet_2_na console.log("coin: ", coin); - const electrumClient = await mercurynodejslib.getElectrumClient(clientConfig); + const electrumClient = await getElectrumClient(clientConfig); const blockHeader = await electrumClient.request('blockchain.headers.subscribe'); // request(promise) const currentBlockheight = blockHeader.height; @@ -974,7 +974,7 @@ async function transferReceiveAtCoinExpiry(clientConfig, wallet_1_name, wallet_2 coin = await mercurynodejslib.transferSend(clientConfig, wallet_1_name, coin.statechain_id, transfer_address.transfer_receive); - const electrumClient = await mercurynodejslib.getElectrumClient(clientConfig); + const electrumClient = await getElectrumClient(clientConfig); const blockHeader = await electrumClient.request('blockchain.headers.subscribe'); // request(promise) const currentBlockheight = blockHeader.height; @@ -1041,7 +1041,7 @@ async function transferSendCoinExpiryBySending(clientConfig, wallet_1_name, wall console.log("coin: ", coin); - const electrumClient = await mercurynodejslib.getElectrumClient(clientConfig); + const electrumClient = await getElectrumClient(clientConfig); const blockHeader = await electrumClient.request('blockchain.headers.subscribe'); // request(promise) const currentBlockheight = blockHeader.height; @@ -1154,7 +1154,7 @@ async function transferSendCoinExpiryBySending(clientConfig, wallet_1_name, wall assert.fail("Expected error when sending backup tx before expiry, but no error was thrown"); } catch (error) { console.log("Expected error received: ", error.message); - assert(error.message.includes("The coin is expired."), + assert(error.message.includes("The coin is not expired yet."), `Unexpected error message: ${error.message}`); } console.log("Completed test for send backup tx before expiry"); diff --git a/clients/libs/nodejs/broadcast_backup_tx.js b/clients/libs/nodejs/broadcast_backup_tx.js index c7ed9d47..67ad7eda 100644 --- a/clients/libs/nodejs/broadcast_backup_tx.js +++ b/clients/libs/nodejs/broadcast_backup_tx.js @@ -45,8 +45,8 @@ const execute = async (clientConfig, electrumClient, db, walletName, statechainI const blockHeader = await electrumClient.request('blockchain.headers.subscribe'); // request(promise) const currentBlockheight = blockHeader.height; - if (currentBlockheight > coin.locktime) { - throw new Error(`The coin is expired. Coin locktime is ${coin.locktime} and current blockheight is ${currentBlockheight}`); + if (currentBlockheight <= coin.locktime) { + throw new Error(`The coin is not expired yet. Coin locktime is ${coin.locktime} and current blockheight is ${currentBlockheight}`); } const backupTx = mercury_wasm.latestBackuptxPaysToUserpubkey(backupTxs, coin, wallet.network);