Skip to content

Commit 787cb2a

Browse files
committed
tapfreighter: add context to coin select errors
1 parent cf46190 commit 787cb2a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tapfreighter/coin_select.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ func (s *CoinSelect) SelectCoins(ctx context.Context,
8585
},
8686
)
8787
if len(compatibleCommitments) == 0 {
88-
return nil, ErrMatchingAssetsNotFound
88+
return nil, fmt.Errorf("%w: no compatible commitments for max "+
89+
"version %v", ErrMatchingAssetsNotFound, maxVersion)
8990
}
9091

9192
selectedCoins, err := s.selectForAmount(
@@ -191,7 +192,9 @@ func (s *CoinSelect) selectForAmount(minTotalAmount uint64,
191192
// Having examined all the eligible commitments, return an error if the
192193
// minimal funding amount was not reached.
193194
if amountSum < minTotalAmount {
194-
return nil, ErrMatchingAssetsNotFound
195+
return nil, fmt.Errorf("%w: insufficient amount available, "+
196+
"have %d, want %d", ErrMatchingAssetsNotFound,
197+
amountSum, minTotalAmount)
195198
}
196199
return selectedCommitments, nil
197200
}

0 commit comments

Comments
 (0)