Skip to content

Commit

Permalink
Fixes for linter
Browse files Browse the repository at this point in the history
  • Loading branch information
galt-tr committed Jan 16, 2024
1 parent 435b353 commit 2cef447
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
7 changes: 4 additions & 3 deletions app/models/alert_message_confiscate_utxo.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ type AlertMessageConfiscateTransaction struct {
Transactions []models.ConfiscationTransactionDetails
}

// ConfiscateTransaction defines the parameters for the confiscation transaction
type ConfiscateTransaction struct {
EnforceAtHeight [8]byte
Id [32]byte
ID [32]byte
}

// Read reads the alert
Expand All @@ -34,12 +35,12 @@ func (a *AlertMessageConfiscateTransaction) Read(raw []byte) error {
for i := 0; i < txCount; i++ {
tx := ConfiscateTransaction{
EnforceAtHeight: [8]byte(raw[:8]),
Id: [32]byte(raw[8:40]),
ID: [32]byte(raw[8:40]),
}
detail := models.ConfiscationTransactionDetails{
ConfiscationTransaction: models.ConfiscationTransaction{
EnforceAtHeight: int64(binary.LittleEndian.Uint64(tx.EnforceAtHeight[:])),
Hex: hex.EncodeToString(tx.Id[:]),
Hex: hex.EncodeToString(tx.ID[:]),
},
}
details = append(details, detail)
Expand Down
10 changes: 6 additions & 4 deletions app/models/alert_message_freeze_utxo.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ type AlertMessageFreezeUtxo struct {
Funds []models.Fund
}

// Fund is the struct defining funds to freeze
type Fund struct {
TransactionOutId [32]byte
TransactionOutID [32]byte
Vout uint64
EnforceAtHeightStart uint64
EnforceAtHeightEnd uint64
PolicyExpiresWithConsensus bool
}

// Serialize creates the raw hex string of the fund
func (f *Fund) Serialize() []byte {
raw := []byte{}
raw = append(raw, f.TransactionOutId[:]...)
raw = append(raw, f.TransactionOutID[:]...)
raw = binary.LittleEndian.AppendUint64(raw, f.Vout)
raw = binary.LittleEndian.AppendUint64(raw, f.EnforceAtHeightStart)
raw = binary.LittleEndian.AppendUint64(raw, f.EnforceAtHeightEnd)
Expand All @@ -49,7 +51,7 @@ func (a *AlertMessageFreezeUtxo) Read(raw []byte) error {
funds := []models.Fund{}
for i := 0; i < fundCount; i++ {
fund := Fund{
TransactionOutId: [32]byte(raw[0:32]),
TransactionOutID: [32]byte(raw[0:32]),
Vout: binary.LittleEndian.Uint64(raw[32:40]),
EnforceAtHeightStart: binary.LittleEndian.Uint64(raw[40:48]),
EnforceAtHeightEnd: binary.LittleEndian.Uint64(raw[48:56]),
Expand All @@ -61,7 +63,7 @@ func (a *AlertMessageFreezeUtxo) Read(raw []byte) error {
}
funds = append(funds, models.Fund{
TxOut: models.TxOut{
TxId: hex.EncodeToString(fund.TransactionOutId[:]),
TxId: hex.EncodeToString(fund.TransactionOutID[:]),
Vout: int(fund.Vout),
},
EnforceAtHeight: []models.Enforce{
Expand Down
10 changes: 5 additions & 5 deletions hack/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ func main() {
case models.AlertTypeUnbanPeer:
//a = UnbanPeerAlert(*sequenceNumber, *peer)
case models.AlertTypeConfiscateUtxo:
a = ConfiscateAlert(*sequenceNumber, model.WithAllDependencies(_appConfig))
a = confiscateAlert(*sequenceNumber, model.WithAllDependencies(_appConfig))
case models.AlertTypeFreezeUtxo:
a = FreezeAlert(*sequenceNumber, model.WithAllDependencies(_appConfig))
a = freezeAlert(*sequenceNumber, model.WithAllDependencies(_appConfig))
case models.AlertTypeUnfreezeUtxo:
panic(fmt.Errorf("not implemented"))
case models.AlertTypeSetKeys:
Expand Down Expand Up @@ -141,10 +141,10 @@ func InfoAlert(seq uint, opts ...model.Options) *models.AlertMessage {
return newAlert
}

func FreezeAlert(seq uint, opts ...model.Options) *models.AlertMessage {
func freezeAlert(seq uint, opts ...model.Options) *models.AlertMessage {
tx, _ := hex.DecodeString("d83dee7aec89a9437345d9676bc727a2592e5b3988f4343931181f86b666eace")
fund := models.Fund{
TransactionOutId: [32]byte(tx),
TransactionOutID: [32]byte(tx),
Vout: uint64(0),
EnforceAtHeightStart: uint64(10000),
EnforceAtHeightEnd: uint64(10100),
Expand All @@ -161,7 +161,7 @@ func FreezeAlert(seq uint, opts ...model.Options) *models.AlertMessage {
return newAlert
}

func ConfiscateAlert(seq uint, opts ...model.Options) *models.AlertMessage {
func confiscateAlert(seq uint, opts ...model.Options) *models.AlertMessage {
tx := models2.ConfiscationTransactionDetails{
ConfiscationTransaction: models2.ConfiscationTransaction{
Hex: "dd1b08331cf22da4d27bd1b29019a04a168805d49b48d65a7fec381eb4307d61",
Expand Down

0 comments on commit 2cef447

Please sign in to comment.