Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
d0512746
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,体验更适合开发者的 AI 搜索 >>
提交
d0512746
编写于
8月 07, 2015
作者:
J
Jeffrey Wilcke
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
xeth: added address hex check and length check
上级
9a02f537
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
0 deletion
+37
-0
xeth/xeth.go
xeth/xeth.go
+11
-0
xeth/xeth_test.go
xeth/xeth_test.go
+26
-0
未找到文件。
xeth/xeth.go
浏览文件 @
d0512746
...
...
@@ -20,8 +20,10 @@ package xeth
import
(
"bytes"
"encoding/json"
"errors"
"fmt"
"math/big"
"regexp"
"sync"
"time"
...
...
@@ -45,6 +47,7 @@ var (
defaultGasPrice
=
big
.
NewInt
(
10000000000000
)
//150000000000
defaultGas
=
big
.
NewInt
(
90000
)
//500000
dappStorePre
=
[]
byte
(
"dapp-"
)
addrReg
=
regexp
.
MustCompile
(
`^(0x)?[a-fA-F0-9]{40}$`
)
)
// byte will be inferred
...
...
@@ -878,6 +881,10 @@ func (self *XEth) Sign(fromStr, hashStr string, didUnlock bool) (string, error)
return
common
.
ToHex
(
sig
),
nil
}
func
isAddress
(
addr
string
)
bool
{
return
addrReg
.
MatchString
(
addr
)
}
func
(
self
*
XEth
)
Transact
(
fromStr
,
toStr
,
nonceStr
,
valueStr
,
gasStr
,
gasPriceStr
,
codeStr
string
)
(
string
,
error
)
{
// this minimalistic recoding is enough (works for natspec.js)
...
...
@@ -887,6 +894,10 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS
return
""
,
err
}
if
!
isAddress
(
toStr
)
{
return
""
,
errors
.
New
(
"Invalid address"
)
}
var
(
from
=
common
.
HexToAddress
(
fromStr
)
to
=
common
.
HexToAddress
(
toStr
)
...
...
xeth/xeth_test.go
0 → 100644
浏览文件 @
d0512746
package
xeth
import
"testing"
func
TestIsAddress
(
t
*
testing
.
T
)
{
for
_
,
invalid
:=
range
[]
string
{
"0x00"
,
"0xNN"
,
"0x00000000000000000000000000000000000000NN"
,
"0xAAar000000000000000000000000000000000000"
,
}
{
if
isAddress
(
invalid
)
{
t
.
Error
(
"Expected"
,
invalid
,
"to be invalid"
)
}
}
for
_
,
valid
:=
range
[]
string
{
"0x0000000000000000000000000000000000000000"
,
"0xAABBbbCCccff9900000000000000000000000000"
,
"AABBbbCCccff9900000000000000000000000000"
,
}
{
if
!
isAddress
(
valid
)
{
t
.
Error
(
"Expected"
,
valid
,
"to be valid"
)
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录