forked from bpancost/sila
-
Notifications
You must be signed in to change notification settings - Fork 0
/
transaction_transfer_sila.go
61 lines (51 loc) · 1.97 KB
/
transaction_transfer_sila.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
package sila
import (
"github.com/kappapay/silaclient/domain"
)
func (client ClientImpl) TransferSila(userHandle string) TransferSila {
return &TransferSilaMsg{
Header: client.generateHeader().setUserHandle(userHandle),
Message: "transfer_msg",
}
}
type TransferSilaMsg struct {
Header *Header `json:"header"`
Message string `json:"message"`
Amount int64 `json:"amount"`
DestinationHandle string `json:"destination_handle"`
DestinationWallet string `json:"destination_wallet,omitempty"`
DestinationAddress string `json:"destination_address,omitempty"`
Descriptor string `json:"descriptor,omitempty"`
TransactionIdempotencyId string `json:"transaction_idempotency_id,omitempty"`
}
func (msg *TransferSilaMsg) SetRef(ref string) TransferSila {
msg.Header.setRef(ref)
return msg
}
func (msg *TransferSilaMsg) SetAmountAndUser(amount int64, destinationHandle string) TransferSila {
msg.Amount = amount
msg.DestinationHandle = destinationHandle
return msg
}
func (msg *TransferSilaMsg) SetDestinationWallet(destinationWalletName string) TransferSila {
msg.DestinationWallet = destinationWalletName
return msg
}
func (msg *TransferSilaMsg) SetDestinationAddress(destinationWalletAddress string) TransferSila {
msg.DestinationAddress = destinationWalletAddress
return msg
}
func (msg *TransferSilaMsg) SetDescriptor(descriptor string) TransferSila {
msg.Descriptor = descriptor
return msg
}
func (msg *TransferSilaMsg) SetTransactionIdempotencyId(id string) TransferSila {
msg.TransactionIdempotencyId = id
return msg
}
// The wallet key passed in is what determines which wallet is the source wallet for the transfer
func (msg *TransferSilaMsg) Do(userWalletPrivateKey string) (domain.TransferSilaResponse, error) {
var responseBody domain.TransferSilaResponse
err := instance.performCallWithUserAuth("/transfer_sila", msg, &responseBody, userWalletPrivateKey)
return responseBody, err
}