Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/core/application/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3549,11 +3549,11 @@ func (s *service) scheduleSweepBatchOutput(round domain.Round) {

blockTimestamp, err := waitForConfirmation(context.Background(), round.CommitmentTxid, s.wallet)
if err != nil {
log.WithError(err).Warnf(
"failed to wait for confirmation of commitment tx %s, schedule task time may be inaccurate",
log.WithError(err).Errorf(
"wallet unavailable; cannot schedule sweep for %s — will be picked up on next startup",
round.CommitmentTxid,
)
blockTimestamp = &ports.BlockTimestamp{Time: time.Now().Unix()}
return
}

var expirationTimestamp int64
Expand Down
11 changes: 7 additions & 4 deletions internal/core/application/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,13 @@ func waitForConfirmation(
return nil, ctx.Err()
case <-ticker.C:
confirmed, blockTimestamp, err := wallet.IsTransactionConfirmed(ctx, txid)
if confirmed && err == nil {
if err != nil {
log.WithError(err).Warnf(
"transient error checking confirmation of %s; will retry on next tick", txid,
)
continue
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
if confirmed {
log.Debugf(
"tx %s confirmed at block height %d, block time %d",
txid,
Expand All @@ -550,9 +556,6 @@ func waitForConfirmation(
)
return blockTimestamp, nil
}
if err != nil {
return nil, err
}
}
}
}
Expand Down
18 changes: 16 additions & 2 deletions internal/infrastructure/wallet/wallet_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import (
"encoding/hex"
"fmt"
"strings"
"time"

"github.com/arkade-os/arkd/internal/core/domain"
arklib "github.com/arkade-os/arkd/pkg/ark-lib"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/wire"
grpc_retry "github.com/grpc-ecosystem/go-grpc-middleware/retry"
log "github.com/sirupsen/logrus"

arkwalletv1 "github.com/arkade-os/arkd/api-spec/protobuf/gen/arkwallet/v1"
Expand All @@ -32,6 +34,14 @@ func New(addr, otelCollectorEndpoint string) (ports.WalletService, *arklib.Netwo
opts := []grpc.DialOption{
grpc.WithTransportCredentials(insecure.NewCredentials()),
}
retryOpts := []grpc_retry.CallOption{
grpc_retry.WithMax(5),
grpc_retry.WithBackoff(grpc_retry.BackoffExponential(100 * time.Millisecond)),
grpc_retry.WithCodes(codes.Unavailable, codes.DeadlineExceeded, codes.ResourceExhausted),
}

opts = append(opts, grpc.WithUnaryInterceptor(grpc_retry.UnaryClientInterceptor(retryOpts...)))

if otelCollectorEndpoint != "" {
otelHandler := otelgrpc.NewClientHandler(
otelgrpc.WithTracerProvider(otel.GetTracerProvider()),
Expand Down Expand Up @@ -441,8 +451,12 @@ func (w *walletDaemonClient) GetCurrentBlockTime(
func (w *walletDaemonClient) Withdraw(
ctx context.Context, address string, amount uint64, all bool,
) (string, error) {
resp, err := w.client.Withdraw(ctx, &arkwalletv1.WithdrawRequest{
Address: address, Amount: amount, All: all},
// Withdraw moves funds to an external address; retrying after an
// ambiguous failure could double-spend, so opt out of the interceptor.
resp, err := w.client.Withdraw(
ctx,
&arkwalletv1.WithdrawRequest{Address: address, Amount: amount, All: all},
grpc_retry.WithMax(0),
)
if err != nil {
return "", err
Expand Down
Loading