/
bridge_interface.go
34 lines (25 loc) · 1.06 KB
/
bridge_interface.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
package trezoreum
import (
"math/big"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
mm "github.com/tranvictor/trezoreum/messages_management"
)
type TrezorState int
const (
Ready TrezorState = iota // Already unlocked and ready to sign data
WaitingForPin // Expecting PIN in order to unlock the trezor
WaitingForPassphrase // Expecting passphrase in order to unlock the trezor
Unexpected
)
type Bridge interface {
// init the connection to trezor via libusb and return the status
// of the device as well as indication to next step to unlock the
// device.
Init() (info mm.Features, state TrezorState, err error)
UnlockByPin(pin string) (state TrezorState, err error)
UnlockByPassphrase(passphrase string) (state TrezorState, err error)
Derive(path accounts.DerivationPath) (common.Address, error)
Sign(path accounts.DerivationPath, tx *types.Transaction, chainID *big.Int) (common.Address, *types.Transaction, error)
}