diff --git a/go.mod b/go.mod index c2bc224..4439327 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index efc5573..4cce2a0 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/ocp/currency/validation.go b/ocp/currency/validation.go index 070dd93..097a490 100644 --- a/ocp/currency/validation.go +++ b/ocp/currency/validation.go @@ -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. diff --git a/ocp/rpc/messaging/message_handler.go b/ocp/rpc/messaging/message_handler.go index 988c04c..6e9c46c 100644 --- a/ocp/rpc/messaging/message_handler.go +++ b/ocp/rpc/messaging/message_handler.go @@ -1,6 +1,7 @@ package messaging import ( + "bytes" "context" "github.com/pkg/errors" @@ -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 }