-
Notifications
You must be signed in to change notification settings - Fork 13
/
keeper.go
65 lines (48 loc) · 1.84 KB
/
keeper.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
62
63
64
65
package keeper
import (
"errors"
"github.com/btcsuite/btcd/btcjson"
)
var ErrAccountNotFound = errors.New("error account not found")
var ErrAccountExists = errors.New("error account exists")
var ErrNotSupport = errors.New("error not supported")
func IsNotFound(err error) bool {
return err.Error() == "error account not found"
}
type Account struct {
Account string `json:"account"`
Balance float64 `json:"balance"`
Addresses []string `json:"addresses"`
}
//Keeper interface
type Keeper interface {
GetBlockCount() (int64, error)
// check if the coin core service avaliable or not,
// the error might caused by misconfiguration or
// runtime error. Error happend indicates fatal and
// could not recover, suicide might be the best choice.
Ping() error
// create a new account
CreateAccount(account string) (Account, error)
// Get account, together with balance and address
// return error if account not exist
GetAccountInfo(account string, conf int) (Account, error)
// Returns address under accont, use default account if
// not provided
GetAddress(account string) (string, error)
// Return new address under account
GetNewAddress(account string) (string, error)
// Return addresses under certain account, default account if
// no account specicied
GetAddressesByAccount(account string) ([]string, error)
// List all accounts/labels together with how much satoshi remains.
ListAccountsMinConf(conf int) (map[string]float64, error)
// send bitcoin to address
SendToAddress(address string, amount float64) (string, error)
// send bitcoin from some account to target address
SendFrom(account, address string, amount float64) (string, error)
// list all UXTO
ListUnspentMin(minConf int) ([]btcjson.ListUnspentResult, error)
// Move from one account to another under same wallet
Move(from, to string, amount float64) (bool, error)
}