@@ -12,6 +12,7 @@ import (
12
12
"github.com/pkg/errors"
13
13
"google.golang.org/protobuf/proto"
14
14
15
+ commonpb "github.com/code-payments/code-protobuf-api/generated/go/common/v1"
15
16
messagingpb "github.com/code-payments/code-protobuf-api/generated/go/messaging/v1"
16
17
transactionpb "github.com/code-payments/code-protobuf-api/generated/go/transaction/v2"
17
18
@@ -121,12 +122,56 @@ func (r *trustedPaymentRequest) ToKikCodePayload() *kikcode.Payload {
121
122
return r .kikCodePayload
122
123
}
123
124
124
- func (r * trustedPaymentRequest ) ToProtoMessage () * messagingpb.Message {
125
- return getRequestToReceiveBillMessage (
126
- r .currency ,
127
- r .nativeAmount ,
128
- r .destination ,
129
- )
125
+ func (r * trustedPaymentRequest ) ToProtoMessageWithVerifidDomain (domain * string , domainVerifier * common.Account ) * messagingpb.Message {
126
+ var msg * messagingpb.RequestToReceiveBill
127
+ if r .currency == currency_lib .KIN {
128
+ quarks := kin .ToQuarks (uint64 (r .nativeAmount ))
129
+ if int (100.0 * r .nativeAmount )% 100.0 != 0 {
130
+ quarks += kin .ToQuarks (1 )
131
+ }
132
+
133
+ msg = & messagingpb.RequestToReceiveBill {
134
+ ExchangeData : & messagingpb.RequestToReceiveBill_Exact {
135
+ Exact : & transactionpb.ExchangeData {
136
+ Currency : string (r .currency ),
137
+ ExchangeRate : 1.0 ,
138
+ NativeAmount : r .nativeAmount ,
139
+ Quarks : quarks ,
140
+ },
141
+ },
142
+ }
143
+ } else {
144
+ msg = & messagingpb.RequestToReceiveBill {
145
+ ExchangeData : & messagingpb.RequestToReceiveBill_Partial {
146
+ Partial : & transactionpb.ExchangeDataWithoutRate {
147
+ Currency : string (r .currency ),
148
+ NativeAmount : r .nativeAmount ,
149
+ },
150
+ },
151
+ }
152
+ }
153
+
154
+ msg .RequestorAccount = r .destination .ToProto ()
155
+
156
+ if domain != nil {
157
+ msg .Domain = & commonpb.Domain {
158
+ Value : * domain ,
159
+ }
160
+
161
+ if domainVerifier != nil {
162
+ msg .Verifier = domainVerifier .ToProto ()
163
+ msg .RendezvousKey = & messagingpb.RendezvousKey {
164
+ Value : r .privateRendezvousKey .ToProto ().Value ,
165
+ }
166
+ msg .Signature , _ = signProtoMessage (msg , domainVerifier )
167
+ }
168
+ }
169
+
170
+ return & messagingpb.Message {
171
+ Kind : & messagingpb.Message_RequestToReceiveBill {
172
+ RequestToReceiveBill : msg ,
173
+ },
174
+ }
130
175
}
131
176
132
177
func (r * trustedPaymentRequest ) GetIdempotencyKey () kikcode.IdempotencyKey {
@@ -276,46 +321,3 @@ func (r *trustlessPaymentRequest) ToProtoMessage() *messagingpb.Message {
276
321
},
277
322
}
278
323
}
279
-
280
- func getRequestToReceiveBillMessage (
281
- currency currency_lib.Code ,
282
- nativeAmount float64 ,
283
- destination * common.Account ,
284
- ) * messagingpb.Message {
285
- if currency == currency_lib .KIN {
286
- quarks := kin .ToQuarks (uint64 (nativeAmount ))
287
- if int (100.0 * nativeAmount )% 100.0 != 0 {
288
- quarks += kin .ToQuarks (1 )
289
- }
290
-
291
- return & messagingpb.Message {
292
- Kind : & messagingpb.Message_RequestToReceiveBill {
293
- RequestToReceiveBill : & messagingpb.RequestToReceiveBill {
294
- RequestorAccount : destination .ToProto (),
295
- ExchangeData : & messagingpb.RequestToReceiveBill_Exact {
296
- Exact : & transactionpb.ExchangeData {
297
- Currency : string (currency ),
298
- ExchangeRate : 1.0 ,
299
- NativeAmount : nativeAmount ,
300
- Quarks : quarks ,
301
- },
302
- },
303
- },
304
- },
305
- }
306
- }
307
-
308
- return & messagingpb.Message {
309
- Kind : & messagingpb.Message_RequestToReceiveBill {
310
- RequestToReceiveBill : & messagingpb.RequestToReceiveBill {
311
- RequestorAccount : destination .ToProto (),
312
- ExchangeData : & messagingpb.RequestToReceiveBill_Partial {
313
- Partial : & transactionpb.ExchangeDataWithoutRate {
314
- Currency : string (currency ),
315
- NativeAmount : nativeAmount ,
316
- },
317
- },
318
- },
319
- },
320
- }
321
- }
0 commit comments