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
619f4775
Commit
619f4775
authored
Jan 25, 2019
by
heyubin
Committed by
vipwzw
Jan 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add by hyb for get multisig account by owner
parent
f5f0a308
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
517 additions
and
0 deletions
+517
-0
chain33.toml
chain33.toml
+3
-0
multisig.go
plugin/dapp/multisig/commands/multisig.go
+28
-0
doc.go
plugin/dapp/multisig/doc.go
+3
-0
query.go
plugin/dapp/multisig/executor/query.go
+2
-0
plugin.go
plugin/dapp/multisig/plugin.go
+1
-0
multisig.proto
plugin/dapp/multisig/proto/multisig.proto
+12
-0
rpc.go
plugin/dapp/multisig/rpc/rpc.go
+10
-0
rpc_real_test.go
plugin/dapp/multisig/rpc/rpc_real_test.go
+8
-0
multisig.pb.go
plugin/dapp/multisig/types/multisig.pb.go
+0
-0
const.go
plugin/dapp/multisig/wallet/const.go
+9
-0
exec.go
plugin/dapp/multisig/wallet/exec.go
+30
-0
exec_test.go
plugin/dapp/multisig/wallet/exec_test.go
+319
-0
keys.go
plugin/dapp/multisig/wallet/keys.go
+20
-0
multisig.go
plugin/dapp/multisig/wallet/multisig.go
+0
-0
multisig_store.go
plugin/dapp/multisig/wallet/multisig_store.go
+72
-0
No files found.
chain33.toml
View file @
619f4775
...
...
@@ -158,6 +158,9 @@ signType="secp256k1"
minerdisable
=
false
minerwhitelist
=
["*"]
[wallet.sub.multisig]
rescanMultisigAddr
=
false
[exec]
isFree
=
false
minExecFee
=
100000
...
...
plugin/dapp/multisig/commands/multisig.go
View file @
619f4775
...
...
@@ -51,6 +51,7 @@ func MultiSigAccountCmd() *cobra.Command {
GetMultiSigAccUnSpentTodayCmd
(),
GetMultiSigAccAssetsCmd
(),
GetMultiSigAccAllAddressCmd
(),
GetMultiSigAccByOwnerCmd
(),
)
return
cmd
}
...
...
@@ -1100,3 +1101,30 @@ func isValidDailylimit(dailylimit float64) error {
}
return
nil
}
//GetMultiSigAccByOwnerCmd 获取指定地址拥有的所有多重签名账户
func
GetMultiSigAccByOwnerCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"owner"
,
Short
:
"get multisig accounts by the owner"
,
Run
:
getMultiSigAccByOwner
,
}
getMultiSigAccByOwnerFlags
(
cmd
)
return
cmd
}
func
getMultiSigAccByOwnerFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"addr"
,
"a"
,
""
,
"address of owner"
)
}
func
getMultiSigAccByOwner
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
ownerAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"addr"
)
params
:=
&
types
.
ReqString
{
Data
:
ownerAddr
,
}
var
res
mty
.
OwnerAttrs
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"multisig.MultiSigAddresList"
,
params
,
&
res
)
ctx
.
Run
()
}
plugin/dapp/multisig/doc.go
View file @
619f4775
...
...
@@ -34,6 +34,7 @@ Available Commands:
creator get all multisig accounts created by the address
dailylimit Create a modify assets dailylimit transaction
info get multisig account info
owner get multisig accounts by the owner
unspent get assets unspent today amount
weight Create a modify required weight transaction
...
...
@@ -194,4 +195,6 @@ cli send multisig tx confirm -a "13q53Ga1kquDCqx7EWF8FU94tLUK18Zd47" -i 8 -k "1
cli send multisig tx confirm -a "13q53Ga1kquDCqx7EWF8FU94tLUK18Zd47" -i 8 -k "1C5xK2ytuoFqxmVGMcyz9XFKFWcDA8T3rK"
// 获取owner拥有的所有多重签名地址,不指定地址时返回的是本钱包拥有的所有多重签名地址
cli multisig account owner -a 166po3ghRbRu53hu8jBBQzddp7kUJ9Ynyf
*/
plugin/dapp/multisig/executor/query.go
View file @
619f4775
...
...
@@ -192,6 +192,8 @@ func (m *MultiSig) Query_MultiSigTxInfo(in *mty.ReqMultiSigTxInfo) (types.Messag
}
if
multiSigTx
==
nil
{
multiSigTx
=
&
mty
.
MultiSigTx
{}
}
else
{
//由于代码中使用hex.EncodeToString()接口转换的,没有加0x,为了方便上层统一处理再次返回时增加0x即可
multiSigTx
.
TxHash
=
"0x"
+
multiSigTx
.
TxHash
}
return
multiSigTx
,
nil
}
...
...
plugin/dapp/multisig/plugin.go
View file @
619f4775
...
...
@@ -6,6 +6,7 @@ import (
"github.com/33cn/plugin/plugin/dapp/multisig/executor"
"github.com/33cn/plugin/plugin/dapp/multisig/rpc"
mty
"github.com/33cn/plugin/plugin/dapp/multisig/types"
_
"github.com/33cn/plugin/plugin/dapp/multisig/wallet"
// register wallet package
)
func
init
()
{
...
...
plugin/dapp/multisig/proto/multisig.proto
View file @
619f4775
...
...
@@ -338,4 +338,15 @@ message Assets {
//账户地址列表
message
AccAddress
{
repeated
string
address
=
1
;
}
//owner拥有的多重签名账户信息
message
OwnerAttr
{
string
multiSigAddr
=
1
;
string
ownerAddr
=
2
;
uint64
weight
=
3
;
}
message
OwnerAttrs
{
repeated
OwnerAttr
items
=
1
;
}
\ No newline at end of file
plugin/dapp/multisig/rpc/rpc.go
View file @
619f4775
...
...
@@ -91,3 +91,13 @@ func (c *Jrpc) MultiSigAccTransferOutTx(param *mty.MultiSigExecTransferFrom, res
*
result
=
hex
.
EncodeToString
(
data
)
return
nil
}
// MultiSigAddresList 获取owner地址上的多重签名账户列表{multiSigAddr,owneraddr,weight}
func
(
c
*
Jrpc
)
MultiSigAddresList
(
in
*
types
.
ReqString
,
result
*
interface
{})
error
{
reply
,
err
:=
c
.
cli
.
ExecWalletFunc
(
mty
.
MultiSigX
,
"MultiSigAddresList"
,
in
)
if
err
!=
nil
{
return
err
}
*
result
=
reply
return
nil
}
plugin/dapp/multisig/rpc/rpc_real_test.go
View file @
619f4775
...
...
@@ -193,6 +193,14 @@ func testAccCreateTx(t *testing.T, mocker *testnode.Chain33Mock, jrpcClient *jso
assert
.
Equal
(
t
,
rep3
.
Address
[
0
],
multiSigAccAddr
)
//t.Log(rep3)
//获取owner拥有的多重签名账户地址
req4
:=
&
types
.
ReqString
{
Data
:
GenAddr
,
}
var
res4
mty
.
OwnerAttrs
err
=
jrpcClient
.
Call
(
"multisig.MultiSigAddresList"
,
req4
,
&
res4
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
res4
.
Items
[
0
]
.
OwnerAddr
,
GenAddr
)
return
multiSigAccAddr
}
...
...
plugin/dapp/multisig/types/multisig.pb.go
View file @
619f4775
This diff is collapsed.
Click to expand it.
plugin/dapp/multisig/wallet/const.go
0 → 100644
View file @
619f4775
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
wallet
const
(
MaxCountPerTime
int64
=
100
)
plugin/dapp/multisig/wallet/exec.go
0 → 100644
View file @
619f4775
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
wallet
import
(
"github.com/33cn/chain33/types"
)
//On_MultiSigAddresList 获取owner对应的多重签名地址列表
func
(
policy
*
multisigPolicy
)
On_MultiSigAddresList
(
req
*
types
.
ReqString
)
(
types
.
Message
,
error
)
{
policy
.
getWalletOperate
()
.
GetMutex
()
.
Lock
()
defer
policy
.
getWalletOperate
()
.
GetMutex
()
.
Unlock
()
//获取本钱包中记录的所有多重签名地址
if
req
.
Data
==
""
{
reply
,
err
:=
policy
.
store
.
listOwnerAttrs
()
if
err
!=
nil
{
bizlog
.
Error
(
"On_MultiSigAddresList listOwnerAttrs"
,
"err"
,
err
)
}
return
reply
,
err
}
//值查询指定owner地址拥有的多重签名地址列表
reply
,
err
:=
policy
.
store
.
listOwnerAttrsByAddr
(
req
.
Data
)
if
err
!=
nil
{
bizlog
.
Error
(
"On_MultiSigAddresList listOwnerAttrsByAddr"
,
"owneraddr"
,
req
.
Data
,
"err"
,
err
)
}
return
reply
,
err
}
plugin/dapp/multisig/wallet/exec_test.go
0 → 100644
View file @
619f4775
This diff is collapsed.
Click to expand it.
plugin/dapp/multisig/wallet/keys.go
0 → 100644
View file @
619f4775
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
wallet
import
"fmt"
const
(
// MultisigAddr 记录本钱包owner地址拥有的多重签名地址,key:"multisig-addr-owneraddr, value [](multisigaddr,owneraddr,weight)
MultisigAddr
=
"multisig-addr-"
)
func
calcMultisigAddr
(
ownerAddr
string
)
[]
byte
{
return
[]
byte
(
fmt
.
Sprintf
(
"%s%s"
,
MultisigAddr
,
ownerAddr
))
}
func
calcPrefixMultisigAddr
()
[]
byte
{
return
[]
byte
(
MultisigAddr
)
}
plugin/dapp/multisig/wallet/multisig.go
0 → 100644
View file @
619f4775
This diff is collapsed.
Click to expand it.
plugin/dapp/multisig/wallet/multisig_store.go
0 → 100644
View file @
619f4775
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
wallet
import
(
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/types"
wcom
"github.com/33cn/chain33/wallet/common"
mtypes
"github.com/33cn/plugin/plugin/dapp/multisig/types"
)
func
newStore
(
db
db
.
DB
)
*
multisigStore
{
return
&
multisigStore
{
Store
:
wcom
.
NewStore
(
db
)}
}
// multisigStore 多重签名数据库存储操作类
type
multisigStore
struct
{
*
wcom
.
Store
}
//获取指定owner拥有的多重签名地址
func
(
store
*
multisigStore
)
listOwnerAttrsByAddr
(
addr
string
)
(
*
mtypes
.
OwnerAttrs
,
error
)
{
if
len
(
addr
)
==
0
{
bizlog
.
Error
(
"listMultisigAddrByOwnerAddr addr is nil"
)
return
nil
,
types
.
ErrInvalidParam
}
ownerAttrByte
,
err
:=
store
.
Get
(
calcMultisigAddr
(
addr
))
if
err
!=
nil
{
bizlog
.
Error
(
"listMultisigAddrByOwnerAddr"
,
"addr"
,
addr
,
"db Get error "
,
err
)
if
err
==
db
.
ErrNotFoundInDb
{
return
nil
,
types
.
ErrNotFound
}
return
nil
,
err
}
if
nil
==
ownerAttrByte
||
len
(
ownerAttrByte
)
==
0
{
return
nil
,
types
.
ErrNotFound
}
var
ownerAttrs
mtypes
.
OwnerAttrs
err
=
types
.
Decode
(
ownerAttrByte
,
&
ownerAttrs
)
if
err
!=
nil
{
bizlog
.
Error
(
"listMultisigAddrByOwnerAddr"
,
"proto.Unmarshal err:"
,
err
)
return
nil
,
types
.
ErrUnmarshal
}
return
&
ownerAttrs
,
nil
}
//获取本钱包地址拥有的所有多重签名地址
func
(
store
*
multisigStore
)
listOwnerAttrs
()
(
*
mtypes
.
OwnerAttrs
,
error
)
{
list
:=
store
.
NewListHelper
()
ownerbytes
:=
list
.
PrefixScan
(
calcPrefixMultisigAddr
())
if
len
(
ownerbytes
)
==
0
{
bizlog
.
Error
(
"listOwnerAttrs is null"
)
return
nil
,
types
.
ErrNotFound
}
var
replayOwnerAttrs
mtypes
.
OwnerAttrs
for
_
,
ownerattrbytes
:=
range
ownerbytes
{
var
ownerAttrs
mtypes
.
OwnerAttrs
err
:=
types
.
Decode
(
ownerattrbytes
,
&
ownerAttrs
)
if
err
!=
nil
{
bizlog
.
Error
(
"listOwnerAttrs"
,
"Decode err"
,
err
)
continue
}
for
_
,
ownerAttr
:=
range
ownerAttrs
.
Items
{
replayOwnerAttrs
.
Items
=
append
(
replayOwnerAttrs
.
Items
,
ownerAttr
)
}
}
return
&
replayOwnerAttrs
,
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