-
Notifications
You must be signed in to change notification settings - Fork 13
/
transaction_external.go
47 lines (40 loc) · 1.25 KB
/
transaction_external.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
package mixin
import (
"context"
"time"
"github.com/shopspring/decimal"
)
type ExternalTransaction struct {
TransactionID string `json:"transaction_id"`
CreatedAt time.Time `json:"created_at"`
TransactionHash string `json:"transaction_hash"`
Sender string `json:"sender"`
ChainId string `json:"chain_id"`
AssetId string `json:"asset_id"`
Amount decimal.Decimal `json:"amount"`
Destination string `json:"destination"`
Tag string `json:"tag"`
Confirmations int64 `json:"confirmations"`
Threshold int64 `json:"threshold"`
}
func ReadExternalTransactions(ctx context.Context, assetID, destination, tag string) ([]*ExternalTransaction, error) {
params := make(map[string]string)
if destination != "" {
params["destination"] = destination
}
if tag != "" {
params["tag"] = tag
}
if assetID != "" {
params["asset"] = assetID
}
resp, err := Request(ctx).SetQueryParams(params).Get("/external/transactions")
if err != nil {
return nil, err
}
var transactions []*ExternalTransaction
if err := UnmarshalResponse(resp, &transactions); err != nil {
return nil, err
}
return transactions, nil
}