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
c989cfb0
Commit
c989cfb0
authored
Dec 07, 2018
by
heyubin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add by hyb for multisig cmd
parent
1cecae74
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
51 deletions
+69
-51
multisig.go
plugin/dapp/multisig/commands/multisig.go
+59
-26
multisig.go
plugin/dapp/multisig/executor/multisig.go
+10
-25
No files found.
plugin/dapp/multisig/commands/multisig.go
View file @
c989cfb0
...
...
@@ -25,29 +25,62 @@ func MultiSigCmd() *cobra.Command {
Short
:
"multisig management"
,
Args
:
cobra
.
MinimumNArgs
(
1
),
}
cmd
.
AddCommand
(
MultiSigAccountCmd
(),
MultiSigOwnerCmd
(),
MultiSigTxCmd
(),
)
return
cmd
}
func
MultiSigAccountCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"account"
,
Short
:
"multisig account"
,
Args
:
cobra
.
MinimumNArgs
(
1
),
}
cmd
.
AddCommand
(
CreateMultiSigAccCreateCmd
(),
CreateMultiSigAccWeightModifyCmd
(),
CreateMultiSigAccDailyLimitModifyCmd
(),
GetMultiSigAccCountCmd
(),
GetMultiSigAccountsCmd
(),
GetMultiSigAccountInfoCmd
(),
GetMultiSigAccUnSpentTodayCmd
(),
GetMultiSigAccAssetsCmd
(),
GetMultiSigAccAllAddressCmd
(),
)
return
cmd
}
func
MultiSigOwnerCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"owner"
,
Short
:
"multisig owner"
,
Args
:
cobra
.
MinimumNArgs
(
1
),
}
cmd
.
AddCommand
(
CreateMultiSigAccOwnerAddCmd
(),
CreateMultiSigAccOwnerDelCmd
(),
CreateMultiSigAccOwnerModifyCmd
(),
CreateMultiSigAccOwnerReplaceCmd
(),
CreateMultiSigAccWeightModifyCmd
(),
CreateMultiSigAccDailyLimitModifyCmd
(),
)
return
cmd
}
func
MultiSigTxCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"tx"
,
Short
:
"multisig tx"
,
Args
:
cobra
.
MinimumNArgs
(
1
),
}
cmd
.
AddCommand
(
CreateMultiSigConfirmTxCmd
(),
CreateMultiSigAccTransferInCmd
(),
CreateMultiSigAccTransferOutCmd
(),
GetMultiSigAccCountCmd
(),
GetMultiSigAccountsCmd
(),
GetMultiSigAccountInfoCmd
(),
GetMultiSigAccTxCountCmd
(),
GetMultiSigTxidsCmd
(),
GetMultiSigTxInfoCmd
(),
GetMultiSigTxConfirmedWeightCmd
(),
GetMultiSigAccUnSpentTodayCmd
(),
GetMultiSigAccAssetsCmd
(),
GetMultiSigAccAllAddressCmd
(),
)
return
cmd
}
...
...
@@ -159,7 +192,7 @@ func createMultiSigAccTransfer(cmd *cobra.Command, args []string) {
// CreateMultiSigAccOwnerAddCmd create raw MultiSigAccOwnerAdd transaction
func
CreateMultiSigAccOwnerAddCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"
owner_
add"
,
Use
:
"add"
,
Short
:
"Create a add owner transaction"
,
Run
:
createOwnerAddTransfer
,
}
...
...
@@ -200,7 +233,7 @@ func createOwnerAddTransfer(cmd *cobra.Command, args []string) {
// CreateMultiSigAccOwnerDelCmd create raw MultiSigAccOwnerDel transaction
func
CreateMultiSigAccOwnerDelCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"
owner_
del"
,
Use
:
"del"
,
Short
:
"Create a del owner transaction"
,
Run
:
createOwnerDelTransfer
,
}
...
...
@@ -235,7 +268,7 @@ func createOwnerDelTransfer(cmd *cobra.Command, args []string) {
// CreateMultiSigAccOwnerModifyCmd create raw MultiSigAccOwnerDel transaction
func
CreateMultiSigAccOwnerModifyCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"
owner_
modify"
,
Use
:
"modify"
,
Short
:
"Create a modify owner weight transaction"
,
Run
:
createOwnerModifyTransfer
,
}
...
...
@@ -273,7 +306,7 @@ func createOwnerModifyTransfer(cmd *cobra.Command, args []string) {
// CreateMultiSigAccOwnerReplaceCmd create raw MultiSigAccOwnerReplace transaction
func
CreateMultiSigAccOwnerReplaceCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"
owner_
replace"
,
Use
:
"replace"
,
Short
:
"Create a replace owner transaction"
,
Run
:
createOwnerReplaceTransfer
,
}
...
...
@@ -311,7 +344,7 @@ func createOwnerReplaceTransfer(cmd *cobra.Command, args []string) {
// CreateMultiSigAccWeightModifyCmd create raw CreateMultiSigAccWeightModifyCmd transaction
func
CreateMultiSigAccWeightModifyCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"weight
_modify
"
,
Use
:
"weight"
,
Short
:
"Create a modify required weight transaction"
,
Run
:
createMultiSigAccWeightModifyTransfer
,
}
...
...
@@ -552,7 +585,7 @@ func createMultiSigAccTransferOut(cmd *cobra.Command, args []string) {
//GetMultiSigAccCountCmd 获取已经创建的多重签名账户数量
func
GetMultiSigAccCountCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"
get_account_
count"
,
Use
:
"count"
,
Short
:
"get multisig account count"
,
Run
:
getMultiSigAccCount
,
}
...
...
@@ -577,8 +610,8 @@ func getMultiSigAccCount(cmd *cobra.Command, args []string) {
//GetMultiSigAccountsCmd 获取已经创建的多重签名账户地址,通过转入的index
func
GetMultiSigAccountsCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"
get_account
s"
,
Short
:
"get multisig accounts"
,
Use
:
"
addres
s"
,
Short
:
"get multisig account
addres
s"
,
Run
:
getMultiSigAccounts
,
}
addgetMultiSigAccountsFlags
(
cmd
)
...
...
@@ -623,7 +656,7 @@ func getMultiSigAccounts(cmd *cobra.Command, args []string) {
//GetMultiSigAccountInfoCmd 获取已经创建的多重签名账户信息
func
GetMultiSigAccountInfoCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"
get_acc_
info"
,
Use
:
"info"
,
Short
:
"get multisig account info"
,
Run
:
getMultiSigAccountInfo
,
}
...
...
@@ -689,7 +722,7 @@ func parseAccInfo(view interface{}) (interface{}, error) {
//GetMultiSigAccTxCountCmd 获取多重签名账户上的tx交易数量
func
GetMultiSigAccTxCountCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"
get_tx_
count"
,
Use
:
"count"
,
Short
:
"get multisig tx count"
,
Run
:
getMultiSigAccTxCount
,
}
...
...
@@ -724,7 +757,7 @@ func getMultiSigAccTxCount(cmd *cobra.Command, args []string) {
//GetMultiSigTxidsCmd 获取多重签名账户上的tx交易数量
func
GetMultiSigTxidsCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"
get_
txids"
,
Use
:
"txids"
,
Short
:
"get multisig txids"
,
Run
:
getMultiSigTxids
,
}
...
...
@@ -795,7 +828,7 @@ func getMultiSigTxids(cmd *cobra.Command, args []string) {
//GetMultiSigTxInfoCmd 获取已经创建的多重签名账户的交易信息
func
GetMultiSigTxInfoCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"
get_tx_
info"
,
Use
:
"info"
,
Short
:
"get multisig account tx info"
,
Run
:
getMultiSigTxInfo
,
}
...
...
@@ -835,7 +868,7 @@ func getMultiSigTxInfo(cmd *cobra.Command, args []string) {
//GetMultiSigTxConfirmedWeightCmd 获取交易已经被确认的总权重
func
GetMultiSigTxConfirmedWeightCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"
get_
confirmed_weight"
,
Use
:
"confirmed_weight"
,
Short
:
"get the weight of the transaction confirmed."
,
Run
:
getGetMultiSigTxConfirmedWeight
,
}
...
...
@@ -875,7 +908,7 @@ func getGetMultiSigTxConfirmedWeight(cmd *cobra.Command, args []string) {
//GetMultiSigAccUnSpentTodayCmd 获取多重签名账户今日免多重签名的余额
func
GetMultiSigAccUnSpentTodayCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"
get_
unspent"
,
Use
:
"unspent"
,
Short
:
"get assets unspent today amount"
,
Run
:
getMultiSigAccUnSpentToday
,
}
...
...
@@ -948,7 +981,7 @@ func parseUnSpentToday(view interface{}) (interface{}, error) {
//GetMultiSigAccAssetsCmd 获取多重签名账户上的资产信息
func
GetMultiSigAccAssetsCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"
get_
assets"
,
Use
:
"assets"
,
Short
:
"get assets of multisig account"
,
Run
:
getMultiSigAccAssets
,
}
...
...
@@ -1028,7 +1061,7 @@ func parseAccAssets(view interface{}) (interface{}, error) {
//GetMultiSigAccAllAddressCmd 获取指定地址创建的所有多重签名账户
func
GetMultiSigAccAllAddressCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"
get_cre_accounts
"
,
Use
:
"
creater
"
,
Short
:
"get all multisig accounts created by the address"
,
Run
:
getMultiSigAccAllAddress
,
}
...
...
plugin/dapp/multisig/executor/multisig.go
View file @
c989cfb0
...
...
@@ -84,42 +84,32 @@ func (m *MultiSig) CheckTx(tx *types.Transaction, index int) error {
//MultiSigAccCreate 交易校验
if
ato
,
ok
:=
payload
.
(
*
mty
.
MultiSigAccCreate
);
ok
{
err
:=
checkAccountCreateTx
(
ato
)
if
err
!=
nil
{
return
err
}
return
checkAccountCreateTx
(
ato
)
}
//MultiSigOwnerOperate 交易的检测
if
ato
,
ok
:=
payload
.
(
*
mty
.
MultiSigOwnerOperate
);
ok
{
err
:=
checkOwnerOperateTx
(
ato
)
if
err
!=
nil
{
return
err
}
return
checkOwnerOperateTx
(
ato
)
}
//MultiSigAccOperate
to 地址
检测
//MultiSigAccOperate
交易的
检测
if
ato
,
ok
:=
payload
.
(
*
mty
.
MultiSigAccOperate
);
ok
{
err
:=
checkAccountOperateTx
(
ato
)
if
err
!=
nil
{
return
err
}
return
checkAccountOperateTx
(
ato
)
}
//MultiSigConfirmTx
multiSigAccAddr地址
检测
//MultiSigConfirmTx
交易的
检测
if
ato
,
ok
:=
payload
.
(
*
mty
.
MultiSigConfirmTx
);
ok
{
if
err
:=
address
.
CheckAddress
(
ato
.
GetMultiSigAccAddr
());
err
!=
nil
{
return
types
.
ErrInvalidAddress
}
return
nil
}
//MultiSigExecTransfer
to 地址
检测
//MultiSigExecTransfer
交易的
检测
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
mty
.
IsAssetsInvalid
(
ato
.
GetExecname
(),
ato
.
GetSymbol
())
}
return
nil
}
...
...
@@ -167,10 +157,7 @@ func checkAccountCreateTx(ato *mty.MultiSigAccCreate) error {
dailyLimit
:=
ato
.
GetDailyLimit
()
//assets check
if
err
:=
mty
.
IsAssetsInvalid
(
dailyLimit
.
GetExecer
(),
dailyLimit
.
GetSymbol
());
err
!=
nil
{
return
err
}
return
nil
return
mty
.
IsAssetsInvalid
(
dailyLimit
.
GetExecer
(),
dailyLimit
.
GetSymbol
())
}
func
checkOwnerOperateTx
(
ato
*
mty
.
MultiSigOwnerOperate
)
error
{
...
...
@@ -229,9 +216,7 @@ func checkAccountOperateTx(ato *mty.MultiSigAccOperate) error {
if
ato
.
OperateFlag
==
mty
.
AccDailyLimitOp
{
dailyLimit
:=
ato
.
GetDailyLimit
()
//assets check
if
err
:=
mty
.
IsAssetsInvalid
(
dailyLimit
.
GetExecer
(),
dailyLimit
.
GetSymbol
());
err
!=
nil
{
return
err
}
return
mty
.
IsAssetsInvalid
(
dailyLimit
.
GetExecer
(),
dailyLimit
.
GetSymbol
())
}
return
nil
}
...
...
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