-
Notifications
You must be signed in to change notification settings - Fork 2
/
unstake.go
42 lines (34 loc) · 844 Bytes
/
unstake.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
package main
import (
"fmt"
"main/base"
"main/node_manager"
"math/big"
"strconv"
"strings"
)
type UnStakeParser struct {
rawAction *RawAction
}
func (s *UnStakeParser) ParseInput(input string) error {
param := &node_manager.UnStakeParam{}
s.rawAction.Input = param
parts := strings.Split(input, ";")
if len(parts) != 2 {
return fmt.Errorf("invalid format input[%s]", input)
}
consensusHdAddress, err := parseAddress(parts[0])
if err != nil {
return err
}
param.ConsensusAddress = consensusHdAddress.ToAddress()
amount, err := strconv.ParseInt(parts[1], 10, 64)
if err != nil {
return fmt.Errorf("invalid stake amount: %s, err: %v", parts[1], err)
}
param.Amount = new(big.Int).Mul(big.NewInt(amount), base.ZionPrecision)
return nil
}
func (s *UnStakeParser) ParseAssertion(input string) error {
return nil
}