Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
chore(BUX-322): cast bumpIndex to uint
Browse files Browse the repository at this point in the history
  • Loading branch information
pawellewandowski98 committed Nov 27, 2023
1 parent 4d070a4 commit fcb1d74
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions paymail_service_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ func saveBEEFTxInputs(ctx context.Context, c ClientInterface, p2pTx *paymail.P2P
return
}

inputsToAdd, err := getInputsWhichAreNotInDb(ctx, c, p2pTx)
inputsToAdd, err := getInputsWhichAreNotInDb(c, p2pTx)
if err != nil {
c.Logger().Error(ctx, "error in saveBEEFTxInputs", err)
}
Expand All @@ -342,10 +342,11 @@ func saveBEEFTxInputs(ctx context.Context, c ClientInterface, p2pTx *paymail.P2P
}

func getBump(p2pTx *paymail.P2PTransaction, input *beef.TxData) (*BUMP, error) {
if input.BumpIndex.Length() > len(p2pTx.DecodedBeef.BUMPs) {
bumpIndex := uint(input.BumpIndex.Length())
if bumpIndex > uint(len(p2pTx.DecodedBeef.BUMPs)) {
return nil, fmt.Errorf("error in getBump: bump index exceeds bumps length")
}
bump := p2pTx.DecodedBeef.BUMPs[input.BumpIndex.Length()]
bump := p2pTx.DecodedBeef.BUMPs[bumpIndex]
paths := make([][]BUMPLeaf, 0)

for _, path := range bump.Path {
Expand All @@ -367,7 +368,7 @@ func getBump(p2pTx *paymail.P2PTransaction, input *beef.TxData) (*BUMP, error) {
}, nil
}

func getInputsWhichAreNotInDb(ctx context.Context, c ClientInterface, p2pTx *paymail.P2PTransaction) ([]*beef.TxData, error) {
func getInputsWhichAreNotInDb(c ClientInterface, p2pTx *paymail.P2PTransaction) ([]*beef.TxData, error) {
var txIDs []string
for _, tx := range p2pTx.DecodedBeef.Transactions {
txIDs = append(txIDs, tx.GetTxID())
Expand Down

0 comments on commit fcb1d74

Please sign in to comment.