-
Notifications
You must be signed in to change notification settings - Fork 13
/
transfer.go
53 lines (42 loc) · 1.3 KB
/
transfer.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
package mixin
import (
"context"
"fmt"
"github.com/shopspring/decimal"
)
// TransferInput input for transfer/verify payment request
type TransferInput struct {
AssetID string `json:"asset_id,omitempty"`
OpponentID string `json:"opponent_id,omitempty"`
Amount decimal.Decimal `json:"amount,omitempty"`
TraceID string `json:"trace_id,omitempty"`
Memo string `json:"memo,omitempty"`
// OpponentKey used for raw transaction
OpponentKey string `json:"opponent_key,omitempty"`
OpponentMultisig struct {
Receivers []string `json:"receivers,omitempty"`
Threshold uint8 `json:"threshold,omitempty"`
} `json:"opponent_multisig,omitempty"`
}
func (c *Client) Transfer(ctx context.Context, input *TransferInput, pin string) (*Snapshot, error) {
body := struct {
*TransferInput
Pin string
}{
TransferInput: input,
Pin: c.EncryptPin(pin),
}
var snapshot Snapshot
if err := c.Post(ctx, "/transfers", body, &snapshot); err != nil {
return nil, err
}
return &snapshot, nil
}
func (c *Client) ReadTransfer(ctx context.Context, traceID string) (*Snapshot, error) {
uri := fmt.Sprintf("/transfers/trace/%s", traceID)
var snapshot Snapshot
if err := c.Get(ctx, uri, nil, &snapshot); err != nil {
return nil, err
}
return &snapshot, nil
}