forked from bpancost/sila
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wallet_register_wallet.go
39 lines (32 loc) · 1.29 KB
/
wallet_register_wallet.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
package sila
import (
"github.com/kappapay/silaclient/domain"
)
func (client ClientImpl) RegisterWallet(userHandle string) RegisterWallet {
return &RegisterWalletMsg{
Header: client.generateHeader().setUserHandle(userHandle),
}
}
type RegisterWalletMsg struct {
Header *Header `json:"header"`
WalletVerificationSignature string `json:"wallet_verification_signature"`
Wallet domain.Wallet `json:"wallet"`
}
func (msg *RegisterWalletMsg) SetRef(ref string) RegisterWallet {
msg.Header.setRef(ref)
return msg
}
// Sets wallet information to register.
// The new wallet signature should be generated from signing the new wallet address with the GenerateWalletSignature function.
func (msg *RegisterWalletMsg) SetWallet(nickname string, address string, newWalletSignature string) RegisterWallet {
msg.Wallet.BlockchainAddress = address
msg.Wallet.BlockchainNetwork = "ETH"
msg.Wallet.Nickname = nickname
msg.WalletVerificationSignature = newWalletSignature
return msg
}
func (msg *RegisterWalletMsg) Do(userWalletPrivateKey string) (domain.RegisterWalletResponse, error) {
var responseBody domain.RegisterWalletResponse
err := instance.performCallWithUserAuth("/register_wallet", msg, &responseBody, userWalletPrivateKey)
return responseBody, err
}