-
Notifications
You must be signed in to change notification settings - Fork 117
/
Copy pathaccount_handlers.go
610 lines (586 loc) · 20.3 KB
/
account_handlers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
package api
import (
"context"
"encoding/base64"
"encoding/binary"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"net/http"
"sort"
"strings"
"time"
"github.com/tonkeeper/opentonapi/pkg/addressbook"
"golang.org/x/exp/slices"
"github.com/cespare/xxhash/v2"
"github.com/go-faster/jx"
"github.com/tonkeeper/opentonapi/internal/g"
"github.com/tonkeeper/opentonapi/pkg/core"
"github.com/tonkeeper/opentonapi/pkg/oas"
"github.com/tonkeeper/tongo"
"github.com/tonkeeper/tongo/abi"
"github.com/tonkeeper/tongo/boc"
"github.com/tonkeeper/tongo/code"
"github.com/tonkeeper/tongo/tlb"
"github.com/tonkeeper/tongo/ton"
"github.com/tonkeeper/tongo/utils"
walletTongo "github.com/tonkeeper/tongo/wallet"
)
func (h *Handler) GetBlockchainRawAccount(ctx context.Context, params oas.GetBlockchainRawAccountParams) (*oas.BlockchainRawAccount, error) {
account, err := tongo.ParseAddress(params.AccountID)
if err != nil {
return nil, toError(http.StatusBadRequest, err)
}
rawAccount, err := h.storage.GetRawAccount(ctx, account.ID)
if errors.Is(err, core.ErrEntityNotFound) {
return nil, toError(http.StatusNotFound, err)
}
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
res, err := convertToRawAccount(rawAccount)
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
return &res, nil
}
func (h *Handler) GetAccount(ctx context.Context, params oas.GetAccountParams) (*oas.Account, error) {
account, err := tongo.ParseAddress(params.AccountID)
if err != nil {
return nil, toError(http.StatusBadRequest, err)
}
rawAccount, err := h.storage.GetRawAccount(ctx, account.ID)
if errors.Is(err, core.ErrEntityNotFound) {
return &oas.Account{
Address: account.ID.ToRaw(),
Status: oas.AccountStatusNonexist,
}, nil
}
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
ab, found := h.addressBook.GetAddressInfoByAddress(account.ID)
var res oas.Account
if found {
res = convertToAccount(rawAccount, &ab, h.state, h.spamFilter)
} else {
res = convertToAccount(rawAccount, nil, h.state, h.spamFilter)
}
if rawAccount.ExtraBalances != nil {
res.ExtraBalance = convertExtraCurrencies(rawAccount.ExtraBalances)
}
return &res, nil
}
func (h *Handler) GetAccounts(ctx context.Context, request oas.OptGetAccountsReq, params oas.GetAccountsParams) (*oas.Accounts, error) {
if len(request.Value.AccountIds) == 0 {
return nil, toError(http.StatusBadRequest, fmt.Errorf("empty list of ids"))
}
if !h.limits.isBulkQuantityAllowed(len(request.Value.AccountIds)) {
return nil, toError(http.StatusBadRequest, fmt.Errorf("the maximum number of accounts to request at once: %v", h.limits.BulkLimits))
}
var currencyPrice float64
currency := strings.ToUpper(params.Currency.Value)
if currency != "" {
rates, err := h.ratesSource.GetRates(time.Now().Unix())
if err == nil {
currencyPrice = rates[currency]
}
}
var ids []tongo.AccountID
allAccountIDs := make(map[tongo.AccountID]struct{}, len(request.Value.AccountIds))
for _, str := range request.Value.AccountIds {
account, err := tongo.ParseAddress(str)
if err != nil {
return nil, toError(http.StatusBadRequest, err)
}
ids = append(ids, account.ID)
allAccountIDs[account.ID] = struct{}{}
}
accounts, err := h.storage.GetRawAccounts(ctx, ids)
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
results := make(map[ton.AccountID]oas.Account, len(accounts))
for _, account := range accounts {
delete(allAccountIDs, account.AccountAddress)
ab, found := h.addressBook.GetAddressInfoByAddress(account.AccountAddress)
var res oas.Account
if found {
res = convertToAccount(account, &ab, h.state, h.spamFilter)
} else {
res = convertToAccount(account, nil, h.state, h.spamFilter)
}
if account.ExtraBalances != nil {
res.ExtraBalance = convertExtraCurrencies(account.ExtraBalances)
}
results[account.AccountAddress] = res
}
// if we don't find an account, we return it with "nonexist" status
for accountID := range allAccountIDs {
account := oas.Account{
Address: accountID.ToRaw(),
Status: oas.AccountStatusNonexist,
IsWallet: true,
}
results[accountID] = account
}
resp := &oas.Accounts{}
for _, i := range ids {
account := results[i]
if currencyPrice != 0 {
convertedAmount := float64(account.Balance/int64(ton.OneTON)) / currencyPrice
currenciesBalance := map[string]jx.Raw{currency: jx.Raw(fmt.Sprintf("%f", convertedAmount))}
account.CurrenciesBalance.SetTo(currenciesBalance)
}
resp.Accounts = append(resp.Accounts, account)
}
return resp, nil
}
func (h *Handler) GetBlockchainAccountTransactions(ctx context.Context, params oas.GetBlockchainAccountTransactionsParams) (*oas.Transactions, error) {
account, err := tongo.ParseAddress(params.AccountID)
if err != nil {
return nil, toError(http.StatusBadRequest, err)
}
if params.BeforeLt.Value == 0 {
params.BeforeLt.Value = 1 << 62
}
descendingOrder := true
if params.SortOrder.Value == oas.GetBlockchainAccountTransactionsSortOrderAsc {
descendingOrder = false
}
txs, err := h.storage.GetAccountTransactions(ctx, account.ID, int(params.Limit.Value),
uint64(params.BeforeLt.Value), uint64(params.AfterLt.Value), descendingOrder)
if errors.Is(err, core.ErrEntityNotFound) {
return &oas.Transactions{}, nil
}
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
result := oas.Transactions{
Transactions: make([]oas.Transaction, len(txs)),
}
accountObject, err := h.storage.GetRawAccount(ctx, account.ID)
if err != nil {
return nil, err
}
for i, tx := range txs {
result.Transactions[i] = convertTransaction(*tx, accountObject.Interfaces, h.addressBook)
}
return &result, nil
}
func getMethodCacheKey(accountID ton.AccountID, methodName string, lt uint64, args []string) (string, error) {
d := xxhash.New()
var x [8]byte
binary.LittleEndian.PutUint64(x[:], lt)
if _, err := d.Write(x[:]); err != nil {
return "", err
}
if _, err := d.WriteString(methodName); err != nil {
return "", err
}
for _, arg := range args {
if _, err := d.WriteString(arg + "|"); err != nil {
return "", err
}
}
return fmt.Sprintf("%s-%d", accountID.ToRaw(), d.Sum64()), nil
}
func (h *Handler) ExecGetMethodForBlockchainAccount(ctx context.Context, params oas.ExecGetMethodForBlockchainAccountParams) (*oas.MethodExecutionResult, error) {
account, err := tongo.ParseAddress(params.AccountID)
if err != nil {
return nil, toError(http.StatusBadRequest, err)
}
contract, err := h.storage.GetContract(ctx, account.ID)
if err != nil {
if errors.Is(err, core.ErrEntityNotFound) {
return nil, toError(http.StatusNotFound, err)
}
return nil, toError(http.StatusInternalServerError, err)
}
// TODO: remove parameter after user migration
if params.FixOrder.IsSet() && params.FixOrder.Value == true && len(params.Args) > 1 {
slices.Reverse(params.Args)
}
key, err := getMethodCacheKey(account.ID, params.MethodName, contract.LastTransactionLt, params.Args)
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
if result, ok := h.getMethodsCache.Get(key); ok {
return result, nil
}
stack := make([]tlb.VmStackValue, 0, len(params.Args))
for i := len(params.Args) - 1; i >= 0; i-- {
r, err := stringToTVMStackRecord(params.Args[i])
if err != nil {
return nil, toError(http.StatusBadRequest, fmt.Errorf("can't parse arg '%v' as any TVMStackValue", params.Args[i]))
}
stack = append(stack, r) // we need to put the arguments on the stack in reverse order
}
// RunSmcMethodByID fetches the contract from the storage on its own,
// and it can happen that the contract has been changed and has another lt,
// in this case, we get a correct result from the executor,
// but we update a previous cache entry that won't be used anymore.
exitCode, stack, err := h.executor.RunSmcMethodByID(ctx, account.ID, utils.MethodIdFromName(params.MethodName), stack)
if err != nil {
if errors.Is(err, core.ErrEntityNotFound) {
return nil, toError(http.StatusNotFound, err)
}
return nil, toError(http.StatusInternalServerError, err)
}
result := oas.MethodExecutionResult{
Success: exitCode == 0 || exitCode == 1,
ExitCode: int(exitCode),
Stack: make([]oas.TvmStackRecord, 0, len(stack)),
}
for i := range stack {
value, err := convertTvmStackValue(stack[i])
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
result.Stack = append(result.Stack, value)
}
for _, decoder := range abi.KnownGetMethodsDecoder[params.MethodName] {
_, v, err := decoder(stack)
if err == nil {
value, err := json.Marshal(v)
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
result.SetDecoded(g.ChangeJsonKeys(value, g.CamelToSnake))
break
}
}
h.getMethodsCache.Set(key, &result)
return &result, nil
}
func (h *Handler) SearchAccounts(ctx context.Context, params oas.SearchAccountsParams) (*oas.FoundAccounts, error) {
attachedAccounts := h.addressBook.SearchAttachedAccountsByPrefix(params.Name)
accounts := make([]addressbook.AttachedAccount, 0, len(attachedAccounts))
for _, account := range attachedAccounts {
if account.Symbol != "" {
trust := h.spamFilter.JettonTrust(account.Wallet, account.Symbol, account.Name, account.Preview)
if trust == core.TrustBlacklist {
continue
}
}
trust := h.spamFilter.AccountTrust(account.Wallet)
if trust == core.TrustBlacklist {
continue
}
accounts = append(accounts, account)
}
converted := make([]oas.FoundAccountsAddressesItem, len(accounts))
for idx, account := range accounts {
converted[idx] = oas.FoundAccountsAddressesItem{
Address: account.Wallet.ToRaw(),
Name: account.Name,
Preview: account.Preview,
Trust: oas.TrustType(account.Trust),
}
}
return &oas.FoundAccounts{Addresses: converted}, nil
}
// ReindexAccount updates internal cache for a particular account.
func (h *Handler) ReindexAccount(ctx context.Context, params oas.ReindexAccountParams) error {
account, err := tongo.ParseAddress(params.AccountID)
if err != nil {
return toError(http.StatusBadRequest, err)
}
if err = h.storage.ReindexAccount(ctx, account.ID); err != nil {
return toError(http.StatusInternalServerError, err)
}
return nil
}
func (h *Handler) GetAccountDnsExpiring(ctx context.Context, params oas.GetAccountDnsExpiringParams) (*oas.DnsExpiring, error) {
account, err := tongo.ParseAddress(params.AccountID)
if err != nil {
return nil, toError(http.StatusBadRequest, err)
}
var period *int
if params.Period.Set {
period = ¶ms.Period.Value
}
dnsExpiring, err := h.storage.GetDnsExpiring(ctx, account.ID, period)
if errors.Is(err, core.ErrEntityNotFound) {
return &oas.DnsExpiring{}, nil
}
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
accounts := make([]tongo.AccountID, 0, len(dnsExpiring))
var response oas.DnsExpiring
if len(dnsExpiring) == 0 {
return &response, nil
}
for _, dns := range dnsExpiring {
if dns.DnsItem != nil {
accounts = append(accounts, dns.DnsItem.Address)
}
}
nfts, err := h.storage.GetNFTs(ctx, accounts)
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
for _, dns := range dnsExpiring {
dei := oas.DnsExpiringItemsItem{
Name: dns.Name,
ExpiringAt: dns.ExpiringAt,
}
if dns.DnsItem != nil {
for _, n := range nfts {
if n.Address == dns.DnsItem.Address {
dei.DNSItem = oas.NewOptNftItem(h.convertNFT(ctx, n, h.addressBook, h.metaCache))
break
}
}
}
response.Items = append(response.Items, dei)
}
sort.Slice(response.Items, func(i, j int) bool {
return response.Items[i].ExpiringAt > response.Items[j].ExpiringAt
})
return &response, nil
}
func (h *Handler) GetAccountPublicKey(ctx context.Context, params oas.GetAccountPublicKeyParams) (*oas.GetAccountPublicKeyOK, error) {
account, err := tongo.ParseAddress(params.AccountID)
if err != nil {
return nil, toError(http.StatusBadRequest, err)
}
pubKey, err := h.storage.GetWalletPubKey(ctx, account.ID)
if errors.Is(err, core.ErrEntityNotFound) {
return nil, toError(http.StatusNotFound, err)
}
if err != nil {
state, err := h.storage.GetRawAccount(ctx, account.ID)
if errors.Is(err, core.ErrEntityNotFound) {
return nil, toError(http.StatusNotFound, err)
}
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
pubKey, err = pubkeyFromCodeData(state.Code, state.Data)
if errors.Is(err, unknownWalletVersionError) {
return nil, toError(http.StatusBadRequest, err)
}
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
}
return &oas.GetAccountPublicKeyOK{PublicKey: hex.EncodeToString(pubKey)}, nil
}
func (h *Handler) GetAccountSubscriptions(ctx context.Context, params oas.GetAccountSubscriptionsParams) (*oas.Subscriptions, error) {
account, err := tongo.ParseAddress(params.AccountID)
if err != nil {
return nil, toError(http.StatusBadRequest, err)
}
subscriptions, err := h.storage.GetSubscriptions(ctx, account.ID)
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
var response oas.Subscriptions
for _, subscription := range subscriptions {
response.Subscriptions = append(response.Subscriptions, oas.Subscription{
Address: subscription.AccountID.ToRaw(),
WalletAddress: subscription.WalletAccountID.ToRaw(),
BeneficiaryAddress: subscription.BeneficiaryAccountID.ToRaw(),
Amount: subscription.Amount,
Period: subscription.Period,
StartTime: subscription.StartTime,
Timeout: subscription.Timeout,
LastPaymentTime: subscription.LastPaymentTime,
LastRequestTime: subscription.LastRequestTime,
SubscriptionID: subscription.SubscriptionID,
FailedAttempts: subscription.FailedAttempts,
})
}
return &response, nil
}
func (h *Handler) GetAccountTraces(ctx context.Context, params oas.GetAccountTracesParams) (*oas.TraceIDs, error) {
account, err := tongo.ParseAddress(params.AccountID)
if err != nil {
return nil, toError(http.StatusBadRequest, err)
}
traceIDs, err := h.storage.SearchTraces(ctx, account.ID, params.Limit.Value, optIntToPointer(params.BeforeLt), nil, nil, false)
if err != nil && !errors.Is(err, core.ErrEntityNotFound) {
return nil, toError(http.StatusInternalServerError, err)
}
traces := oas.TraceIDs{
Traces: make([]oas.TraceID, 0, len(traceIDs)),
}
for _, traceID := range traceIDs {
traces.Traces = append(traces.Traces, oas.TraceID{
ID: traceID.Hash.Hex(),
Utime: int64(traceID.Lt),
})
}
return &traces, nil
}
func (h *Handler) GetAccountDiff(ctx context.Context, params oas.GetAccountDiffParams) (*oas.GetAccountDiffOK, error) {
account, err := tongo.ParseAddress(params.AccountID)
if err != nil {
return nil, toError(http.StatusBadRequest, err)
}
balanceChange, err := h.storage.GetAccountDiff(ctx, account.ID, params.StartDate, params.EndDate)
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
return &oas.GetAccountDiffOK{BalanceChange: balanceChange}, nil
}
func (h *Handler) GetAccountNftHistory(ctx context.Context, params oas.GetAccountNftHistoryParams) (*oas.AccountEvents, error) {
account, err := tongo.ParseAddress(params.AccountID)
if err != nil {
return nil, toError(http.StatusBadRequest, err)
}
traceIDs, err := h.storage.GetAccountNftsHistory(ctx, account.ID, params.Limit, optIntToPointer(params.BeforeLt), optIntToPointer(params.StartDate), optIntToPointer(params.EndDate))
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
events, lastLT, err := h.convertNftHistory(ctx, account.ID, traceIDs, params.AcceptLanguage)
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
return &oas.AccountEvents{Events: events, NextFrom: lastLT}, nil
}
func (h *Handler) BlockchainAccountInspect(ctx context.Context, params oas.BlockchainAccountInspectParams) (*oas.BlockchainAccountInspect, error) {
account, err := tongo.ParseAddress(params.AccountID)
if err != nil {
return nil, toError(http.StatusBadRequest, err)
}
rawAccount, err := h.storage.GetRawAccount(ctx, account.ID)
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
cells, err := boc.DeserializeBoc(rawAccount.Code)
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
if len(cells) != 1 {
return nil, toError(http.StatusInternalServerError, fmt.Errorf("invalid boc with code"))
}
codeHash, err := cells[0].Hash()
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
methods, err := code.ParseContractMethods(rawAccount.Code)
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
source, _ := h.verifierSource.GetAccountSource(account.ID)
sourceFiles := make([]oas.SourceFile, len(source.Files))
for idx, file := range source.Files {
sourceFiles[idx] = oas.SourceFile{
Name: file.Name,
Content: file.Content,
IsEntrypoint: file.IsEntrypoint,
IsStdLib: file.IsStdLib,
IncludeInCommand: file.IncludeInCommand,
}
}
compiler := oas.BlockchainAccountInspectCompilerFunc
if source.Compiler != "" {
compiler = oas.BlockchainAccountInspectCompiler(source.Compiler)
}
resp := oas.BlockchainAccountInspect{
Code: hex.EncodeToString(rawAccount.Code),
CodeHash: hex.EncodeToString(codeHash),
Compiler: compiler,
}
if len(sourceFiles) > 0 {
resp.Source = oas.NewOptSource(oas.Source{Files: sourceFiles})
}
for _, methodID := range methods {
if method, ok := code.Methods[methodID]; ok {
resp.Methods = append(resp.Methods, oas.Method{
ID: methodID,
Method: string(method),
})
}
}
return &resp, nil
}
func (h *Handler) GetAccountMultisigs(ctx context.Context, params oas.GetAccountMultisigsParams) (*oas.Multisigs, error) {
accountID, err := ton.ParseAccountID(params.AccountID)
if err != nil {
return nil, toError(http.StatusBadRequest, err)
}
multisigs, err := h.storage.GetAccountMultisigs(ctx, accountID)
if errors.Is(err, core.ErrEntityNotFound) {
return nil, toError(http.StatusNotFound, err)
}
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
var converted []oas.Multisig
for _, multisig := range multisigs {
oasMultisig, err := h.convertMultisig(ctx, multisig)
if err != nil {
return nil, toError(http.StatusInternalServerError, err)
}
converted = append(converted, *oasMultisig)
}
return &oas.Multisigs{Multisigs: converted}, nil
}
var unknownWalletVersionError = fmt.Errorf("unknown wallet version")
func pubkeyFromCodeData(code, data []byte) ([]byte, error) {
if len(code) == 0 {
return nil, unknownWalletVersionError
}
cells, err := boc.DeserializeBoc(code)
if err != nil {
return nil, err
}
if len(cells) != 1 {
return nil, fmt.Errorf("invalid boc with code")
}
codeHash, err := cells[0].Hash()
if err != nil {
return nil, err
}
ver, ok := walletTongo.GetVerByCodeHash([32]byte(codeHash))
if !ok {
return nil, unknownWalletVersionError
}
switch ver {
case walletTongo.V3R1:
var dataBody walletTongo.DataV3
cells, err = boc.DeserializeBoc(data)
if err != nil {
return nil, err
}
err = tlb.Unmarshal(cells[0], &dataBody)
if err != nil {
return nil, err
}
return dataBody.PublicKey[:], nil
default:
return nil, unknownWalletVersionError
}
}
func (h *Handler) AddressParse(ctx context.Context, params oas.AddressParseParams) (*oas.AddressParseOK, error) {
address, err := tongo.ParseAddress(params.AccountID)
if err != nil {
return nil, toError(http.StatusBadRequest, err)
}
var res oas.AddressParseOK
res.RawForm = address.ID.ToRaw()
res.Bounceable.B64url = address.ID.ToHuman(true, false)
res.NonBounceable.B64url = address.ID.ToHuman(false, false)
b, _ := base64.URLEncoding.DecodeString(res.Bounceable.B64url)
res.Bounceable.B64 = base64.StdEncoding.EncodeToString(b)
b, _ = base64.URLEncoding.DecodeString(res.NonBounceable.B64url)
res.NonBounceable.B64 = base64.StdEncoding.EncodeToString(b)
if strings.Contains(params.AccountID, ":") {
res.GivenType = "raw_form"
} else if strings.Contains(params.AccountID, ".") {
res.GivenType = "dns"
} else if address.Bounce {
res.GivenType = "friendly_bounceable"
} else {
res.GivenType = "friendly_non_bounceable"
}
return &res, nil //todo: add testnet_only
}
func (h *Handler) GetAccountExtraCurrencyHistoryByID(ctx context.Context, params oas.GetAccountExtraCurrencyHistoryByIDParams) (*oas.AccountEvents, error) {
return &oas.AccountEvents{}, nil
}