Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
c7022c1a
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
c7022c1a
编写于
2月 10, 2017
作者:
P
Péter Szilágyi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
accounts/usbwallet: detect and report in Ledger is in browser mode
上级
26cd41f0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
17 addition
and
4 deletion
+17
-4
accounts/usbwallet/ledger_wallet.go
accounts/usbwallet/ledger_wallet.go
+17
-4
未找到文件。
accounts/usbwallet/ledger_wallet.go
浏览文件 @
c7022c1a
...
...
@@ -74,6 +74,11 @@ const (
ledgerP2ReturnAddressChainCode
ledgerParam2
=
0x01
// Require a user confirmation before returning the address
)
// errReplyInvalidHeader is the error message returned by a Ledfer data exchange
// if the device replies with a mismatching header. This usually means the device
// is in browser mode.
var
errReplyInvalidHeader
=
errors
.
New
(
"invalid reply header"
)
// ledgerWallet represents a live USB Ledger hardware wallet.
type
ledgerWallet
struct
{
context
*
usb
.
Context
// USB context to interface libusb through
...
...
@@ -87,6 +92,7 @@ type ledgerWallet struct {
failure
error
// Any failure that would make the device unusable
version
[
3
]
byte
// Current version of the Ledger Ethereum app (zero if app is offline)
browser
bool
// Flag whether the Ledger is in browser mode (reply channel mismatch)
accounts
[]
accounts
.
Account
// List of derive accounts pinned on the Ledger
paths
map
[
common
.
Address
]
accounts
.
DerivationPath
// Known derivation paths for signing operations
...
...
@@ -138,6 +144,9 @@ func (w *ledgerWallet) Status() string {
if
w
.
device
==
nil
{
return
"Closed"
}
if
w
.
browser
{
return
"Ethereum app in browser mode"
}
if
w
.
offline
()
{
return
"Ethereum app offline"
}
...
...
@@ -239,7 +248,10 @@ func (w *ledgerWallet) Open(passphrase string) error {
}()
if
_
,
err
=
w
.
ledgerDerive
(
accounts
.
DefaultBaseDerivationPath
);
err
!=
nil
{
// Ethereum app is not running, nothing more to do, return
// Ethereum app is not running or in browser mode, nothing more to do, return
if
err
==
errReplyInvalidHeader
{
w
.
browser
=
true
}
return
nil
}
// Try to resolve the Ethereum app's version, will fail prior to v1.0.2
...
...
@@ -351,7 +363,8 @@ func (w *ledgerWallet) close() error {
err
:=
w
.
device
.
Close
()
w
.
device
,
w
.
input
,
w
.
output
=
nil
,
nil
,
nil
w
.
version
,
w
.
accounts
,
w
.
paths
=
[
3
]
byte
{},
nil
,
nil
w
.
browser
,
w
.
version
=
false
,
[
3
]
byte
{}
w
.
accounts
,
w
.
paths
=
nil
,
nil
return
err
}
...
...
@@ -463,7 +476,7 @@ func (w *ledgerWallet) selfDerive() {
// Display a log message to the user for new (or previously empty accounts)
if
_
,
known
:=
w
.
paths
[
nextAddr
];
!
known
||
(
!
empty
&&
nextAddr
==
w
.
deriveNextAddr
)
{
glog
.
V
(
logger
.
Info
)
.
Infof
(
"%s discovered %s (balance %
d, nonce %
d) at %s"
,
w
.
url
.
String
(),
nextAddr
.
Hex
(),
balance
,
nonce
,
path
)
glog
.
V
(
logger
.
Info
)
.
Infof
(
"%s discovered %s (balance %
22v, nonce %4
d) at %s"
,
w
.
url
.
String
(),
nextAddr
.
Hex
(),
balance
,
nonce
,
path
)
}
// Fetch the next potential account
if
!
empty
{
...
...
@@ -909,7 +922,7 @@ func (w *ledgerWallet) ledgerExchange(opcode ledgerOpcode, p1 ledgerParam1, p2 l
}
// Make sure the transport header matches
if
chunk
[
0
]
!=
0x01
||
chunk
[
1
]
!=
0x01
||
chunk
[
2
]
!=
0x05
{
return
nil
,
fmt
.
Errorf
(
"invalid reply header: %x"
,
chunk
[
:
3
])
return
nil
,
errReplyInvalidHeader
}
// If it's the first chunk, retrieve the total message length
if
chunk
[
3
]
==
0x00
&&
chunk
[
4
]
==
0x00
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录