Skip to content

Commit

Permalink
pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
KonradStaniec committed Oct 16, 2024
1 parent 49640ac commit c485d35
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions stakerdb/trackedtranactionstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,12 +570,16 @@ func CreateTrackedTransaction(
return nil, fmt.Errorf("cannot add transaction without finality providers public keys")
}

var fpPubKeysBytes [][]byte = make([][]byte, len(fpPubKeys))
fpPubKeysBytes := make([][]byte, len(fpPubKeys))

for i, pk := range fpPubKeys {
fpPubKeysBytes[i] = schnorr.SerializePubKey(pk)
}

if pop == nil {
return nil, fmt.Errorf("cannot add transaction without proof of possession")
}

msg := proto.TrackedTransaction{
// Setting it to 0, proper number will be filled by `addTransactionInternal`
TrackedTransactionIdx: 0,
Expand Down Expand Up @@ -610,23 +614,27 @@ func (c *TrackedTransactionStore) AddTransactionSentToBabylon(
serializedTx, err := utils.SerializeBtcTransaction(btcTx)

if err != nil {
return err
return fmt.Errorf("failed to serialize Bitcoin transaction: %w", err)
}

if len(fpPubKeys) == 0 {
return fmt.Errorf("cannot add transaction without finality providers public keys")
}

var fpPubKeysBytes [][]byte = make([][]byte, len(fpPubKeys))
fpPubKeysBytes := make([][]byte, len(fpPubKeys))

for i, pk := range fpPubKeys {
fpPubKeysBytes[i] = schnorr.SerializePubKey(pk)
}

if pop == nil {
return fmt.Errorf("cannot add transaction without proof of possession")
}

update, err := newInitialUnbondingTxData(unbondingTx, unbondingTime)

if err != nil {
return err
return fmt.Errorf("failed to create unbonding transaction data: %w", err)
}

msg := proto.TrackedTransaction{
Expand All @@ -646,7 +654,7 @@ func (c *TrackedTransactionStore) AddTransactionSentToBabylon(
}

return c.addTransactionInternal(
txHashBytes, &msg, nil,
txHashBytes[:], &msg, nil,
)
}

Expand All @@ -663,19 +671,23 @@ func (c *TrackedTransactionStore) AddTransaction(
serializedTx, err := utils.SerializeBtcTransaction(btcTx)

if err != nil {
return err
return fmt.Errorf("failed to serialize Bitcoin transaction: %w", err)
}

if len(fpPubKeys) == 0 {
return fmt.Errorf("cannot add transaction without finality providers public keys")
}

var fpPubKeysBytes [][]byte = make([][]byte, len(fpPubKeys))
fpPubKeysBytes := make([][]byte, len(fpPubKeys))

for i, pk := range fpPubKeys {
fpPubKeysBytes[i] = schnorr.SerializePubKey(pk)
}

if pop == nil {
return fmt.Errorf("cannot add transaction without proof of possession")
}

msg := proto.TrackedTransaction{
// Setting it to 0, proper number will be filled by `addTransactionInternal`
TrackedTransactionIdx: 0,
Expand All @@ -693,7 +705,7 @@ func (c *TrackedTransactionStore) AddTransaction(
}

return c.addTransactionInternal(
txHashBytes, &msg, nil,
txHashBytes[:], &msg, nil,
)
}

Expand Down

0 comments on commit c485d35

Please sign in to comment.