-
Notifications
You must be signed in to change notification settings - Fork 0
/
staking.go
49 lines (39 loc) · 1.78 KB
/
staking.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
package main
import (
"encoding/hex"
"github.com/ci123chain/ci123chain/pkg/abci/types"
sdk "github.com/ci123chain/ci123chain/sdk/staking"
)
func SignCreateValidatorTx(from types.AccAddress, amount types.Coin, priv string, minSelfDelegation int64,
validatorAddress, delegatorAddress types.AccAddress, rate, maxRate, maxChangeRate int64,
moniker, identity, website, securityContact, details string, publicKey string) (string, error) {
//
tx, err := sdk.SignCreateValidatorMSg(from, gas, nonce, amount, priv, minSelfDelegation, validatorAddress,
delegatorAddress, rate, maxRate, maxChangeRate, moniker, identity, website, securityContact, details, publicKey)
if err != nil {
return "", err
}
return hex.EncodeToString(tx), nil
}
func SignDelegateTx(from types.AccAddress, gas, nonce uint64, amount types.Coin, priv string, validatorAddress, delegatorAddress types.AccAddress) (string, error) {
tx, err := sdk.SignDelegateMsg(from, gas, nonce, amount, priv, validatorAddress, delegatorAddress)
if err != nil {
return "", err
}
return hex.EncodeToString(tx), nil
}
func SignRelegateTx(from types.AccAddress, gas, nonce uint64, amount types.Coin, priv string, validatorSrcAddress, validatorDstAddress, delegatorAddress types.AccAddress) (string, error) {
//
tx, err := sdk.SignRedelegateMsg(from, gas, nonce ,amount, priv, validatorSrcAddress, validatorDstAddress, delegatorAddress)
if err != nil {
return "", err
}
return hex.EncodeToString(tx), nil
}
func SignUndelegate(from types.AccAddress, gas, nonce uint64, amount types.Coin, priv string, validatorAddress, delegatorAddress types.AccAddress) (string, error) {
tx, err := sdk.SignUndelegateMsg(from, gas, nonce, amount, priv, validatorAddress, delegatorAddress)
if err != nil {
return "", err
}
return hex.EncodeToString(tx), nil
}