mirror of
https://github.com/aljazceru/ark.git
synced 2026-01-22 13:14:19 +01:00
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user