Wait for boarding tx confirmation server-side (#129)

* wait for onboarding confirmation server side

* Update server/internal/core/application/service.go

Co-authored-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com>
Signed-off-by: Louis Singer <41042567+louisinger@users.noreply.github.com>

* Update server/internal/core/application/service.go

Co-authored-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com>
Signed-off-by: Louis Singer <41042567+louisinger@users.noreply.github.com>

* handleOnboarding func: sleep 30s if an error happens then retry

---------

Signed-off-by: Louis Singer <41042567+louisinger@users.noreply.github.com>
Co-authored-by: Pietralberto Mazza <18440657+altafan@users.noreply.github.com>
This commit is contained in:
Louis Singer
2024-03-08 17:24:47 +01:00
committed by GitHub
parent 767935407d
commit 834af545de
2 changed files with 81 additions and 38 deletions

View File

@@ -3,7 +3,6 @@ package main
import (
"encoding/hex"
"fmt"
"time"
arkv1 "github.com/ark-network/ark/api-spec/protobuf/gen/ark/v1"
"github.com/ark-network/ark/common/tree"
@@ -99,16 +98,6 @@ func onboardAction(ctx *cli.Context) error {
return err
}
fmt.Println("onboard_txid:", txid)
fmt.Println("waiting for confirmation... (this may take up to a minute, do not cancel the process)")
// wait for the transaction to be confirmed
if err := waitForTxConfirmation(ctx, txid); err != nil {
return err
}
fmt.Println("transaction confirmed")
congestionTree, err := treeFactoryFn(psetv2.InputArgs{
Txid: txid,
TxIndex: 0,
@@ -133,17 +122,7 @@ func onboardAction(ctx *cli.Context) error {
return err
}
return nil
}
func waitForTxConfirmation(ctx *cli.Context, txid string) error {
isConfirmed := false
for !isConfirmed {
time.Sleep(5 * time.Second)
isConfirmed, _, _ = getTxBlocktime(txid)
}
fmt.Println("onboard_txid:", txid)
return nil
}