Skip to content

Commit

Permalink
Add blockheight in web library receive functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ssantos21 committed Sep 3, 2024
1 parent 0af1bd9 commit a370e0d
Show file tree
Hide file tree
Showing 18 changed files with 328 additions and 23 deletions.
11 changes: 8 additions & 3 deletions clients/libs/web/transfer_receive.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const sendTransferReceiverRequestPayload = async (clientConfig, transferReceiver

}

const processEncryptedMessage = async (clientConfig, coin, encMessage, network, serverInfo, activities) => {
const processEncryptedMessage = async (clientConfig, coin, encMessage, network, serverInfo, blockheight, activities) => {
let clientAuthKey = coin.auth_privkey;
let newUserPubkey = coin.user_pubkey;

Expand Down Expand Up @@ -182,8 +182,10 @@ const processEncryptedMessage = async (clientConfig, coin, encMessage, network,
transferMsg,
statechainInfo,
tx0Hex,
blockheight,
feeRateTolerance,
currentFeeRateSatsPerByte,
serverInfo.initlock,
serverInfo.interval
)

Expand Down Expand Up @@ -283,6 +285,9 @@ const execute = async (clientConfig, walletName) => {
let tempCoins = [...wallet.coins];
let tempActivities = [...wallet.activities];

const response = await axios.get(`${clientConfig.esploraServer}/api/blocks/tip/height`);
const blockheight = response.data;

for (let [authPubkey, encMessages] of encMsgsPerAuthPubkey.entries()) {

for (let encMessage of encMessages) {
Expand All @@ -291,7 +296,7 @@ const execute = async (clientConfig, walletName) => {

if (coin) {
try {
let messageResult = await processEncryptedMessage(clientConfig, coin, encMessage, wallet.network, serverInfo, tempActivities);
let messageResult = await processEncryptedMessage(clientConfig, coin, encMessage, wallet.network, serverInfo, blockheight, tempActivities);

if (messageResult.isBatchLocked) {
isThereBatchLocked = true;
Expand All @@ -310,7 +315,7 @@ const execute = async (clientConfig, walletName) => {
let newCoin = await mercury_wasm.duplicateCoinToInitializedState(wallet, authPubkey);

if (newCoin) {
let messageResult = await processEncryptedMessage(clientConfig, newCoin, encMessage, wallet.network, serverInfo, tempActivities);
let messageResult = await processEncryptedMessage(clientConfig, newCoin, encMessage, wallet.network, serverInfo, blockheight, tempActivities);

if (messageResult.isBatchLocked) {
isThereBatchLocked = true;
Expand Down
Loading

0 comments on commit a370e0d

Please sign in to comment.