Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
1cecae74
Commit
1cecae74
authored
Dec 06, 2018
by
heyubin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add by hyb fo rbug
parent
fd952893
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
41 deletions
+52
-41
multisig.go
plugin/dapp/multisig/commands/multisig.go
+17
-27
multisig.go
plugin/dapp/multisig/executor/multisig.go
+17
-11
const.go
plugin/dapp/multisig/types/const.go
+17
-3
errors.go
plugin/dapp/multisig/types/errors.go
+1
-0
No files found.
plugin/dapp/multisig/commands/multisig.go
View file @
1cecae74
...
@@ -88,10 +88,10 @@ func createMultiSigAccTransfer(cmd *cobra.Command, args []string) {
...
@@ -88,10 +88,10 @@ func createMultiSigAccTransfer(cmd *cobra.Command, args []string) {
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
address
,
_
:=
cmd
.
Flags
()
.
GetString
(
"owners_addr"
)
address
,
_
:=
cmd
.
Flags
()
.
GetString
(
"owners_addr"
)
addressArr
:=
strings
.
Split
(
address
,
" "
)
addressArr
:=
strings
.
Fields
(
address
)
weightstr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"owners_weight"
)
weightstr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"owners_weight"
)
weightsArr
:=
strings
.
Split
(
weightstr
,
" "
)
weightsArr
:=
strings
.
Fields
(
weightstr
)
//校验owner和权重数量要一致
//校验owner和权重数量要一致
if
len
(
addressArr
)
!=
len
(
weightsArr
)
{
if
len
(
addressArr
)
!=
len
(
weightsArr
)
{
...
@@ -131,26 +131,15 @@ func createMultiSigAccTransfer(cmd *cobra.Command, args []string) {
...
@@ -131,26 +131,15 @@ func createMultiSigAccTransfer(cmd *cobra.Command, args []string) {
return
return
}
}
//创建时最少设置两个owner
if
ownerCount
<
mty
.
MinOwnersInit
{
fmt
.
Fprintln
(
os
.
Stderr
,
"OwnerLessThanTwo"
)
return
}
execer
,
_
:=
cmd
.
Flags
()
.
GetString
(
"execer"
)
execer
,
_
:=
cmd
.
Flags
()
.
GetString
(
"execer"
)
symbol
,
_
:=
cmd
.
Flags
()
.
GetString
(
"symbol"
)
symbol
,
_
:=
cmd
.
Flags
()
.
GetString
(
"symbol"
)
err
=
mty
.
IsAssetsInvalid
(
execer
,
symbol
)
dailylimit
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"daily_limit"
)
err
=
isValidDailylimit
(
dailylimit
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
return
}
}
dailylimit
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"daily_limit"
)
if
dailylimit
<
0
{
fmt
.
Fprintln
(
os
.
Stderr
,
"DailyLimitLessThanZero"
)
return
}
symboldailylimit
:=
&
mty
.
SymbolDailyLimit
{
symboldailylimit
:=
&
mty
.
SymbolDailyLimit
{
Symbol
:
symbol
,
Symbol
:
symbol
,
Execer
:
execer
,
Execer
:
execer
,
...
@@ -385,16 +374,11 @@ func createMultiSigAccDailyLimitModifyTransfer(cmd *cobra.Command, args []string
...
@@ -385,16 +374,11 @@ func createMultiSigAccDailyLimitModifyTransfer(cmd *cobra.Command, args []string
symbol
,
_
:=
cmd
.
Flags
()
.
GetString
(
"symbol"
)
symbol
,
_
:=
cmd
.
Flags
()
.
GetString
(
"symbol"
)
dailylimit
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"daily_limit"
)
dailylimit
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"daily_limit"
)
err
:=
mty
.
IsAssetsInvalid
(
execer
,
symbol
)
err
:=
isValidDailylimit
(
dailylimit
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
return
}
}
if
dailylimit
<
0
{
fmt
.
Fprintln
(
os
.
Stderr
,
"DailyLimitLessThanZero"
)
return
}
assetsDailyLimit
:=
&
mty
.
SymbolDailyLimit
{
assetsDailyLimit
:=
&
mty
.
SymbolDailyLimit
{
Symbol
:
symbol
,
Symbol
:
symbol
,
Execer
:
execer
,
Execer
:
execer
,
...
@@ -490,9 +474,8 @@ func createMultiSigAccTransferIn(cmd *cobra.Command, args []string) {
...
@@ -490,9 +474,8 @@ func createMultiSigAccTransferIn(cmd *cobra.Command, args []string) {
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
err
:=
mty
.
IsAssetsInvalid
(
execer
,
symbol
)
if
float64
(
types
.
MaxCoin
/
types
.
Coin
)
<
amount
{
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
types
.
ErrAmount
)
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
return
}
}
params
:=
&
mty
.
MultiSigExecTransfer
{
params
:=
&
mty
.
MultiSigExecTransfer
{
...
@@ -548,9 +531,8 @@ func createMultiSigAccTransferOut(cmd *cobra.Command, args []string) {
...
@@ -548,9 +531,8 @@ func createMultiSigAccTransferOut(cmd *cobra.Command, args []string) {
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
err
:=
mty
.
IsAssetsInvalid
(
execer
,
symbol
)
if
float64
(
types
.
MaxCoin
/
types
.
Coin
)
<
amount
{
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
types
.
ErrAmount
)
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
return
}
}
params
:=
&
mty
.
MultiSigExecTransfer
{
params
:=
&
mty
.
MultiSigExecTransfer
{
...
@@ -681,6 +663,7 @@ func parseAccInfo(view interface{}) (interface{}, error) {
...
@@ -681,6 +663,7 @@ func parseAccInfo(view interface{}) (interface{}, error) {
for
_
,
dailyLimit
:=
range
res
.
DailyLimits
{
for
_
,
dailyLimit
:=
range
res
.
DailyLimits
{
dailyLimt
:=
strconv
.
FormatFloat
(
float64
(
dailyLimit
.
DailyLimit
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
dailyLimt
:=
strconv
.
FormatFloat
(
float64
(
dailyLimit
.
DailyLimit
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
spentToday
:=
strconv
.
FormatFloat
(
float64
(
dailyLimit
.
SpentToday
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
spentToday
:=
strconv
.
FormatFloat
(
float64
(
dailyLimit
.
SpentToday
)
/
float64
(
types
.
Coin
),
'f'
,
4
,
64
)
fmt
.
Println
(
"parseAccInfo dailyLimt"
,
dailyLimt
)
dailyLimitResult
:=
&
mty
.
DailyLimitResult
{
dailyLimitResult
:=
&
mty
.
DailyLimitResult
{
Symbol
:
dailyLimit
.
Symbol
,
Symbol
:
dailyLimit
.
Symbol
,
Execer
:
dailyLimit
.
Execer
,
Execer
:
dailyLimit
.
Execer
,
...
@@ -1074,3 +1057,10 @@ func getMultiSigAccAllAddress(cmd *cobra.Command, args []string) {
...
@@ -1074,3 +1057,10 @@ func getMultiSigAccAllAddress(cmd *cobra.Command, args []string) {
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
rep
)
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"Chain33.Query"
,
params
,
rep
)
ctx
.
Run
()
ctx
.
Run
()
}
}
func
isValidDailylimit
(
dailylimit
float64
)
error
{
if
dailylimit
<
0
||
float64
(
types
.
MaxCoin
/
types
.
Coin
)
<
dailylimit
{
return
mty
.
ErrInvalidDailyLimit
}
return
nil
}
plugin/dapp/multisig/executor/multisig.go
View file @
1cecae74
...
@@ -89,16 +89,7 @@ func (m *MultiSig) CheckTx(tx *types.Transaction, index int) error {
...
@@ -89,16 +89,7 @@ func (m *MultiSig) CheckTx(tx *types.Transaction, index int) error {
return
err
return
err
}
}
}
}
//MultiSigExecTransfer to 地址检测
if
ato
,
ok
:=
payload
.
(
*
mty
.
MultiSigExecTransfer
);
ok
{
if
err
:=
address
.
CheckAddress
(
ato
.
GetTo
());
err
!=
nil
{
return
types
.
ErrInvalidAddress
}
//assets check
if
err
:=
mty
.
IsAssetsInvalid
(
ato
.
GetExecname
(),
ato
.
GetSymbol
());
err
!=
nil
{
return
err
}
}
//MultiSigOwnerOperate 交易的检测
//MultiSigOwnerOperate 交易的检测
if
ato
,
ok
:=
payload
.
(
*
mty
.
MultiSigOwnerOperate
);
ok
{
if
ato
,
ok
:=
payload
.
(
*
mty
.
MultiSigOwnerOperate
);
ok
{
err
:=
checkOwnerOperateTx
(
ato
)
err
:=
checkOwnerOperateTx
(
ato
)
...
@@ -120,6 +111,16 @@ func (m *MultiSig) CheckTx(tx *types.Transaction, index int) error {
...
@@ -120,6 +111,16 @@ func (m *MultiSig) CheckTx(tx *types.Transaction, index int) error {
}
}
}
}
//MultiSigExecTransfer to 地址检测
if
ato
,
ok
:=
payload
.
(
*
mty
.
MultiSigExecTransfer
);
ok
{
if
err
:=
address
.
CheckAddress
(
ato
.
GetTo
());
err
!=
nil
{
return
types
.
ErrInvalidAddress
}
//assets check
if
err
:=
mty
.
IsAssetsInvalid
(
ato
.
GetExecname
(),
ato
.
GetSymbol
());
err
!=
nil
{
return
err
}
}
return
nil
return
nil
}
}
func
checkAccountCreateTx
(
ato
*
mty
.
MultiSigAccCreate
)
error
{
func
checkAccountCreateTx
(
ato
*
mty
.
MultiSigAccCreate
)
error
{
...
@@ -131,6 +132,8 @@ func checkAccountCreateTx(ato *mty.MultiSigAccCreate) error {
...
@@ -131,6 +132,8 @@ func checkAccountCreateTx(ato *mty.MultiSigAccCreate) error {
return
mty
.
ErrInvalidWeight
return
mty
.
ErrInvalidWeight
}
}
owners
:=
ato
.
GetOwners
()
owners
:=
ato
.
GetOwners
()
ownersMap
:=
make
(
map
[
string
]
bool
)
//创建时requiredweight权重的值不能大于所有owner权重之和
//创建时requiredweight权重的值不能大于所有owner权重之和
for
_
,
owner
:=
range
owners
{
for
_
,
owner
:=
range
owners
{
if
owner
!=
nil
{
if
owner
!=
nil
{
...
@@ -140,6 +143,10 @@ func checkAccountCreateTx(ato *mty.MultiSigAccCreate) error {
...
@@ -140,6 +143,10 @@ func checkAccountCreateTx(ato *mty.MultiSigAccCreate) error {
if
owner
.
Weight
==
0
{
if
owner
.
Weight
==
0
{
return
mty
.
ErrInvalidWeight
return
mty
.
ErrInvalidWeight
}
}
if
ownersMap
[
owner
.
OwnerAddr
]
{
return
mty
.
ErrOwnerExist
}
ownersMap
[
owner
.
OwnerAddr
]
=
true
totalweight
+=
owner
.
Weight
totalweight
+=
owner
.
Weight
ownerCount
=
ownerCount
+
1
ownerCount
=
ownerCount
+
1
}
}
...
@@ -167,7 +174,6 @@ func checkAccountCreateTx(ato *mty.MultiSigAccCreate) error {
...
@@ -167,7 +174,6 @@ func checkAccountCreateTx(ato *mty.MultiSigAccCreate) error {
}
}
func
checkOwnerOperateTx
(
ato
*
mty
.
MultiSigOwnerOperate
)
error
{
func
checkOwnerOperateTx
(
ato
*
mty
.
MultiSigOwnerOperate
)
error
{
OldOwner
:=
ato
.
GetOldOwner
()
OldOwner
:=
ato
.
GetOldOwner
()
NewOwner
:=
ato
.
GetNewOwner
()
NewOwner
:=
ato
.
GetNewOwner
()
NewWeight
:=
ato
.
GetNewWeight
()
NewWeight
:=
ato
.
GetNewWeight
()
...
...
plugin/dapp/multisig/types/const.go
View file @
1cecae74
...
@@ -33,7 +33,7 @@ var (
...
@@ -33,7 +33,7 @@ var (
OneDaySecond
int64
=
24
*
3600
OneDaySecond
int64
=
24
*
3600
MinOwnersInit
int
=
2
MinOwnersInit
int
=
2
MinOwnersCount
int
=
1
//一个多重签名的账户最少要保留一个owner
MinOwnersCount
int
=
1
//一个多重签名的账户最少要保留一个owner
MaxOwnersCount
int
=
50
//一个多重签名的账户最多拥有5
0个owner
MaxOwnersCount
int
=
20
//一个多重签名的账户最多拥有2
0个owner
Multisiglog
=
log15
.
New
(
"module"
,
MultiSigX
)
Multisiglog
=
log15
.
New
(
"module"
,
MultiSigX
)
)
)
...
@@ -126,10 +126,24 @@ func IsAssetsInvalid(exec, symbol string) error {
...
@@ -126,10 +126,24 @@ func IsAssetsInvalid(exec, symbol string) error {
}
}
//Symbol检测
//Symbol检测
symbolstr
:=
strings
.
Split
(
symbol
,
"."
)[
len
(
strings
.
Split
(
symbol
,
"."
))
-
1
]
symbolstr
:=
strings
.
Split
(
symbol
,
"."
)[
len
(
strings
.
Split
(
symbol
,
"."
))
-
1
]
upperSymbol
:=
strings
.
ToUpper
(
symbolstr
)
valid
:=
validSymbol
([]
byte
(
symbolstr
)
)
if
symbolstr
!=
upperSymbol
{
if
!
valid
{
multisiglog
.
Error
(
"IsAssetsInvalid"
,
"symbol"
,
symbol
)
multisiglog
.
Error
(
"IsAssetsInvalid"
,
"symbol"
,
symbol
)
return
ErrInvalidSymbol
return
ErrInvalidSymbol
}
}
return
nil
return
nil
}
}
func
isUpperChar
(
a
byte
)
bool
{
res
:=
(
a
<=
'Z'
&&
a
>=
'A'
)
return
res
}
func
validSymbol
(
cs
[]
byte
)
bool
{
for
_
,
c
:=
range
cs
{
if
!
isUpperChar
(
c
)
{
return
false
}
}
return
true
}
plugin/dapp/multisig/types/errors.go
View file @
1cecae74
...
@@ -39,4 +39,5 @@ var (
...
@@ -39,4 +39,5 @@ var (
ErrInvalidSymbol
=
errors
.
New
(
"ErrInvalidSymbol"
)
ErrInvalidSymbol
=
errors
.
New
(
"ErrInvalidSymbol"
)
ErrInvalidExec
=
errors
.
New
(
"ErrInvalidExec"
)
ErrInvalidExec
=
errors
.
New
(
"ErrInvalidExec"
)
ErrInvalidWeight
=
errors
.
New
(
"ErrInvalidWeight"
)
ErrInvalidWeight
=
errors
.
New
(
"ErrInvalidWeight"
)
ErrInvalidDailyLimit
=
errors
.
New
(
"ErrInvalidDailyLimit"
)
)
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment