github.com/neatlab/neatio@v1.7.3-0.20220425043230-d903e92fcc75/chain/accounts/accounts.go (about) 1 package accounts 2 3 import ( 4 "math/big" 5 6 "github.com/neatlab/neatio" 7 "github.com/neatlab/neatio/chain/core/types" 8 "github.com/neatlab/neatio/utilities/common" 9 "github.com/neatlab/neatio/utilities/event" 10 ) 11 12 type Account struct { 13 Address common.Address `json:"address"` 14 URL URL `json:"url"` 15 } 16 17 type Wallet interface { 18 URL() URL 19 20 Status() (string, error) 21 22 Open(passphrase string) error 23 24 Close() error 25 26 Accounts() []Account 27 28 Contains(account Account) bool 29 30 Derive(path DerivationPath, pin bool) (Account, error) 31 32 SelfDerive(base DerivationPath, chain neatio.ChainStateReader) 33 34 SignHash(account Account, hash []byte) ([]byte, error) 35 36 SignTx(account Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) 37 38 SignTxWithAddress(account Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) 39 40 SignHashWithPassphrase(account Account, passphrase string, hash []byte) ([]byte, error) 41 42 SignTxWithPassphrase(account Account, passphrase string, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) 43 } 44 45 type Backend interface { 46 Wallets() []Wallet 47 48 Subscribe(sink chan<- WalletEvent) event.Subscription 49 } 50 51 type WalletEventType int 52 53 const ( 54 WalletArrived WalletEventType = iota 55 56 WalletOpened 57 58 WalletDropped 59 ) 60 61 type WalletEvent struct { 62 Wallet Wallet 63 Kind WalletEventType 64 }