/
bridge.go
32 lines (24 loc) · 984 Bytes
/
bridge.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
package trezoreum
import (
"math/big"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/usbwallet/trezor"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
)
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 trezor.Features, state TrezorState, err error)
Unlock() error
Derive(path accounts.DerivationPath) (common.Address, error)
Sign(path accounts.DerivationPath, tx *types.Transaction, chainID *big.Int) (common.Address, *types.Transaction, error)
}