Skip to content

Commit

Permalink
Intent.IsValid special-case openSession as it does not need to be signed
Browse files Browse the repository at this point in the history
  • Loading branch information
marino39 committed Dec 1, 2023
1 parent c39e106 commit df32814
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions intents/intent.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ func (intent *Intent) Signers() []string {
}

func (intent *Intent) IsValid() bool {
// Check if the packet is valid
var packet packets.BasePacket
err := json.Unmarshal(intent.Packet, &packet)
if err != nil {
return false
}

// OpenSession packets do not require signatures
if packet.Code == packets.OpenSessionPacketCode {
return packet.IsValid()
}

// Check if there are any signatures
if len(intent.signatures) == 0 {
return false
Expand All @@ -92,12 +104,6 @@ func (intent *Intent) IsValid() bool {
}

// Check if the packet is valid
var packet packets.BasePacket
err := json.Unmarshal(intent.Packet, &packet)
if err != nil {
return false
}

return packet.IsValid()
}

Expand Down

0 comments on commit df32814

Please sign in to comment.