Skip to content

Commit

Permalink
pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
KonradStaniec committed Feb 12, 2024
1 parent f765f1e commit db0bcb9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
7 changes: 7 additions & 0 deletions types/btc_schnorr_sig.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package types

import (
"encoding/hex"
"errors"

"github.com/btcsuite/btcd/btcec/v2/schnorr"
)
Expand All @@ -11,8 +12,14 @@ type BIP340Signature []byte
const BIP340SignatureLen = schnorr.SignatureSize

func NewBIP340Signature(data []byte) (*BIP340Signature, error) {

var sig BIP340Signature
err := sig.Unmarshal(data)

if _, err := sig.ToBTCSig(); err != nil {
return nil, errors.New("bytes cannot be converted to a *schnorr.Signature object")
}

return &sig, err
}

Expand Down
16 changes: 4 additions & 12 deletions x/btcstaking/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ func (m *MsgCreateBTCDelegation) ValidateBasic() error {
return fmt.Errorf("empty delegator signature")
}

_, err := m.DelegatorSlashingSig.ToBTCSig()

if err != nil {
if _, err := m.DelegatorSlashingSig.ToBTCSig(); err != nil {
return fmt.Errorf("invalid delegator slashing signature: %w", err)
}

Expand Down Expand Up @@ -128,9 +126,7 @@ func (m *MsgCreateBTCDelegation) ValidateBasic() error {
return fmt.Errorf("invalid unbonding slashing tx: %w", err)
}

_, err = m.DelegatorUnbondingSlashingSig.ToBTCSig()

if err != nil {
if _, err := m.DelegatorUnbondingSlashingSig.ToBTCSig(); err != nil {
return fmt.Errorf("invalid delegator unbonding slashing signature: %w", err)
}

Expand Down Expand Up @@ -169,9 +165,7 @@ func (m *MsgAddCovenantSigs) ValidateBasic() error {
return fmt.Errorf("empty covenant signature")
}

_, err := m.UnbondingTxSig.ToBTCSig()

if err != nil {
if _, err := m.UnbondingTxSig.ToBTCSig(); err != nil {
return fmt.Errorf("invalid covenant unbonding signature: %w", err)
}

Expand All @@ -191,9 +185,7 @@ func (m *MsgBTCUndelegate) ValidateBasic() error {
return fmt.Errorf("empty signature from the delegator")
}

_, err := m.UnbondingTxSig.ToBTCSig()

if err != nil {
if _, err := m.UnbondingTxSig.ToBTCSig(); err != nil {
return fmt.Errorf("invalid delegator unbonding signature: %w", err)
}

Expand Down

0 comments on commit db0bcb9

Please sign in to comment.