Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
filippo.io/edwards25519 v1.1.0
github.com/aws/aws-sdk-go-v2 v0.17.0
github.com/code-payments/code-vm-indexer v1.2.0
github.com/code-payments/ocp-protobuf-api v0.14.0
github.com/code-payments/ocp-protobuf-api v0.15.0
github.com/emirpasic/gods v1.12.0
github.com/envoyproxy/protoc-gen-validate v1.2.1
github.com/golang/protobuf v1.5.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/code-payments/code-vm-indexer v1.2.0 h1:rSHpBMiT9BKgmKcXg/VIoi/h0t7jNxGx07Qz59m+6Q0=
github.com/code-payments/code-vm-indexer v1.2.0/go.mod h1:vn91YN2qNqb+gGJeZe2+l+TNxVmEEiRHXXnIn2Y40h8=
github.com/code-payments/ocp-protobuf-api v0.14.0 h1:M3lYKl2Af5B+HZkhPzKt00+PENy8KpC4YcKB8THb7V0=
github.com/code-payments/ocp-protobuf-api v0.14.0/go.mod h1:tw6BooY5a8l6CtSZnKOruyKII0W04n89pcM4BizrgG8=
github.com/code-payments/ocp-protobuf-api v0.15.0 h1:5E+m3IQZwi2sIpX8HJaIai284pLmUESutRmN0GFZ4F8=
github.com/code-payments/ocp-protobuf-api v0.15.0/go.mod h1:tw6BooY5a8l6CtSZnKOruyKII0W04n89pcM4BizrgG8=
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6 h1:NmTXa/uVnDyp0TY5MKi197+3HWcnYWfnHGyaFthlnGw=
github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
Expand Down
4 changes: 2 additions & 2 deletions ocp/currency/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ const (
defaultPrecision = 128

// maxVerifiedExchangeRateAge is the maximum age of a verified exchange rate
maxVerifiedExchangeRateAge = 15 * time.Minute
maxVerifiedExchangeRateAge = 10 * time.Minute

// maxVerifiedReserveStateAge is the maximum age of a verified reserve state
maxVerifiedReserveStateAge = 2 * time.Minute
maxVerifiedReserveStateAge = 10 * time.Minute
)

// ValidateVerifiedExchangeRate validates a server-signed exchange rate provided by a client.
Expand Down
17 changes: 17 additions & 0 deletions ocp/rpc/messaging/message_handler.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package messaging

import (
"bytes"
"context"

"github.com/pkg/errors"
Expand Down Expand Up @@ -97,6 +98,22 @@ func (h *RequestToGiveBillMessageHandler) Validate(ctx context.Context, rendezvo
return newMessageValidationError("mint account must be the core mint or a launchpad currency")
}

if typedMessage.ExchangeData != nil {
if common.IsCoreMint(mintAccount) {
if typedMessage.ExchangeData.LaunchpadCurrencyReserveState != nil {
return newMessageValidationError("reserve state cannot be provided for core mint")
}
} else {
if typedMessage.ExchangeData.LaunchpadCurrencyReserveState == nil {
return newMessageValidationError("reserve state is required for launchpad currency")
}

if !bytes.Equal(mintAccount.PublicKey().ToBytes(), typedMessage.ExchangeData.Mint.Value) {
return newMessageValidationError("reserve state mint doesn't match top-level mint")
}
}
}

return nil
}

Expand Down
Loading