@@ -10,16 +10,6 @@ import (
1010 "github.com/code-payments/code-server/pkg/metrics"
1111)
1212
13- const (
14- // These limits are intentionally higher than that enforced on clients,
15- // so we can do better rounding on limits per currency.
16- //
17- // todo: configurable
18- maxUsdPrivateBalance = 500.00 // 2x the 250 USD limit
19- maxUsdTransactionValue = 500.00 // 2x the 250 USD limit
20- maxDailyUsdLimit = 1500.00 // 1.5x the 1000 USD limit
21- )
22-
2313// AntiMoneyLaunderingGuard gates money movement by applying rules on operations
2414// of interest to discourage money laundering through Code.
2515type AntiMoneyLaunderingGuard struct {
@@ -40,97 +30,6 @@ func (g *AntiMoneyLaunderingGuard) AllowMoneyMovement(ctx context.Context, inten
4030 tracer := metrics .TraceMethodCall (ctx , metricsStructName , "AllowMoneyMovement" )
4131 defer tracer .End ()
4232
43- /*
44- var usdMarketValue float64
45- var consumptionCalculator func(ctx context.Context, phoneNumber string, since time.Time) (uint64, float64, error)
46- switch intentRecord.IntentType {
47- case intent.SendPublicPayment, intent.ReceivePaymentsPublicly:
48- // Public movements of money are not subject to AML rules. They are
49- // done in the open.
50- return true, nil
51- case intent.SendPrivatePayment:
52- usdMarketValue = intentRecord.SendPrivatePaymentMetadata.UsdMarketValue
53- consumptionCalculator = g.data.GetTransactedAmountForAntiMoneyLaundering
54- case intent.ReceivePaymentsPrivately:
55- // Allow users to always receive in-app payments from their temporary incoming
56- // accounts. The payment was already allowed when initiatied on the send side.
57- if !intentRecord.ReceivePaymentsPrivatelyMetadata.IsDeposit {
58- return true, nil
59- }
60-
61- owner, err := common.NewAccountFromPublicKeyString(intentRecord.InitiatorOwnerAccount)
62- if err != nil {
63- tracer.OnError(err)
64- return false, err
65- }
66-
67- totalPrivateBalance, err := balance.GetPrivateBalance(ctx, g.data, owner)
68- if err != nil {
69- tracer.OnError(err)
70- return false, err
71- }
72-
73- usdExchangeRecord, err := g.data.GetExchangeRate(ctx, currency_lib.USD, time.Now())
74- if err != nil {
75- tracer.OnError(err)
76- return false, err
77- }
78-
79- // Do they need the deposit based on total private balance? Note: clients
80- // always try to deposit the max as a mechanism of hiding in the crowd, so
81- // we can only consider the current balance and whether it makes sense.
82- if usdExchangeRecord.Rate*float64(kin.FromQuarks(totalPrivateBalance)) >= maxUsdPrivateBalance {
83- recordDenialEvent(ctx, "private balance exceeds threshold")
84- return false, nil
85- }
86-
87- // Otherwise, limit deposits in line with expectations for payments.
88- usdMarketValue = intentRecord.ReceivePaymentsPrivatelyMetadata.UsdMarketValue
89- consumptionCalculator = g.data.GetDepositedAmountForAntiMoneyLaundering
90- default:
91- err := errors.New("intent record must be a send or receive payment")
92- tracer.OnError(err)
93- return false, err
94- }
95-
96- if intentRecord.InitiatorPhoneNumber == nil {
97- err := errors.New("anti-money laundering guard requires an identity")
98- tracer.OnError(err)
99- return false, err
100- }
101-
102- log := g.log.WithFields(logrus.Fields{
103- "method": "AllowMoneyMovement",
104- "owner": intentRecord.InitiatorOwnerAccount,
105- "phone_number": *intentRecord.InitiatorPhoneNumber,
106- "usd_value": usdMarketValue,
107- })
108-
109- phoneNumber := *intentRecord.InitiatorPhoneNumber
110-
111- // Bound the maximum dollar value of a payment
112- if usdMarketValue > maxUsdTransactionValue {
113- log.Info("denying intent that exceeds per-transaction usd value")
114- recordDenialEvent(ctx, "exceeds per-transaction usd value")
115- return false, nil
116- }
117-
118- // Bound the maximum dollar value of payments in the last day
119- _, usdInLastDay, err := consumptionCalculator(ctx, phoneNumber, time.Now().Add(-24*time.Hour))
120- if err != nil {
121- log.WithError(err).Warn("failure calculating previous day transaction amount")
122- tracer.OnError(err)
123- return false, err
124- }
125-
126- if usdInLastDay+usdMarketValue > maxDailyUsdLimit {
127- log.Info("denying intent that exceeds daily usd limit")
128- recordDenialEvent(ctx, "exceeds daily usd value")
129- return false, nil
130- }
131-
132- return true, nil
133- */
134-
33+ // All movements of money are public, so no limits apply
13534 return true , nil
13635}
0 commit comments