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
8c429796
Commit
8c429796
authored
Jan 24, 2019
by
linj
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into trade-localdb
parents
57c2349e
12653f8f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
182 additions
and
536 deletions
+182
-536
guess.go
plugin/dapp/guess/executor/guess.go
+1
-9
guessdb.go
plugin/dapp/guess/executor/guessdb.go
+5
-68
testcase.sh
plugin/dapp/paracross/cmd/build/testcase.sh
+1
-1
privacy.toml
plugin/dapp/privacy/autotest/privacy.toml
+16
-16
privacy.go
plugin/dapp/privacy/commands/privacy.go
+79
-91
ring_signature_crypto.go
plugin/dapp/privacy/crypto/ring_signature_crypto.go
+2
-1
exec.go
plugin/dapp/privacy/executor/exec.go
+1
-1
privacy.go
plugin/dapp/privacy/executor/privacy.go
+13
-9
privacy.proto
plugin/dapp/privacy/proto/privacy.proto
+1
-49
rpc.go
plugin/dapp/privacy/rpc/rpc.go
+0
-62
rpc_channel_test.go
plugin/dapp/privacy/rpc/rpc_channel_test.go
+0
-49
privacy.pb.go
plugin/dapp/privacy/types/privacy.pb.go
+0
-0
exec.go
plugin/dapp/privacy/wallet/exec.go
+0
-30
privacy.go
plugin/dapp/privacy/wallet/privacy.go
+0
-0
privacybizpolicy_test.go
plugin/dapp/privacy/wallet/privacybizpolicy_test.go
+0
-111
ticket.go
plugin/dapp/ticket/commands/ticket.go
+2
-9
types.go
plugin/dapp/ticket/commands/types.go
+0
-9
jrpc_channel_test.go
plugin/dapp/ticket/rpc/jrpc_channel_test.go
+4
-4
rpc.go
plugin/dapp/ticket/rpc/rpc.go
+1
-3
rpc_real_test.go
plugin/dapp/ticket/rpc/rpc_real_test.go
+9
-0
gitlab-ci-autotest.sh
...3cn/chain33/build/autotest/gitlabci/gitlab-ci-autotest.sh
+1
-1
jerkins-ci-autotest.sh
...n/chain33/build/autotest/jerkinsci/jerkins-ci-autotest.sh
+1
-1
local-autotest.sh
...b.com/33cn/chain33/build/autotest/local/local-autotest.sh
+1
-1
black_list.sh
vendor/github.com/33cn/chain33/build/util/black_list.sh
+2
-2
manage.sh
vendor/github.com/33cn/chain33/build/util/manage.sh
+1
-1
manage_list.sh
vendor/github.com/33cn/chain33/build/util/manage_list.sh
+2
-2
allow.go
vendor/github.com/33cn/chain33/executor/allow.go
+2
-2
executor_test.go
vendor/github.com/33cn/chain33/executor/executor_test.go
+2
-0
api_test.go
vendor/github.com/33cn/chain33/rpc/grpcclient/api_test.go
+31
-0
resolver.go
vendor/github.com/33cn/chain33/rpc/grpcclient/resolver.go
+1
-1
config.go
...ub.com/33cn/chain33/system/dapp/manage/commands/config.go
+3
-3
No files found.
plugin/dapp/guess/executor/guess.go
View file @
8c429796
...
@@ -20,21 +20,13 @@ func init() {
...
@@ -20,21 +20,13 @@ func init() {
ety
.
InitFuncList
(
types
.
ListMethod
(
&
Guess
{}))
ety
.
InitFuncList
(
types
.
ListMethod
(
&
Guess
{}))
}
}
type
subConfig
struct
{
ParaRemoteGrpcClient
string
`json:"paraRemoteGrpcClient"`
}
var
cfg
subConfig
// Init Guess
// Init Guess
func
Init
(
name
string
,
sub
[]
byte
)
{
func
Init
(
name
string
,
sub
[]
byte
)
{
driverName
:=
GetName
()
driverName
:=
GetName
()
if
name
!=
driverName
{
if
name
!=
driverName
{
panic
(
"system dapp can't be rename"
)
panic
(
"system dapp can't be rename"
)
}
}
if
sub
!=
nil
{
types
.
MustDecode
(
sub
,
&
cfg
)
}
drivers
.
Register
(
driverName
,
newGuessGame
,
types
.
GetDappFork
(
driverName
,
"Enable"
))
drivers
.
Register
(
driverName
,
newGuessGame
,
types
.
GetDappFork
(
driverName
,
"Enable"
))
}
}
...
...
plugin/dapp/guess/executor/guessdb.go
View file @
8c429796
...
@@ -5,17 +5,12 @@
...
@@ -5,17 +5,12 @@
package
executor
package
executor
import
(
import
(
"context"
"fmt"
"fmt"
"strings"
"strings"
"time"
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/common/db/table"
"github.com/33cn/chain33/common/db/table"
"github.com/33cn/chain33/client"
"google.golang.org/grpc"
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common"
dbm
"github.com/33cn/chain33/common/db"
dbm
"github.com/33cn/chain33/common/db"
...
@@ -48,12 +43,6 @@ const (
...
@@ -48,12 +43,6 @@ const (
//MaxExpireHeight 距离游戏创建区块的最大过期高度差
//MaxExpireHeight 距离游戏创建区块的最大过期高度差
MaxExpireHeight
=
1000000
MaxExpireHeight
=
1000000
//grpcRecSize 接收缓冲大小
grpcRecSize
int
=
30
*
1024
*
1024
//retryNum 失败时的重试次数
retryNum
=
10
)
)
//Action 具体动作执行
//Action 具体动作执行
...
@@ -67,9 +56,7 @@ type Action struct {
...
@@ -67,9 +56,7 @@ type Action struct {
execaddr
string
execaddr
string
localDB
dbm
.
KVDB
localDB
dbm
.
KVDB
index
int
index
int
api
client
.
QueueProtocolAPI
mainHeight
int64
conn
*
grpc
.
ClientConn
grpcClient
types
.
Chain33Client
}
}
//NewAction 生成Action对象
//NewAction 生成Action对象
...
@@ -77,19 +64,6 @@ func NewAction(guess *Guess, tx *types.Transaction, index int) *Action {
...
@@ -77,19 +64,6 @@ func NewAction(guess *Guess, tx *types.Transaction, index int) *Action {
hash
:=
tx
.
Hash
()
hash
:=
tx
.
Hash
()
fromAddr
:=
tx
.
From
()
fromAddr
:=
tx
.
From
()
msgRecvOp
:=
grpc
.
WithMaxMsgSize
(
grpcRecSize
)
paraRemoteGrpcClient
:=
types
.
Conf
(
"config.consensus"
)
.
GStr
(
"ParaRemoteGrpcClient"
)
if
types
.
IsPara
()
&&
paraRemoteGrpcClient
==
""
{
panic
(
"ParaRemoteGrpcClient error"
)
}
conn
,
err
:=
grpc
.
Dial
(
paraRemoteGrpcClient
,
grpc
.
WithInsecure
(),
msgRecvOp
)
if
err
!=
nil
{
panic
(
err
)
}
grpcClient
:=
types
.
NewChain33Client
(
conn
)
return
&
Action
{
return
&
Action
{
coinsAccount
:
guess
.
GetCoinsAccount
(),
coinsAccount
:
guess
.
GetCoinsAccount
(),
db
:
guess
.
GetStateDB
(),
db
:
guess
.
GetStateDB
(),
...
@@ -100,9 +74,7 @@ func NewAction(guess *Guess, tx *types.Transaction, index int) *Action {
...
@@ -100,9 +74,7 @@ func NewAction(guess *Guess, tx *types.Transaction, index int) *Action {
execaddr
:
dapp
.
ExecAddress
(
string
(
tx
.
Execer
)),
execaddr
:
dapp
.
ExecAddress
(
string
(
tx
.
Execer
)),
localDB
:
guess
.
GetLocalDB
(),
localDB
:
guess
.
GetLocalDB
(),
index
:
index
,
index
:
index
,
api
:
guess
.
GetAPI
(),
mainHeight
:
guess
.
GetMainHeight
(),
conn
:
conn
,
grpcClient
:
grpcClient
,
}
}
}
}
...
@@ -299,7 +271,7 @@ func (action *Action) readGame(id string) (*gty.GuessGame, error) {
...
@@ -299,7 +271,7 @@ func (action *Action) readGame(id string) (*gty.GuessGame, error) {
func
(
action
*
Action
)
newGame
(
gameID
string
,
start
*
gty
.
GuessGameStart
)
(
*
gty
.
GuessGame
,
error
)
{
func
(
action
*
Action
)
newGame
(
gameID
string
,
start
*
gty
.
GuessGameStart
)
(
*
gty
.
GuessGame
,
error
)
{
game
:=
&
gty
.
GuessGame
{
game
:=
&
gty
.
GuessGame
{
GameID
:
gameID
,
GameID
:
gameID
,
Status
:
gty
.
GuessGame
Action
Start
,
Status
:
gty
.
GuessGame
Status
Start
,
//StartTime: action.blocktime,
//StartTime: action.blocktime,
StartTxHash
:
gameID
,
StartTxHash
:
gameID
,
Topic
:
start
.
Topic
,
Topic
:
start
.
Topic
,
...
@@ -375,16 +347,7 @@ func (action *Action) GameStart(start *gty.GuessGameStart) (*types.Receipt, erro
...
@@ -375,16 +347,7 @@ func (action *Action) GameStart(start *gty.GuessGameStart) (*types.Receipt, erro
gameID
:=
common
.
ToHex
(
action
.
txhash
)
gameID
:=
common
.
ToHex
(
action
.
txhash
)
game
,
_
:=
action
.
newGame
(
gameID
,
start
)
game
,
_
:=
action
.
newGame
(
gameID
,
start
)
game
.
StartTime
=
action
.
blocktime
game
.
StartTime
=
action
.
blocktime
if
types
.
IsPara
()
{
game
.
StartHeight
=
action
.
mainHeight
mainHeight
:=
action
.
GetMainHeightByTxHash
(
action
.
txhash
)
if
mainHeight
<
0
{
logger
.
Error
(
"GameStart"
,
"mainHeight"
,
mainHeight
)
return
nil
,
gty
.
ErrGuessStatus
}
game
.
StartHeight
=
mainHeight
}
else
{
game
.
StartHeight
=
action
.
height
}
game
.
AdminAddr
=
action
.
fromaddr
game
.
AdminAddr
=
action
.
fromaddr
game
.
PreIndex
=
0
game
.
PreIndex
=
0
game
.
Index
=
action
.
getIndex
()
game
.
Index
=
action
.
getIndex
()
...
@@ -831,18 +794,7 @@ func (action *Action) changeAllAddrIndex(game *gty.GuessGame) {
...
@@ -831,18 +794,7 @@ func (action *Action) changeAllAddrIndex(game *gty.GuessGame) {
//refreshStatusByTime 检测游戏是否过期,是否可以下注
//refreshStatusByTime 检测游戏是否过期,是否可以下注
func
(
action
*
Action
)
refreshStatusByTime
(
game
*
gty
.
GuessGame
)
(
canBet
bool
)
{
func
(
action
*
Action
)
refreshStatusByTime
(
game
*
gty
.
GuessGame
)
(
canBet
bool
)
{
mainHeight
:=
action
.
mainHeight
var
mainHeight
int64
if
types
.
IsPara
()
{
mainHeight
=
action
.
GetMainHeightByTxHash
(
action
.
txhash
)
if
mainHeight
<
0
{
logger
.
Error
(
"RefreshStatusByTime"
,
"mainHeight err"
,
mainHeight
)
return
true
}
}
else
{
mainHeight
=
action
.
height
}
//如果完全由管理员驱动状态变化,则除了保护性过期判断外,不需要做其他判断。
//如果完全由管理员驱动状态变化,则除了保护性过期判断外,不需要做其他判断。
if
game
.
DrivenByAdmin
{
if
game
.
DrivenByAdmin
{
...
@@ -899,18 +851,3 @@ func (action *Action) checkTime(start *gty.GuessGameStart) bool {
...
@@ -899,18 +851,3 @@ func (action *Action) checkTime(start *gty.GuessGameStart) bool {
return
false
return
false
}
}
// GetMainHeightByTxHash get Block height
func
(
action
*
Action
)
GetMainHeightByTxHash
(
txHash
[]
byte
)
int64
{
for
i
:=
0
;
i
<
retryNum
;
i
++
{
req
:=
&
types
.
ReqHash
{
Hash
:
txHash
}
txDetail
,
err
:=
action
.
grpcClient
.
QueryTransaction
(
context
.
Background
(),
req
)
if
err
!=
nil
{
time
.
Sleep
(
time
.
Second
)
}
else
{
return
txDetail
.
GetHeight
()
}
}
return
-
1
}
plugin/dapp/paracross/cmd/build/testcase.sh
View file @
8c429796
...
@@ -107,7 +107,7 @@ function para_transfer2account() {
...
@@ -107,7 +107,7 @@ function para_transfer2account() {
}
}
function
para_configkey
()
{
function
para_configkey
()
{
tx
=
$(${
1
}
config config_tx
-o
add
-
k
"
${
2
}
"
-v
"
${
3
}
"
)
tx
=
$(${
1
}
config config_tx
-o
add
-
c
"
${
2
}
"
-v
"
${
3
}
"
)
sign
=
$(${
CLI
}
wallet sign
-k
0xc34b5d9d44ac7b754806f761d3d4d2c4fe5214f6b074c19f069c4f5c2a29c8cc
-d
"
${
tx
}
"
)
sign
=
$(${
CLI
}
wallet sign
-k
0xc34b5d9d44ac7b754806f761d3d4d2c4fe5214f6b074c19f069c4f5c2a29c8cc
-d
"
${
tx
}
"
)
send
=
$(${
CLI
}
wallet send
-d
"
${
sign
}
"
)
send
=
$(${
CLI
}
wallet send
-d
"
${
sign
}
"
)
echo
"
${
send
}
"
echo
"
${
send
}
"
...
...
plugin/dapp/privacy/autotest/privacy.toml
View file @
8c429796
...
@@ -10,7 +10,7 @@ dep = ["import1", "import2", "import3"]
...
@@ -10,7 +10,7 @@ dep = ["import1", "import2", "import3"]
id
=
"import1"
id
=
"import1"
command
=
"account import_key -k 0x88b2fb90411935872f0501dd13345aba19b5fac9b00eb0dddd7df977d4d5477e -l privacy_test1"
command
=
"account import_key -k 0x88b2fb90411935872f0501dd13345aba19b5fac9b00eb0dddd7df977d4d5477e -l privacy_test1"
#import privacy test addr,17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT
#import privacy test addr,
17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT
[[SimpleCase]]
[[SimpleCase]]
id
=
"import2"
id
=
"import2"
command
=
"account import_key -k 0xa0c6f46de8d275ce21e935afa5363e9b8a087fe604e05f7a9eef1258dc781c3a -l privacy_test2"
command
=
"account import_key -k 0xa0c6f46de8d275ce21e935afa5363e9b8a087fe604e05f7a9eef1258dc781c3a -l privacy_test2"
...
@@ -63,7 +63,7 @@ dep = ["enablePrivacy"]
...
@@ -63,7 +63,7 @@ dep = ["enablePrivacy"]
#pub2priv
#pub2priv
[[PubToPrivCase]]
[[PubToPrivCase]]
id
=
"pub2priv1"
id
=
"pub2priv1"
command
=
"
privacy pub2priv -a 99 -f 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -p d736dcff89c2e588d1fc3d44ba956af4d15d0a01eb1aedaf58fcbc2bdd09591fec9fd83ea6eee18c5a0fd8f1d167b1f8b020d8a6203be49f0bf3f410473fc534
"
command
=
"
send privacy pub2priv -a 99 -p d736dcff89c2e588d1fc3d44ba956af4d15d0a01eb1aedaf58fcbc2bdd09591fec9fd83ea6eee18c5a0fd8f1d167b1f8b020d8a6203be49f0bf3f410473fc534 -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
"
from
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to
=
"17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT"
to
=
"17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT"
amount
=
"99"
amount
=
"99"
...
@@ -73,7 +73,7 @@ dep = ["trans1"]
...
@@ -73,7 +73,7 @@ dep = ["trans1"]
[[PubToPrivCase]]
[[PubToPrivCase]]
id
=
"pub2priv2"
id
=
"pub2priv2"
command
=
"
privacy pub2priv -a 99 -f 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -p d45063357ab3454cfb7ee87db8f9ca2772d11bd82d4f681ce00ae44fe5929e8fd964867dae1b19b265b7f68d4ad965cfd4a0aaf71580344adf9fce28cfebadab
"
command
=
"
send privacy pub2priv -a 99 -p d45063357ab3454cfb7ee87db8f9ca2772d11bd82d4f681ce00ae44fe5929e8fd964867dae1b19b265b7f68d4ad965cfd4a0aaf71580344adf9fce28cfebadab -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
"
from
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to
=
"1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt"
to
=
"1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt"
amount
=
"99"
amount
=
"99"
...
@@ -83,7 +83,7 @@ dep = ["trans1"]
...
@@ -83,7 +83,7 @@ dep = ["trans1"]
[[PubToPrivCase]]
[[PubToPrivCase]]
id
=
"pub2priv3"
id
=
"pub2priv3"
command
=
"
privacy pub2priv -a 199 -f 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -p dda1ae3184c1f4faca5b4e4be3dfea1c5026338764aca1d2c3e8e3c0b0001f4f4d5eb1761cd27dcbf36e2559c66173bc0d46ecc4feb72dee9e60896a696a5a06
"
command
=
"
send privacy pub2priv -a 199 -p dda1ae3184c1f4faca5b4e4be3dfea1c5026338764aca1d2c3e8e3c0b0001f4f4d5eb1761cd27dcbf36e2559c66173bc0d46ecc4feb72dee9e60896a696a5a06 -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
"
from
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to
=
"12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d"
to
=
"12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d"
amount
=
"199"
amount
=
"199"
...
@@ -94,7 +94,7 @@ dep = ["trans1"]
...
@@ -94,7 +94,7 @@ dep = ["trans1"]
#failpub2priv
#failpub2priv
[[PubToPrivCase]]
[[PubToPrivCase]]
id
=
"failpub2priv1"
id
=
"failpub2priv1"
command
=
"privacy pub2priv -a 1000 -
f 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -p d736dcff89c2e588d1fc3d44ba956af4d15d0a01eb1aedaf58fcbc2bdd09591fec9fd83ea6eee18c5a0fd8f1d167b1f8b020d8a6203be49f0bf3f410473fc534
"
command
=
"privacy pub2priv -a 1000 -
p d736dcff89c2e588d1fc3d44ba956af4d15d0a01eb1aedaf58fcbc2bdd09591fec9fd83ea6eee18c5a0fd8f1d167b1f8b020d8a6203be49f0bf3f410473fc534 -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
"
from
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to
=
"17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT"
to
=
"17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT"
amount
=
"1000"
amount
=
"1000"
...
@@ -105,7 +105,7 @@ fail = true
...
@@ -105,7 +105,7 @@ fail = true
[[PubToPrivCase]]
[[PubToPrivCase]]
id
=
"failpub2priv2"
id
=
"failpub2priv2"
command
=
"privacy pub2priv -a 603 -
f 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -p d45063357ab3454cfb7ee87db8f9ca2772d11bd82d4f681ce00ae44fe5929e8fd964867dae1b19b265b7f68d4ad965cfd4a0aaf71580344adf9fce28cfebadab
"
command
=
"privacy pub2priv -a 603 -
p d45063357ab3454cfb7ee87db8f9ca2772d11bd82d4f681ce00ae44fe5929e8fd964867dae1b19b265b7f68d4ad965cfd4a0aaf71580344adf9fce28cfebadab -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
"
from
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to
=
"1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt"
to
=
"1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt"
amount
=
"603"
amount
=
"603"
...
@@ -118,7 +118,7 @@ fail = true
...
@@ -118,7 +118,7 @@ fail = true
[[PrivToPrivCase]]
[[PrivToPrivCase]]
id
=
"priv2priv1"
id
=
"priv2priv1"
command
=
"
privacy priv2priv -a 39 -f 17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT -p 0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb
"
command
=
"
send privacy priv2priv -a 39 -f 17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT -p 0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb -k 17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT
"
from
=
"17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT"
from
=
"17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount
=
"39"
amount
=
"39"
...
@@ -128,7 +128,7 @@ dep = ["pub2priv1"]
...
@@ -128,7 +128,7 @@ dep = ["pub2priv1"]
[[PrivToPrivCase]]
[[PrivToPrivCase]]
id
=
"priv2priv2"
id
=
"priv2priv2"
command
=
"
privacy priv2priv -a 49 -f 1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt -p 0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb
"
command
=
"
send privacy priv2priv -a 49 -f 1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt -p 0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb -k 1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt
"
from
=
"1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt"
from
=
"1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount
=
"49"
amount
=
"49"
...
@@ -138,7 +138,7 @@ dep = ["pub2priv2"]
...
@@ -138,7 +138,7 @@ dep = ["pub2priv2"]
[[PrivToPrivCase]]
[[PrivToPrivCase]]
id
=
"priv2priv3"
id
=
"priv2priv3"
command
=
"
privacy priv2priv -a 69 -f 12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d -p 0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb
"
command
=
"
send privacy priv2priv -a 69 -f 12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d -p 0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb -k 12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d
"
from
=
"12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d"
from
=
"12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount
=
"69"
amount
=
"69"
...
@@ -150,7 +150,7 @@ dep = ["pub2priv3"]
...
@@ -150,7 +150,7 @@ dep = ["pub2priv3"]
[[PrivToPrivCase]]
[[PrivToPrivCase]]
id
=
"failpriv2priv1"
id
=
"failpriv2priv1"
command
=
"
privacy priv2priv -a 100 -f 17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT -p 0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb
"
command
=
"
send privacy priv2priv -a 100 -f 17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT -p 0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb -k 17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT
"
from
=
"17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT"
from
=
"17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount
=
"100"
amount
=
"100"
...
@@ -161,7 +161,7 @@ fail = true
...
@@ -161,7 +161,7 @@ fail = true
[[PrivToPrivCase]]
[[PrivToPrivCase]]
id
=
"failpriv2priv2"
id
=
"failpriv2priv2"
command
=
"
privacy priv2priv -a 51 -f 1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt -p 0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb
"
command
=
"
send privacy priv2priv -a 51 -f 1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt -p 0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb -k 1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt
"
from
=
"1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt"
from
=
"1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount
=
"51"
amount
=
"51"
...
@@ -174,7 +174,7 @@ fail = true
...
@@ -174,7 +174,7 @@ fail = true
[[PrivToPubCase]]
[[PrivToPubCase]]
id
=
"priv2pub1"
id
=
"priv2pub1"
command
=
"
privacy priv2pub -a 48 -f 17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
"
command
=
"
send privacy priv2pub -a 48 -f 17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -k 17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT
"
from
=
"17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT"
from
=
"17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount
=
"48"
amount
=
"48"
...
@@ -184,7 +184,7 @@ dep = ["priv2priv1"]
...
@@ -184,7 +184,7 @@ dep = ["priv2priv1"]
[[PrivToPubCase]]
[[PrivToPubCase]]
id
=
"priv2pub2"
id
=
"priv2pub2"
command
=
"
privacy priv2pub -a 48 -f 1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
"
command
=
"
send privacy priv2pub -a 48 -f 1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -k 1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt
"
from
=
"1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt"
from
=
"1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount
=
"48"
amount
=
"48"
...
@@ -194,7 +194,7 @@ dep = ["priv2priv2"]
...
@@ -194,7 +194,7 @@ dep = ["priv2priv2"]
[[PrivToPubCase]]
[[PrivToPubCase]]
id
=
"priv2pub3"
id
=
"priv2pub3"
command
=
"
privacy priv2pub -a 69 -f 12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
"
command
=
"
send privacy priv2pub -a 69 -f 12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -k 12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d
"
from
=
"12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d"
from
=
"12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount
=
"69"
amount
=
"69"
...
@@ -206,7 +206,7 @@ dep = ["priv2priv3"]
...
@@ -206,7 +206,7 @@ dep = ["priv2priv3"]
[[PrivToPubCase]]
[[PrivToPubCase]]
id
=
"failpriv2pub1"
id
=
"failpriv2pub1"
command
=
"
privacy priv2pub -a 100 -f 17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
"
command
=
"
send privacy priv2pub -a 100 -f 17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -k 17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT
"
from
=
"17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT"
from
=
"17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount
=
"100"
amount
=
"100"
...
@@ -217,7 +217,7 @@ fail = true
...
@@ -217,7 +217,7 @@ fail = true
[[PrivToPubCase]]
[[PrivToPubCase]]
id
=
"failpriv2pub2"
id
=
"failpriv2pub2"
command
=
"
privacy priv2pub -a 3 -f 1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
"
command
=
"
send privacy priv2pub -a 3 -f 1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -k 1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt
"
from
=
"1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt"
from
=
"1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount
=
"3"
amount
=
"3"
...
...
plugin/dapp/privacy/commands/privacy.go
View file @
8c429796
...
@@ -36,9 +36,9 @@ func PrivacyCmd() *cobra.Command {
...
@@ -36,9 +36,9 @@ func PrivacyCmd() *cobra.Command {
cmd
.
AddCommand
(
cmd
.
AddCommand
(
showPrivacyKeyCmd
(),
showPrivacyKeyCmd
(),
showPrivacyAccountSpendCmd
(),
showPrivacyAccountSpendCmd
(),
public2Privacy
Cmd
(),
createPub2PrivTx
Cmd
(),
privacy2Privacy
Cmd
(),
createPriv2PrivTx
Cmd
(),
privacy2Public
Cmd
(),
createPriv2PubTx
Cmd
(),
showAmountsOfUTXOCmd
(),
showAmountsOfUTXOCmd
(),
showUTXOs4SpecifiedAmountCmd
(),
showUTXOs4SpecifiedAmountCmd
(),
createUTXOsCmd
(),
createUTXOsCmd
(),
...
@@ -79,38 +79,34 @@ func showPrivacyKey(cmd *cobra.Command, args []string) {
...
@@ -79,38 +79,34 @@ func showPrivacyKey(cmd *cobra.Command, args []string) {
ctx
.
Run
()
ctx
.
Run
()
}
}
//
public2PrivacyCmd public address to privacy address
//
CreatePub2PrivTxCmd create a public to privacy transaction
func
public2Privacy
Cmd
()
*
cobra
.
Command
{
func
createPub2PrivTx
Cmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"pub2priv"
,
Use
:
"pub2priv"
,
Short
:
"
Public to privacy from pubkeypair amout note
"
,
Short
:
"
Create a public to privacy transaction
"
,
Run
:
public2Privacy
,
Run
:
createPub2PrivTx
,
}
}
public2PrivacyFlag
(
cmd
)
createPub2PrivTxFlags
(
cmd
)
return
cmd
return
cmd
}
}
func
public2PrivacyFlag
(
cmd
*
cobra
.
Command
)
{
func
createPub2PrivTxFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"from"
,
"f"
,
""
,
"from account address"
)
cmd
.
Flags
()
.
StringP
(
"pubkeypair"
,
"p"
,
""
,
"public key pair"
)
cmd
.
MarkFlagRequired
(
"from"
)
cmd
.
Flags
()
.
StringP
(
"pubkeypair"
,
"p"
,
""
,
"to view spend public key pair"
)
cmd
.
MarkFlagRequired
(
"pubkeypair"
)
cmd
.
MarkFlagRequired
(
"pubkeypair"
)
cmd
.
Flags
()
.
Float64P
(
"amount"
,
"a"
,
0.0
,
"transfer amount, at most 4 decimal places"
)
cmd
.
Flags
()
.
Float64P
(
"amount"
,
"a"
,
0
,
"transfer amount"
)
cmd
.
MarkFlagRequired
(
"amount"
)
cmd
.
MarkFlagRequired
(
"amount"
)
cmd
.
Flags
()
.
StringP
(
"note"
,
"n"
,
""
,
"transfer note"
)
cmd
.
Flags
()
.
StringP
(
"symbol"
,
"s"
,
"BTY"
,
"token symbol"
)
cmd
.
Flags
()
.
StringP
(
"note"
,
"n"
,
""
,
"note for transaction"
)
cmd
.
Flags
()
.
Int64P
(
"expire"
,
""
,
0
,
"transfer expire, default one hour"
)
cmd
.
Flags
()
.
Int64P
(
"expire"
,
""
,
0
,
"transfer expire, default one hour"
)
cmd
.
Flags
()
.
IntP
(
"expiretype"
,
""
,
1
,
"0: height 1: time default is 1"
)
cmd
.
Flags
()
.
IntP
(
"expiretype"
,
""
,
1
,
"0: height 1: time default is 1"
)
}
}
func
public2Privacy
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
createPub2PrivTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
from
,
_
:=
cmd
.
Flags
()
.
GetString
(
"from"
)
pubkeypair
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkeypair"
)
pubkeypair
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkeypair"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
amount
:=
cmdtypes
.
GetAmountValue
(
cmd
,
"amount"
)
tokenname
,
_
:=
cmd
.
Flags
()
.
GetString
(
"symbol"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
expire
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"expire"
)
expire
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"expire"
)
expiretype
,
_
:=
cmd
.
Flags
()
.
GetInt
(
"expiretype"
)
expiretype
,
_
:=
cmd
.
Flags
()
.
GetInt
(
"expiretype"
)
...
@@ -121,62 +117,59 @@ func public2Privacy(cmd *cobra.Command, args []string) {
...
@@ -121,62 +117,59 @@ func public2Privacy(cmd *cobra.Command, args []string) {
}
}
}
else
if
expiretype
==
1
{
}
else
if
expiretype
==
1
{
if
expire
<=
0
{
if
expire
<=
0
{
expire
=
int64
(
time
.
Hour
)
expire
=
int64
(
time
.
Hour
/
time
.
Second
)
}
}
}
else
{
}
else
{
fmt
.
Println
(
"Invalid expiretype"
,
expiretype
)
fmt
.
Println
(
"Invalid expiretype"
,
expiretype
)
return
return
}
}
amountInt64
:=
int64
(
amount
*
types
.
InputPrecision
)
*
types
.
Multiple1E4
//支持4位小数输入,多余的输入将被截断
params
:=
types
.
ReqCreateTransaction
{
params
:=
pty
.
ReqPub2Pri
{
Tokenname
:
tokenname
,
Sender
:
from
,
Type
:
types
.
PrivacyTypePublic2Privacy
,
Pubkeypair
:
pubkeypair
,
Amount
:
amount
,
Amount
:
amountInt64
,
Note
:
note
,
Note
:
note
,
Tokenname
:
types
.
BTY
,
Pubkeypair
:
pubkeypair
,
Expire
:
expire
,
Expire
:
expire
,
}
}
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"privacy.CreateRawTransaction"
,
params
,
nil
)
var
res
rpctypes
.
ReplyHash
ctx
.
RunWithoutMarshal
()
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"privacy.MakeTxPublic2privacy"
,
params
,
&
res
)
ctx
.
Run
()
}
}
//
privacy address to privacy address
//
CreatePriv2PrivTxCmd create a privacy to privacy transaction
func
privacy2Privacy
Cmd
()
*
cobra
.
Command
{
func
createPriv2PrivTx
Cmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"priv2priv"
,
Use
:
"priv2priv"
,
Short
:
"
Privacy to privacy from toviewpubkey tospendpubkey amout note
"
,
Short
:
"
Create a privacy to privacy transaction
"
,
Run
:
privacy2Privacy
,
Run
:
createPriv2PrivTx
,
}
}
privacy2PrivacyFlag
(
cmd
)
createPriv2PrivTxFlags
(
cmd
)
return
cmd
return
cmd
}
}
func
privacy2PrivacyFlag
(
cmd
*
cobra
.
Command
)
{
func
createPriv2PrivTxFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"from"
,
"f"
,
""
,
"from account address"
)
cmd
.
Flags
()
.
StringP
(
"pubkeypair"
,
"p"
,
""
,
"public key pair"
)
cmd
.
MarkFlagRequired
(
"from"
)
cmd
.
Flags
()
.
StringP
(
"pubkeypair"
,
"p"
,
""
,
"to view spend public key pair"
)
cmd
.
MarkFlagRequired
(
"pubkeypair"
)
cmd
.
MarkFlagRequired
(
"pubkeypair"
)
cmd
.
Flags
()
.
Float64P
(
"amount"
,
"a"
,
0.0
,
"transfer amount, at most 4 decimal places"
)
cmd
.
Flags
()
.
Float64P
(
"amount"
,
"a"
,
0.0
,
"transfer amount"
)
cmd
.
MarkFlagRequired
(
"amount"
)
cmd
.
MarkFlagRequired
(
"amount"
)
cmd
.
Flags
()
.
StringP
(
"from"
,
"f"
,
""
,
"from address"
)
cmd
.
MarkFlagRequired
(
"from"
)
cmd
.
Flags
()
.
StringP
(
"note"
,
"n"
,
""
,
"transfer note"
)
cmd
.
Flags
()
.
Int32P
(
"mixcount"
,
"m"
,
defMixCount
,
"utxo mix count"
)
cmd
.
Flags
()
.
Int32P
(
"mixcount"
,
"m"
,
defMixCount
,
"transfer note"
)
cmd
.
Flags
()
.
StringP
(
"symbol"
,
"s"
,
"BTY"
,
"token symbol"
)
cmd
.
Flags
()
.
StringP
(
"note"
,
"n"
,
""
,
"note for transaction"
)
cmd
.
Flags
()
.
Int64P
(
"expire"
,
""
,
0
,
"transfer expire, default one hour"
)
cmd
.
Flags
()
.
Int64P
(
"expire"
,
""
,
0
,
"transfer expire, default one hour"
)
cmd
.
Flags
()
.
IntP
(
"expiretype"
,
""
,
1
,
"0: height 1: time default is 1"
)
cmd
.
Flags
()
.
IntP
(
"expiretype"
,
""
,
1
,
"0: height 1: time default is 1"
)
}
}
func
privacy2Privacy
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
createPriv2PrivTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
from
,
_
:=
cmd
.
Flags
()
.
GetString
(
"from"
)
pubkeypair
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkeypair"
)
pubkeypair
,
_
:=
cmd
.
Flags
()
.
GetString
(
"pubkeypair"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
amount
:=
cmdtypes
.
GetAmountValue
(
cmd
,
"amount"
)
mixcount
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"mixcount"
)
mixCount
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"mixcount"
)
tokenname
,
_
:=
cmd
.
Flags
()
.
GetString
(
"symbol"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
sender
,
_
:=
cmd
.
Flags
()
.
GetString
(
"from"
)
expire
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"expire"
)
expire
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"expire"
)
expiretype
,
_
:=
cmd
.
Flags
()
.
GetInt
(
"expiretype"
)
expiretype
,
_
:=
cmd
.
Flags
()
.
GetInt
(
"expiretype"
)
if
expiretype
==
0
{
if
expiretype
==
0
{
...
@@ -186,63 +179,60 @@ func privacy2Privacy(cmd *cobra.Command, args []string) {
...
@@ -186,63 +179,60 @@ func privacy2Privacy(cmd *cobra.Command, args []string) {
}
}
}
else
if
expiretype
==
1
{
}
else
if
expiretype
==
1
{
if
expire
<=
0
{
if
expire
<=
0
{
expire
=
int64
(
time
.
Hour
)
expire
=
int64
(
time
.
Hour
/
time
.
Second
)
}
}
}
else
{
}
else
{
fmt
.
Println
(
"Invalid expiretype"
,
expiretype
)
fmt
.
Println
(
"Invalid expiretype"
,
expiretype
)
return
return
}
}
amountInt64
:=
int64
(
amount
*
types
.
InputPrecision
)
*
types
.
Multiple1E4
//支持4位小数输入,多余的输入将被截断
params
:=
types
.
ReqCreateTransaction
{
params
:=
pty
.
ReqPri2Pri
{
Tokenname
:
tokenname
,
Sender
:
from
,
Type
:
types
.
PrivacyTypePrivacy2Privacy
,
Pubkeypair
:
pubkeypair
,
Amount
:
amount
,
Amount
:
amountInt64
,
Mixin
:
mixcount
,
Note
:
note
,
Note
:
note
,
Tokenname
:
types
.
BTY
,
Pubkeypair
:
pubkeypair
,
From
:
sender
,
Mixcount
:
mixCount
,
Expire
:
expire
,
Expire
:
expire
,
}
}
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"privacy.CreateRawTransaction"
,
params
,
nil
)
var
res
rpctypes
.
ReplyHash
ctx
.
RunWithoutMarshal
()
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"privacy.MakeTxPrivacy2privacy"
,
params
,
&
res
)
ctx
.
Run
()
}
}
//
privacy address to public address
//
CreatePriv2PubTxCmd create a privacy to public transaction
func
privacy2Public
Cmd
()
*
cobra
.
Command
{
func
createPriv2PubTx
Cmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"priv2pub"
,
Use
:
"priv2pub"
,
Short
:
"
Public to privacy from toviewpubkey tospendpubkey amout note
"
,
Short
:
"
Create a privacy to public transaction
"
,
Run
:
privacy2Public
,
Run
:
createPriv2PubTx
,
}
}
privacy2Publiclag
(
cmd
)
createPriv2PubTxFlags
(
cmd
)
return
cmd
return
cmd
}
}
func
privacy2Publiclag
(
cmd
*
cobra
.
Command
)
{
func
createPriv2PubTxFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"from"
,
"f"
,
""
,
"from account address"
)
cmd
.
Flags
()
.
Float64P
(
"amount"
,
"a"
,
0.0
,
"transfer amount, at most 4 decimal places"
)
cmd
.
MarkFlagRequired
(
"amount"
)
cmd
.
Flags
()
.
StringP
(
"from"
,
"f"
,
""
,
"from address"
)
cmd
.
MarkFlagRequired
(
"from"
)
cmd
.
MarkFlagRequired
(
"from"
)
cmd
.
Flags
()
.
StringP
(
"to"
,
"t"
,
""
,
"to address"
)
cmd
.
Flags
()
.
StringP
(
"to"
,
"t"
,
""
,
"to account address"
)
cmd
.
MarkFlagRequired
(
"to"
)
cmd
.
MarkFlagRequired
(
"to"
)
cmd
.
Flags
()
.
Float64P
(
"amount"
,
"a"
,
0.0
,
"transfer amount"
)
cmd
.
Flags
()
.
Int32P
(
"mixcount"
,
"m"
,
defMixCount
,
"utxo mix count"
)
cmd
.
MarkFlagRequired
(
"amount"
)
cmd
.
Flags
()
.
StringP
(
"symbol"
,
"s"
,
"BTY"
,
"token symbol"
)
cmd
.
Flags
()
.
StringP
(
"note"
,
"n"
,
""
,
"note for transaction"
)
cmd
.
Flags
()
.
StringP
(
"note"
,
"n"
,
""
,
"transfer note"
)
cmd
.
Flags
()
.
Int32P
(
"mixcount"
,
"m"
,
defMixCount
,
"transfer note"
)
cmd
.
Flags
()
.
Int64P
(
"expire"
,
""
,
0
,
"transfer expire, default one hour"
)
cmd
.
Flags
()
.
Int64P
(
"expire"
,
""
,
0
,
"transfer expire, default one hour"
)
cmd
.
Flags
()
.
IntP
(
"expiretype"
,
""
,
1
,
"0: height 1: time default is 1"
)
cmd
.
Flags
()
.
IntP
(
"expiretype"
,
""
,
1
,
"0: height 1: time default is 1"
)
}
}
func
privacy2Public
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
createPriv2PubTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
amount
:=
cmdtypes
.
GetAmountValue
(
cmd
,
"amount"
)
mixCount
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"mixcount"
)
tokenname
,
_
:=
cmd
.
Flags
()
.
GetString
(
"symbol"
)
from
,
_
:=
cmd
.
Flags
()
.
GetString
(
"from"
)
from
,
_
:=
cmd
.
Flags
()
.
GetString
(
"from"
)
to
,
_
:=
cmd
.
Flags
()
.
GetString
(
"to"
)
to
,
_
:=
cmd
.
Flags
()
.
GetString
(
"to"
)
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
mixcount
,
_
:=
cmd
.
Flags
()
.
GetInt32
(
"mixcount"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
note
,
_
:=
cmd
.
Flags
()
.
GetString
(
"note"
)
expire
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"expire"
)
expire
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"expire"
)
expiretype
,
_
:=
cmd
.
Flags
()
.
GetInt
(
"expiretype"
)
expiretype
,
_
:=
cmd
.
Flags
()
.
GetInt
(
"expiretype"
)
...
@@ -253,27 +243,25 @@ func privacy2Public(cmd *cobra.Command, args []string) {
...
@@ -253,27 +243,25 @@ func privacy2Public(cmd *cobra.Command, args []string) {
}
}
}
else
if
expiretype
==
1
{
}
else
if
expiretype
==
1
{
if
expire
<=
0
{
if
expire
<=
0
{
expire
=
int64
(
time
.
Hour
)
expire
=
int64
(
time
.
Hour
/
time
.
Second
)
}
}
}
else
{
}
else
{
fmt
.
Println
(
"Invalid expiretype"
,
expiretype
)
fmt
.
Println
(
"Invalid expiretype"
,
expiretype
)
return
return
}
}
amountInt64
:=
int64
(
amount
*
types
.
InputPrecision
)
*
types
.
Multiple1E4
//支持4位小数输入,多余的输入将被截断
params
:=
types
.
ReqCreateTransaction
{
params
:=
pty
.
ReqPri2Pub
{
Tokenname
:
tokenname
,
Sender
:
from
,
Type
:
types
.
PrivacyTypePrivacy2Public
,
Receiver
:
to
,
Amount
:
amount
,
Amount
:
amountInt64
,
Note
:
note
,
Note
:
note
,
Tokenname
:
types
.
BTY
,
From
:
from
,
Mixin
:
mixcount
,
To
:
to
,
Mixcount
:
mixCount
,
Expire
:
expire
,
Expire
:
expire
,
}
}
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"privacy.CreateRawTransaction"
,
params
,
nil
)
var
res
rpctypes
.
ReplyHash
ctx
.
RunWithoutMarshal
()
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"privacy.MakeTxPrivacy2public"
,
params
,
&
res
)
ctx
.
Run
()
}
}
func
showPrivacyAccountSpendCmd
()
*
cobra
.
Command
{
func
showPrivacyAccountSpendCmd
()
*
cobra
.
Command
{
...
...
plugin/dapp/privacy/crypto/ring_signature_crypto.go
View file @
8c429796
...
@@ -22,6 +22,7 @@ import (
...
@@ -22,6 +22,7 @@ import (
func
init
()
{
func
init
()
{
crypto
.
Register
(
privacytypes
.
SignNameRing
,
&
RingSignED25519
{})
crypto
.
Register
(
privacytypes
.
SignNameRing
,
&
RingSignED25519
{})
crypto
.
RegisterType
(
privacytypes
.
SignNameRing
,
privacytypes
.
RingBaseonED25519
)
}
}
// RingSignature 环签名中对于crypto.Signature接口实现
// RingSignature 环签名中对于crypto.Signature接口实现
...
@@ -156,7 +157,7 @@ func (pubkey *RingSignPublicKey) VerifyBytes(msg []byte, sign crypto.Signature)
...
@@ -156,7 +157,7 @@ func (pubkey *RingSignPublicKey) VerifyBytes(msg []byte, sign crypto.Signature)
return
false
return
false
}
}
tx
:=
new
(
types
.
Transaction
)
tx
:=
new
(
types
.
Transaction
)
if
err
:=
types
.
Decode
(
msg
,
tx
);
err
!=
nil
||
!
bytes
.
Equal
([]
byte
(
privacytypes
.
PrivacyX
),
t
x
.
Execer
)
{
if
err
:=
types
.
Decode
(
msg
,
tx
);
err
!=
nil
||
!
bytes
.
Equal
([]
byte
(
privacytypes
.
PrivacyX
),
t
ypes
.
GetRealExecName
(
tx
.
Execer
)
)
{
// 目前只有隐私交易用到了环签名
// 目前只有隐私交易用到了环签名
return
false
return
false
}
}
...
...
plugin/dapp/privacy/executor/exec.go
View file @
8c429796
...
@@ -102,7 +102,7 @@ func (p *privacy) Exec_Privacy2Public(payload *ty.Privacy2Public, tx *types.Tran
...
@@ -102,7 +102,7 @@ func (p *privacy) Exec_Privacy2Public(payload *ty.Privacy2Public, tx *types.Tran
}
}
txhashstr
:=
hex
.
EncodeToString
(
tx
.
Hash
())
txhashstr
:=
hex
.
EncodeToString
(
tx
.
Hash
())
coinsAccount
:=
p
.
GetCoinsAccount
()
coinsAccount
:=
p
.
GetCoinsAccount
()
receipt
,
err
:=
coinsAccount
.
ExecDeposit
(
tx
.
To
,
address
.
ExecAddress
(
string
(
tx
.
Execer
)),
payload
.
Amount
)
receipt
,
err
:=
coinsAccount
.
ExecDeposit
(
payload
.
To
,
address
.
ExecAddress
(
string
(
tx
.
Execer
)),
payload
.
Amount
)
if
err
!=
nil
{
if
err
!=
nil
{
privacylog
.
Error
(
"PrivacyTrading Exec"
,
"ActionPrivacy2Public txhash"
,
txhashstr
,
"ExecDeposit error "
,
err
)
privacylog
.
Error
(
"PrivacyTrading Exec"
,
"ActionPrivacy2Public txhash"
,
txhashstr
,
"ExecDeposit error "
,
err
)
return
nil
,
err
return
nil
,
err
...
...
plugin/dapp/privacy/executor/privacy.go
View file @
8c429796
...
@@ -273,16 +273,20 @@ func (p *privacy) CheckTx(tx *types.Transaction, index int) error {
...
@@ -273,16 +273,20 @@ func (p *privacy) CheckTx(tx *types.Transaction, index int) error {
totalOutput
+=
output
.
Amount
totalOutput
+=
output
.
Amount
}
}
var
feeAmount
int64
//平行链下的隐私交易,utxo不需要燃烧,fee只收取主链的bty,和utxo无关联
if
action
.
Ty
==
pty
.
ActionPrivacy2Privacy
{
if
!
types
.
IsPara
()
{
feeAmount
=
totalInput
-
totalOutput
}
else
{
var
feeAmount
int64
feeAmount
=
totalInput
-
totalOutput
-
amount
if
action
.
Ty
==
pty
.
ActionPrivacy2Privacy
{
}
feeAmount
=
totalInput
-
totalOutput
}
else
{
feeAmount
=
totalInput
-
totalOutput
-
amount
}
if
feeAmount
<
pty
.
PrivacyTxFee
{
if
feeAmount
<
pty
.
PrivacyTxFee
{
privacylog
.
Error
(
"PrivacyTrading CheckTx"
,
"txhash"
,
txhashstr
,
"fee available:"
,
feeAmount
,
"required:"
,
pty
.
PrivacyTxFee
)
privacylog
.
Error
(
"PrivacyTrading CheckTx"
,
"txhash"
,
txhashstr
,
"fee available:"
,
feeAmount
,
"required:"
,
pty
.
PrivacyTxFee
)
return
pty
.
ErrPrivacyTxFeeNotEnough
return
pty
.
ErrPrivacyTxFeeNotEnough
}
}
}
return
nil
return
nil
}
}
...
...
plugin/dapp/privacy/proto/privacy.proto
View file @
8c429796
...
@@ -38,6 +38,7 @@ message Privacy2Public {
...
@@ -38,6 +38,7 @@ message Privacy2Public {
string
tokenname
=
1
;
string
tokenname
=
1
;
int64
amount
=
2
;
int64
amount
=
2
;
string
note
=
3
;
string
note
=
3
;
string
to
=
6
;
PrivacyInput
input
=
4
;
PrivacyInput
input
=
4
;
PrivacyOutput
output
=
5
;
PrivacyOutput
output
=
5
;
}
}
...
@@ -193,49 +194,6 @@ message PrivacyAction4Print {
...
@@ -193,49 +194,6 @@ message PrivacyAction4Print {
int32
ty
=
4
;
int32
ty
=
4
;
}
}
message
ReqPub2Pri
{
//接收人可见公钥A
// string viewPublic = 1;
//接收人花费公钥B
// string spendPublic = 2;
string
tokenname
=
3
;
int64
amount
=
4
;
string
note
=
5
;
//发送人地址
string
sender
=
6
;
int32
mixin
=
7
;
string
pubkeypair
=
8
;
int64
expire
=
9
;
}
message
ReqPri2Pri
{
//接收人可见公钥A
// string viewPublic = 1; //A
//接收人花费公钥B
// string spendPublic = 2; //B
string
tokenname
=
3
;
int64
amount
=
4
;
string
note
=
5
;
//隐私交易发起人地址
string
sender
=
6
;
int32
mixin
=
7
;
// string txhash = 7;
string
pubkeypair
=
8
;
int64
expire
=
9
;
}
message
ReqPri2Pub
{
string
receiver
=
1
;
string
tokenname
=
2
;
int64
amount
=
3
;
string
note
=
4
;
//隐私交易发起人地址
string
sender
=
5
;
int32
mixin
=
6
;
// string txhash = 6;
int64
expire
=
7
;
}
message
ReqCreateUTXOs
{
message
ReqCreateUTXOs
{
// string viewPublic = 1; //接收人可见公钥A
// string viewPublic = 1; //接收人可见公钥A
// string spendPublic = 2; //接收人花费公钥B
// string spendPublic = 2; //接收人花费公钥B
...
@@ -456,12 +414,6 @@ service privacy {
...
@@ -456,12 +414,6 @@ service privacy {
rpc
ShowPrivacyKey
(
ReqString
)
returns
(
ReplyPrivacyPkPair
)
{}
rpc
ShowPrivacyKey
(
ReqString
)
returns
(
ReplyPrivacyPkPair
)
{}
// 创建一系列UTXO
// 创建一系列UTXO
rpc
CreateUTXOs
(
ReqCreateUTXOs
)
returns
(
Reply
)
{}
rpc
CreateUTXOs
(
ReqCreateUTXOs
)
returns
(
Reply
)
{}
// 将资金从公开到隐私转移
rpc
MakeTxPublic2Privacy
(
ReqPub2Pri
)
returns
(
Reply
)
{}
// 将资产从隐私到隐私进行转移
rpc
MakeTxPrivacy2Privacy
(
ReqPri2Pri
)
returns
(
Reply
)
{}
// 将资产从隐私到公开进行转移
rpc
MakeTxPrivacy2Public
(
ReqPri2Pub
)
returns
(
Reply
)
{}
// 扫描UTXO以及获取扫描UTXO后的状态
// 扫描UTXO以及获取扫描UTXO后的状态
rpc
RescanUtxos
(
ReqRescanUtxos
)
returns
(
RepRescanUtxos
)
{}
rpc
RescanUtxos
(
ReqRescanUtxos
)
returns
(
RepRescanUtxos
)
{}
// 使能隐私账户
// 使能隐私账户
...
...
plugin/dapp/privacy/rpc/rpc.go
View file @
8c429796
...
@@ -33,33 +33,6 @@ func (g *channelClient) CreateUTXOs(ctx context.Context, in *pty.ReqCreateUTXOs)
...
@@ -33,33 +33,6 @@ func (g *channelClient) CreateUTXOs(ctx context.Context, in *pty.ReqCreateUTXOs)
return
data
.
(
*
types
.
Reply
),
nil
return
data
.
(
*
types
.
Reply
),
nil
}
}
// 将资金从公开到隐私转移
func
(
g
*
channelClient
)
MakeTxPublic2Privacy
(
ctx
context
.
Context
,
in
*
pty
.
ReqPub2Pri
)
(
*
types
.
Reply
,
error
)
{
data
,
err
:=
g
.
ExecWalletFunc
(
pty
.
PrivacyX
,
"Public2Privacy"
,
in
)
if
err
!=
nil
{
return
nil
,
err
}
return
data
.
(
*
types
.
Reply
),
nil
}
// 将资产从隐私到隐私进行转移
func
(
g
*
channelClient
)
MakeTxPrivacy2Privacy
(
ctx
context
.
Context
,
in
*
pty
.
ReqPri2Pri
)
(
*
types
.
Reply
,
error
)
{
data
,
err
:=
g
.
ExecWalletFunc
(
pty
.
PrivacyX
,
"Privacy2Privacy"
,
in
)
if
err
!=
nil
{
return
nil
,
err
}
return
data
.
(
*
types
.
Reply
),
nil
}
// 将资产从隐私到公开进行转移
func
(
g
*
channelClient
)
MakeTxPrivacy2Public
(
ctx
context
.
Context
,
in
*
pty
.
ReqPri2Pub
)
(
*
types
.
Reply
,
error
)
{
data
,
err
:=
g
.
ExecWalletFunc
(
pty
.
PrivacyX
,
"Privacy2Public"
,
in
)
if
err
!=
nil
{
return
nil
,
err
}
return
data
.
(
*
types
.
Reply
),
nil
}
// 扫描UTXO以及获取扫描UTXO后的状态
// 扫描UTXO以及获取扫描UTXO后的状态
func
(
g
*
channelClient
)
RescanUtxos
(
ctx
context
.
Context
,
in
*
pty
.
ReqRescanUtxos
)
(
*
pty
.
RepRescanUtxos
,
error
)
{
func
(
g
*
channelClient
)
RescanUtxos
(
ctx
context
.
Context
,
in
*
pty
.
ReqRescanUtxos
)
(
*
pty
.
RepRescanUtxos
,
error
)
{
data
,
err
:=
g
.
ExecWalletFunc
(
pty
.
PrivacyX
,
"RescanUtxos"
,
in
)
data
,
err
:=
g
.
ExecWalletFunc
(
pty
.
PrivacyX
,
"RescanUtxos"
,
in
)
...
@@ -122,41 +95,6 @@ func (c *Jrpc) ShowPrivacykey(in *types.ReqString, result *json.RawMessage) erro
...
@@ -122,41 +95,6 @@ func (c *Jrpc) ShowPrivacykey(in *types.ReqString, result *json.RawMessage) erro
return
err
return
err
}
}
// MakeTxPublic2privacy create public to privacy trasaction for json rpc
func
(
c
*
Jrpc
)
MakeTxPublic2privacy
(
in
*
pty
.
ReqPub2Pri
,
result
*
interface
{})
error
{
reply
,
err
:=
c
.
cli
.
MakeTxPublic2Privacy
(
context
.
Background
(),
in
)
if
err
!=
nil
{
return
err
}
*
result
=
rpctypes
.
ReplyHash
{
Hash
:
common
.
ToHex
(
reply
.
GetMsg
())}
return
nil
}
// MakeTxPrivacy2privacy create privacy to privacy transaction
func
(
c
*
Jrpc
)
MakeTxPrivacy2privacy
(
in
*
pty
.
ReqPri2Pri
,
result
*
interface
{})
error
{
reply
,
err
:=
c
.
cli
.
MakeTxPrivacy2Privacy
(
context
.
Background
(),
in
)
if
err
!=
nil
{
return
err
}
*
result
=
rpctypes
.
ReplyHash
{
Hash
:
common
.
ToHex
(
reply
.
GetMsg
())}
return
nil
}
// MakeTxPrivacy2public make privacy to public trasaction
func
(
c
*
Jrpc
)
MakeTxPrivacy2public
(
in
*
pty
.
ReqPri2Pub
,
result
*
interface
{})
error
{
reply
,
err
:=
c
.
cli
.
MakeTxPrivacy2Public
(
context
.
Background
(),
in
)
if
err
!=
nil
{
return
err
}
*
result
=
rpctypes
.
ReplyHash
{
Hash
:
common
.
ToHex
(
reply
.
GetMsg
())}
return
nil
}
// CreateUTXOs create utxos for json rpc
// CreateUTXOs create utxos for json rpc
func
(
c
*
Jrpc
)
CreateUTXOs
(
in
*
pty
.
ReqCreateUTXOs
,
result
*
interface
{})
error
{
func
(
c
*
Jrpc
)
CreateUTXOs
(
in
*
pty
.
ReqCreateUTXOs
,
result
*
interface
{})
error
{
...
...
plugin/dapp/privacy/rpc/rpc_channel_test.go
View file @
8c429796
...
@@ -45,10 +45,6 @@ func TestRPCChannel(t *testing.T) {
...
@@ -45,10 +45,6 @@ func TestRPCChannel(t *testing.T) {
{
fn
:
testShowPrivacyKey
},
{
fn
:
testShowPrivacyKey
},
{
fn
:
testShowPrivacyAccountInfo
},
{
fn
:
testShowPrivacyAccountInfo
},
{
fn
:
testShowPrivacyAccountSpend
},
{
fn
:
testShowPrivacyAccountSpend
},
{
fn
:
testPublic2Privacy
},
{
fn
:
testPrivacy2Privacy
},
{
fn
:
testPrivacy2Public
},
{
fn
:
testPrivacy2Public
},
{
fn
:
testShowAmountsOfUTXO
},
{
fn
:
testShowAmountsOfUTXO
},
{
fn
:
testShowUTXOs4SpecifiedAmount
},
{
fn
:
testShowUTXOs4SpecifiedAmount
},
{
fn
:
testCreateUTXOs
},
{
fn
:
testCreateUTXOs
},
...
@@ -98,51 +94,6 @@ func testShowPrivacyAccountSpend(t *testing.T, jrpc *jsonclient.JSONClient) erro
...
@@ -98,51 +94,6 @@ func testShowPrivacyAccountSpend(t *testing.T, jrpc *jsonclient.JSONClient) erro
return
err
return
err
}
}
func
testPublic2Privacy
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
params
:=
pty
.
ReqPub2Pri
{
Sender
:
"13cS5G1BDN2YfGudsxRxr7X25yu6ZdgxMU"
,
Pubkeypair
:
"92fe6cfec2e19cd15f203f83b5d440ddb63d0cb71559f96dc81208d819fea85886b08f6e874fca15108d244b40f9086d8c03260d4b954a40dfb3cbe41ebc7389"
,
Amount
:
1234
,
Note
:
"for test"
,
Tokenname
:
types
.
BTY
,
Expire
:
int64
(
time
.
Hour
),
}
var
res
rpctypes
.
ReplyHash
err
:=
jrpc
.
Call
(
"privacy.MakeTxPublic2privacy"
,
params
,
&
res
)
return
err
}
func
testPrivacy2Privacy
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
params
:=
pty
.
ReqPri2Pri
{
Sender
:
"13cS5G1BDN2YfGudsxRxr7X25yu6ZdgxMU"
,
Pubkeypair
:
"92fe6cfec2e19cd15f203f83b5d440ddb63d0cb71559f96dc81208d819fea85886b08f6e874fca15108d244b40f9086d8c03260d4b954a40dfb3cbe41ebc7389"
,
Amount
:
234567
,
Mixin
:
16
,
Note
:
"for test"
,
Tokenname
:
types
.
BTY
,
Expire
:
int64
(
time
.
Hour
),
}
var
res
rpctypes
.
ReplyHash
err
:=
jrpc
.
Call
(
"privacy.MakeTxPrivacy2privacy"
,
params
,
&
res
)
return
err
}
func
testPrivacy2Public
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
params
:=
pty
.
ReqPri2Pub
{
Sender
:
"13cS5G1BDN2YfGudsxRxr7X25yu6ZdgxMU"
,
Receiver
:
"1EDDghAtgBsamrNEtNmYdQzC1QEhLkr87t"
,
Amount
:
123456
,
Note
:
"for test"
,
Tokenname
:
types
.
BTY
,
Mixin
:
16
,
Expire
:
int64
(
time
.
Hour
),
}
var
res
rpctypes
.
ReplyHash
err
:=
jrpc
.
Call
(
"privacy.MakeTxPrivacy2public"
,
params
,
&
res
)
return
err
}
func
testShowAmountsOfUTXO
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
func
testShowAmountsOfUTXO
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
reqPrivacyToken
:=
pty
.
ReqPrivacyToken
{
Token
:
types
.
BTY
}
reqPrivacyToken
:=
pty
.
ReqPrivacyToken
{
Token
:
types
.
BTY
}
var
params
rpctypes
.
Query4Jrpc
var
params
rpctypes
.
Query4Jrpc
...
...
plugin/dapp/privacy/types/privacy.pb.go
View file @
8c429796
This diff is collapsed.
Click to expand it.
plugin/dapp/privacy/wallet/exec.go
View file @
8c429796
...
@@ -29,36 +29,6 @@ func (policy *privacyPolicy) On_ShowPrivacyKey(req *types.ReqString) (types.Mess
...
@@ -29,36 +29,6 @@ func (policy *privacyPolicy) On_ShowPrivacyKey(req *types.ReqString) (types.Mess
return
reply
,
err
return
reply
,
err
}
}
func
(
policy
*
privacyPolicy
)
On_Public2Privacy
(
req
*
privacytypes
.
ReqPub2Pri
)
(
types
.
Message
,
error
)
{
policy
.
getWalletOperate
()
.
GetMutex
()
.
Lock
()
defer
policy
.
getWalletOperate
()
.
GetMutex
()
.
Unlock
()
reply
,
err
:=
policy
.
sendPublic2PrivacyTransaction
(
req
)
if
err
!=
nil
{
bizlog
.
Error
(
"sendPublic2PrivacyTransaction"
,
"err"
,
err
.
Error
())
}
return
reply
,
err
}
func
(
policy
*
privacyPolicy
)
On_Privacy2Privacy
(
req
*
privacytypes
.
ReqPri2Pri
)
(
types
.
Message
,
error
)
{
policy
.
getWalletOperate
()
.
GetMutex
()
.
Lock
()
defer
policy
.
getWalletOperate
()
.
GetMutex
()
.
Unlock
()
reply
,
err
:=
policy
.
sendPrivacy2PrivacyTransaction
(
req
)
if
err
!=
nil
{
bizlog
.
Error
(
"sendPrivacy2PrivacyTransaction"
,
"err"
,
err
.
Error
())
}
return
reply
,
err
}
func
(
policy
*
privacyPolicy
)
On_Privacy2Public
(
req
*
privacytypes
.
ReqPri2Pub
)
(
types
.
Message
,
error
)
{
policy
.
getWalletOperate
()
.
GetMutex
()
.
Lock
()
defer
policy
.
getWalletOperate
()
.
GetMutex
()
.
Unlock
()
reply
,
err
:=
policy
.
sendPrivacy2PublicTransaction
(
req
)
if
err
!=
nil
{
bizlog
.
Error
(
"sendPrivacy2PublicTransaction"
,
"err"
,
err
.
Error
())
}
return
reply
,
err
}
func
(
policy
*
privacyPolicy
)
On_CreateUTXOs
(
req
*
privacytypes
.
ReqCreateUTXOs
)
(
types
.
Message
,
error
)
{
func
(
policy
*
privacyPolicy
)
On_CreateUTXOs
(
req
*
privacytypes
.
ReqCreateUTXOs
)
(
types
.
Message
,
error
)
{
policy
.
getWalletOperate
()
.
GetMutex
()
.
Lock
()
policy
.
getWalletOperate
()
.
GetMutex
()
.
Lock
()
defer
policy
.
getWalletOperate
()
.
GetMutex
()
.
Unlock
()
defer
policy
.
getWalletOperate
()
.
GetMutex
()
.
Unlock
()
...
...
plugin/dapp/privacy/wallet/privacy.go
View file @
8c429796
This diff is collapsed.
Click to expand it.
plugin/dapp/privacy/wallet/privacybizpolicy_test.go
View file @
8c429796
...
@@ -360,117 +360,6 @@ func Test_CreateUTXOs(t *testing.T) {
...
@@ -360,117 +360,6 @@ func Test_CreateUTXOs(t *testing.T) {
}
}
}
}
func
Test_SendPublic2PrivacyTransaction
(
t
*
testing
.
T
)
{
mock
:=
&
testDataMock
{
mockMempool
:
true
}
mock
.
init
()
mock
.
enablePrivacy
()
testCases
:=
[]
struct
{
req
*
ty
.
ReqPub2Pri
needReply
*
types
.
Reply
needError
error
}{
{
needError
:
types
.
ErrInvalidParam
,
},
{
req
:
&
ty
.
ReqPub2Pri
{
Tokenname
:
types
.
BTY
,
Amount
:
10
*
types
.
Coin
,
Sender
:
testAddrs
[
0
],
Pubkeypair
:
testPubkeyPairs
[
0
],
},
needReply
:
&
types
.
Reply
{
IsOk
:
true
},
needError
:
types
.
ErrAddrNotExist
,
},
}
for
index
,
testCase
:=
range
testCases
{
_
,
getErr
:=
mock
.
wallet
.
GetAPI
()
.
ExecWalletFunc
(
ty
.
PrivacyX
,
"Public2Privacy"
,
testCase
.
req
)
require
.
Equalf
(
t
,
getErr
,
testCase
.
needError
,
"Publick2Privacy test case index %d"
,
index
)
}
}
func
Test_SendPrivacy2PrivacyTransaction
(
t
*
testing
.
T
)
{
mock
:=
&
testDataMock
{
mockMempool
:
true
,
mockBlockChain
:
true
,
}
mock
.
init
()
mock
.
enablePrivacy
()
// 创建辅助对象
privacyMock
:=
privacy
.
PrivacyMock
{}
privacyMock
.
Init
(
mock
.
wallet
,
mock
.
password
)
// 创建几条可用UTXO
privacyMock
.
CreateUTXOs
(
testAddrs
[
0
],
testPubkeyPairs
[
0
],
17
*
types
.
Coin
,
10000
,
5
)
mock
.
setBlockChainHeight
(
10020
)
testCases
:=
[]
struct
{
req
*
ty
.
ReqPri2Pri
needReply
*
types
.
Reply
needError
error
}{
{
needError
:
types
.
ErrInvalidParam
,
},
{
req
:
&
ty
.
ReqPri2Pri
{
Tokenname
:
types
.
BTY
,
Amount
:
10
*
types
.
Coin
,
Sender
:
testAddrs
[
0
],
Pubkeypair
:
testPubkeyPairs
[
1
],
},
needReply
:
&
types
.
Reply
{
IsOk
:
true
},
needError
:
types
.
ErrAddrNotExist
,
},
}
for
index
,
testCase
:=
range
testCases
{
_
,
getErr
:=
mock
.
wallet
.
GetAPI
()
.
ExecWalletFunc
(
ty
.
PrivacyX
,
"Privacy2Privacy"
,
testCase
.
req
)
require
.
Equalf
(
t
,
getErr
,
testCase
.
needError
,
"Privacy2Privacy test case index %d"
,
index
)
}
}
func
Test_SendPrivacy2PublicTransaction
(
t
*
testing
.
T
)
{
mock
:=
&
testDataMock
{
mockMempool
:
true
,
mockBlockChain
:
true
,
}
mock
.
init
()
mock
.
enablePrivacy
()
// 创建辅助对象
privacyMock
:=
privacy
.
PrivacyMock
{}
privacyMock
.
Init
(
mock
.
wallet
,
mock
.
password
)
// 创建几条可用UTXO
privacyMock
.
CreateUTXOs
(
testAddrs
[
0
],
testPubkeyPairs
[
0
],
17
*
types
.
Coin
,
10000
,
5
)
mock
.
setBlockChainHeight
(
10020
)
testCases
:=
[]
struct
{
req
*
ty
.
ReqPri2Pub
needReply
*
types
.
Reply
needError
error
}{
{
needError
:
types
.
ErrInvalidParam
,
},
{
req
:
&
ty
.
ReqPri2Pub
{
Tokenname
:
types
.
BTY
,
Amount
:
10
*
types
.
Coin
,
Sender
:
testAddrs
[
0
],
Receiver
:
testAddrs
[
0
],
},
needReply
:
&
types
.
Reply
{
IsOk
:
true
},
needError
:
types
.
ErrAddrNotExist
,
},
}
for
index
,
testCase
:=
range
testCases
{
_
,
getErr
:=
mock
.
wallet
.
GetAPI
()
.
ExecWalletFunc
(
ty
.
PrivacyX
,
"Privacy2Public"
,
testCase
.
req
)
require
.
Equalf
(
t
,
getErr
,
testCase
.
needError
,
"Privacy2Public test case index %d"
,
index
)
}
}
func
Test_CreateTransaction
(
t
*
testing
.
T
)
{
func
Test_CreateTransaction
(
t
*
testing
.
T
)
{
mock
:=
&
testDataMock
{
mock
:=
&
testDataMock
{
mockMempool
:
true
,
mockMempool
:
true
,
...
...
plugin/dapp/ticket/commands/ticket.go
View file @
8c429796
...
@@ -10,7 +10,6 @@ import (
...
@@ -10,7 +10,6 @@ import (
"fmt"
"fmt"
"os"
"os"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/rpc/jsonclient"
"github.com/33cn/chain33/rpc/jsonclient"
rpctypes
"github.com/33cn/chain33/rpc/types"
rpctypes
"github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
...
@@ -25,7 +24,6 @@ func TicketCmd() *cobra.Command {
...
@@ -25,7 +24,6 @@ func TicketCmd() *cobra.Command {
Short
:
"Ticket management"
,
Short
:
"Ticket management"
,
Args
:
cobra
.
MinimumNArgs
(
1
),
Args
:
cobra
.
MinimumNArgs
(
1
),
}
}
cmd
.
AddCommand
(
cmd
.
AddCommand
(
BindMinerCmd
(),
BindMinerCmd
(),
CountTicketCmd
(),
CountTicketCmd
(),
...
@@ -130,7 +128,7 @@ func closeTicket(cmd *cobra.Command, args []string) {
...
@@ -130,7 +128,7 @@ func closeTicket(cmd *cobra.Command, args []string) {
MinerAddress
:
bindAddr
,
MinerAddress
:
bindAddr
,
}
}
var
res
types
.
ReplyHashes
var
res
rpc
types
.
ReplyHashes
rpc
,
err
:=
jsonclient
.
NewJSONClient
(
rpcLaddr
)
rpc
,
err
:=
jsonclient
.
NewJSONClient
(
rpcLaddr
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
...
@@ -146,12 +144,7 @@ func closeTicket(cmd *cobra.Command, args []string) {
...
@@ -146,12 +144,7 @@ func closeTicket(cmd *cobra.Command, args []string) {
return
return
}
}
var
tx
txHashes
data
,
err
:=
json
.
MarshalIndent
(
res
,
""
,
" "
)
for
_
,
hash
:=
range
res
.
Hashes
{
tx
.
Hashes
=
append
(
tx
.
Hashes
,
common
.
ToHex
(
hash
))
}
data
,
err
:=
json
.
MarshalIndent
(
tx
,
""
,
" "
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
fmt
.
Fprintln
(
os
.
Stderr
,
err
)
return
return
...
...
plugin/dapp/ticket/commands/types.go
deleted
100644 → 0
View file @
57c2349e
// 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
commands
type
txHashes
struct
{
Hashes
[]
string
`json:"hashes"`
}
plugin/dapp/ticket/rpc/jrpc_channel_test.go
View file @
8c429796
...
@@ -46,13 +46,13 @@ func TestJRPCChannel(t *testing.T) {
...
@@ -46,13 +46,13 @@ func TestJRPCChannel(t *testing.T) {
}
}
func
testCountTicketCmd
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
func
testCountTicketCmd
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
var
res
types
.
ReplyHashes
var
res
int64
return
jrpc
.
Call
(
"ticket.
CloseTickets
"
,
nil
,
&
res
)
return
jrpc
.
Call
(
"ticket.
GetTicketCount
"
,
nil
,
&
res
)
}
}
func
testCloseTicketCmd
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
func
testCloseTicketCmd
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
var
res
int64
var
res
types
.
ReplyHashes
return
jrpc
.
Call
(
"ticket.
GetTicketCount
"
,
nil
,
&
res
)
return
jrpc
.
Call
(
"ticket.
CloseTickets
"
,
nil
,
&
res
)
}
}
func
testGetColdAddrByMinerCmd
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
func
testGetColdAddrByMinerCmd
(
t
*
testing
.
T
,
jrpc
*
jsonclient
.
JSONClient
)
error
{
...
...
plugin/dapp/ticket/rpc/rpc.go
View file @
8c429796
...
@@ -5,8 +5,6 @@
...
@@ -5,8 +5,6 @@
package
rpc
package
rpc
import
(
import
(
"encoding/hex"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/address"
rpctypes
"github.com/33cn/chain33/rpc/types"
rpctypes
"github.com/33cn/chain33/rpc/types"
...
@@ -115,7 +113,7 @@ func (c *Jrpc) CloseTickets(in *ty.TicketClose, result *interface{}) error {
...
@@ -115,7 +113,7 @@ func (c *Jrpc) CloseTickets(in *ty.TicketClose, result *interface{}) error {
}
}
var
hashes
rpctypes
.
ReplyHashes
var
hashes
rpctypes
.
ReplyHashes
for
_
,
has
:=
range
resp
.
Hashes
{
for
_
,
has
:=
range
resp
.
Hashes
{
hashes
.
Hashes
=
append
(
hashes
.
Hashes
,
hex
.
EncodeToString
(
has
))
hashes
.
Hashes
=
append
(
hashes
.
Hashes
,
common
.
ToHex
(
has
))
}
}
*
result
=
&
hashes
*
result
=
&
hashes
return
nil
return
nil
...
...
plugin/dapp/ticket/rpc/rpc_real_test.go
View file @
8c429796
...
@@ -8,9 +8,12 @@ package rpc_test
...
@@ -8,9 +8,12 @@ package rpc_test
import
(
import
(
"testing"
"testing"
rpctypes
"github.com/33cn/chain33/rpc/types"
_
"github.com/33cn/chain33/system"
_
"github.com/33cn/chain33/system"
"github.com/33cn/chain33/util/testnode"
"github.com/33cn/chain33/util/testnode"
_
"github.com/33cn/plugin/plugin"
_
"github.com/33cn/plugin/plugin"
ty
"github.com/33cn/plugin/plugin/dapp/ticket/types"
"github.com/stretchr/testify/assert"
)
)
func
TestNewTicket
(
t
*
testing
.
T
)
{
func
TestNewTicket
(
t
*
testing
.
T
)
{
...
@@ -19,4 +22,10 @@ func TestNewTicket(t *testing.T) {
...
@@ -19,4 +22,10 @@ func TestNewTicket(t *testing.T) {
mock33
:=
testnode
.
NewWithConfig
(
cfg
,
sub
,
nil
)
mock33
:=
testnode
.
NewWithConfig
(
cfg
,
sub
,
nil
)
defer
mock33
.
Close
()
defer
mock33
.
Close
()
mock33
.
WaitHeight
(
5
)
mock33
.
WaitHeight
(
5
)
mock33
.
Listen
()
//选票(可以用hotwallet 关闭选票)
in
:=
&
ty
.
TicketClose
{
MinerAddress
:
mock33
.
GetHotAddress
()}
var
res
rpctypes
.
ReplyHashes
err
:=
mock33
.
GetJSONC
()
.
Call
(
"ticket.CloseTickets"
,
in
,
&
res
)
assert
.
Nil
(
t
,
err
)
}
}
vendor/github.com/33cn/chain33/build/autotest/gitlabci/gitlab-ci-autotest.sh
View file @
8c429796
...
@@ -214,7 +214,7 @@ function auto_test() {
...
@@ -214,7 +214,7 @@ function auto_test() {
fi
fi
echo
"=========== #config token blacklist ============="
echo
"=========== #config token blacklist ============="
rawData
=
$(${
CLI
}
config config_tx
-
k
token-blacklist
-o
add
-v
BTC
)
rawData
=
$(${
CLI
}
config config_tx
-
c
token-blacklist
-o
add
-v
BTC
)
signData
=
$(${
CLI
}
wallet sign
-d
"
${
rawData
}
"
-k
0xc34b5d9d44ac7b754806f761d3d4d2c4fe5214f6b074c19f069c4f5c2a29c8cc
)
signData
=
$(${
CLI
}
wallet sign
-d
"
${
rawData
}
"
-k
0xc34b5d9d44ac7b754806f761d3d4d2c4fe5214f6b074c19f069c4f5c2a29c8cc
)
hash
=
$(${
CLI
}
wallet send
-d
"
${
signData
}
"
)
hash
=
$(${
CLI
}
wallet send
-d
"
${
signData
}
"
)
block_wait
"
${
CLI
}
"
2
block_wait
"
${
CLI
}
"
2
...
...
vendor/github.com/33cn/chain33/build/autotest/jerkinsci/jerkins-ci-autotest.sh
View file @
8c429796
...
@@ -130,7 +130,7 @@ function start_chain33() {
...
@@ -130,7 +130,7 @@ function start_chain33() {
fi
fi
echo
"=========== #config token blacklist ============="
echo
"=========== #config token blacklist ============="
rawData
=
$(${
CLI
}
config config_tx
-
k
token-blacklist
-o
add
-v
BTC
)
rawData
=
$(${
CLI
}
config config_tx
-
c
token-blacklist
-o
add
-v
BTC
)
signData
=
$(${
CLI
}
wallet sign
-d
"
${
rawData
}
"
-k
0xc34b5d9d44ac7b754806f761d3d4d2c4fe5214f6b074c19f069c4f5c2a29c8cc
)
signData
=
$(${
CLI
}
wallet sign
-d
"
${
rawData
}
"
-k
0xc34b5d9d44ac7b754806f761d3d4d2c4fe5214f6b074c19f069c4f5c2a29c8cc
)
hash
=
$(${
CLI
}
wallet send
-d
"
${
signData
}
"
)
hash
=
$(${
CLI
}
wallet send
-d
"
${
signData
}
"
)
...
...
vendor/github.com/33cn/chain33/build/autotest/local/local-autotest.sh
View file @
8c429796
...
@@ -143,7 +143,7 @@ function start_chain33() {
...
@@ -143,7 +143,7 @@ function start_chain33() {
fi
fi
echo
"=========== #config token blacklist ============="
echo
"=========== #config token blacklist ============="
rawData
=
$(${
CLI
}
config config_tx
-
k
token-blacklist
-o
add
-v
BTC
)
rawData
=
$(${
CLI
}
config config_tx
-
c
token-blacklist
-o
add
-v
BTC
)
signData
=
$(${
CLI
}
wallet sign
-d
"
${
rawData
}
"
-k
0xc34b5d9d44ac7b754806f761d3d4d2c4fe5214f6b074c19f069c4f5c2a29c8cc
)
signData
=
$(${
CLI
}
wallet sign
-d
"
${
rawData
}
"
-k
0xc34b5d9d44ac7b754806f761d3d4d2c4fe5214f6b074c19f069c4f5c2a29c8cc
)
hash
=
$(${
CLI
}
wallet send
-d
"
${
signData
}
"
)
hash
=
$(${
CLI
}
wallet send
-d
"
${
signData
}
"
)
...
...
vendor/github.com/33cn/chain33/build/util/black_list.sh
View file @
8c429796
#!/usr/bin/env bash
#!/usr/bin/env bash
guodun
=
"
$(
../chain33-cli config config_tx
-
k
token-blacklist
-o
add
-v
BTY
--paraName
"user.p.guodun."
)
"
guodun
=
"
$(
../chain33-cli config config_tx
-
c
token-blacklist
-o
add
-v
BTY
--paraName
"user.p.guodun."
)
"
fzmtest
=
"
$(
../chain33-cli config config_tx
-
k
token-blacklist
-o
add
-v
BTY
--paraName
"user.p.fzmtest."
)
"
fzmtest
=
"
$(
../chain33-cli config config_tx
-
c
token-blacklist
-o
add
-v
BTY
--paraName
"user.p.fzmtest."
)
"
echo
"cli wallet sign -d
$guodun
-a 1JmFaA6unrCFYEWPGRi7uuXY1KthTJxJEP -e 1h > d:/b.txt"
echo
"cli wallet sign -d
$guodun
-a 1JmFaA6unrCFYEWPGRi7uuXY1KthTJxJEP -e 1h > d:/b.txt"
echo
"cli wallet sign -d
$fzmtest
-a 1JmFaA6unrCFYEWPGRi7uuXY1KthTJxJEP -e 1h >> d:/b.txt"
echo
"cli wallet sign -d
$fzmtest
-a 1JmFaA6unrCFYEWPGRi7uuXY1KthTJxJEP -e 1h >> d:/b.txt"
vendor/github.com/33cn/chain33/build/util/manage.sh
View file @
8c429796
#!/usr/bin/env bash
#!/usr/bin/env bash
fzmtest
=
"
$(
../chain33-cli
--paraName
user.p.fzmtest. config config_tx
-
k
lottery-creator
-o
add
-v
15nn4D2ppUj8tmyHfdm8g4EvtqpBYUS7DM
)
"
fzmtest
=
"
$(
../chain33-cli
--paraName
user.p.fzmtest. config config_tx
-
c
lottery-creator
-o
add
-v
15nn4D2ppUj8tmyHfdm8g4EvtqpBYUS7DM
)
"
echo
"cli wallet sign -d
$fzmtest
-a 1JmFaA6unrCFYEWPGRi7uuXY1KthTJxJEP -e 1h >> d:/b.txt"
echo
"cli wallet sign -d
$fzmtest
-a 1JmFaA6unrCFYEWPGRi7uuXY1KthTJxJEP -e 1h >> d:/b.txt"
vendor/github.com/33cn/chain33/build/util/manage_list.sh
View file @
8c429796
#!/usr/bin/env bash
#!/usr/bin/env bash
guodun1
=
$(
../chain33-cli config config_tx
-
k
token-blacklist
-o
add
-v
BTY
--paraName
"user.p.
$2
."
)
guodun1
=
$(
../chain33-cli config config_tx
-
c
token-blacklist
-o
add
-v
BTY
--paraName
"user.p.
$2
."
)
guodun2
=
$(
../chain33-cli config config_tx
-
k
token-finisher
-o
add
-v
"
$1
"
--paraName
"user.p.
$2
."
)
guodun2
=
$(
../chain33-cli config config_tx
-
c
token-finisher
-o
add
-v
"
$1
"
--paraName
"user.p.
$2
."
)
echo
"cli wallet sign -d
$guodun1
-a 1JmFaA6unrCFYEWPGRi7uuXY1KthTJxJEP -e 1h > d:/b.txt"
echo
"cli wallet sign -d
$guodun1
-a 1JmFaA6unrCFYEWPGRi7uuXY1KthTJxJEP -e 1h > d:/b.txt"
echo
"cli wallet sign -d
$guodun2
-a 1JmFaA6unrCFYEWPGRi7uuXY1KthTJxJEP -e 1h >> d:/b.txt"
echo
"cli wallet sign -d
$guodun2
-a 1JmFaA6unrCFYEWPGRi7uuXY1KthTJxJEP -e 1h >> d:/b.txt"
vendor/github.com/33cn/chain33/executor/allow.go
View file @
8c429796
...
@@ -88,9 +88,9 @@ func isAllowLocalKey2(execer []byte, key []byte) error {
...
@@ -88,9 +88,9 @@ func isAllowLocalKey2(execer []byte, key []byte) error {
err
:=
errors
.
Wrapf
(
types
.
ErrLocalKeyLen
,
"isAllowLocalKey too short. key=%s exec=%s"
,
string
(
key
),
string
(
execer
))
err
:=
errors
.
Wrapf
(
types
.
ErrLocalKeyLen
,
"isAllowLocalKey too short. key=%s exec=%s"
,
string
(
key
),
string
(
execer
))
return
err
return
err
}
}
if
key
[
minkeylen
-
1
]
!=
'-'
{
if
key
[
minkeylen
-
1
]
!=
'-'
||
key
[
len
(
types
.
LocalPrefix
)]
!=
'-'
{
err
:=
errors
.
Wrapf
(
types
.
ErrLocalPrefix
,
err
:=
errors
.
Wrapf
(
types
.
ErrLocalPrefix
,
"isAllowLocalKey prefix last char is not '-'. key=%s exec=%s minkeylen=%d title=%s"
,
"isAllowLocalKey prefix last char
or separator
is not '-'. key=%s exec=%s minkeylen=%d title=%s"
,
string
(
key
),
string
(
execer
),
minkeylen
,
types
.
GetTitle
())
string
(
key
),
string
(
execer
),
minkeylen
,
types
.
GetTitle
())
return
err
return
err
}
}
...
...
vendor/github.com/33cn/chain33/executor/executor_test.go
View file @
8c429796
...
@@ -130,6 +130,8 @@ func TestKeyAllow_evm(t *testing.T) {
...
@@ -130,6 +130,8 @@ func TestKeyAllow_evm(t *testing.T) {
func
TestKeyLocalAllow
(
t
*
testing
.
T
)
{
func
TestKeyLocalAllow
(
t
*
testing
.
T
)
{
err
:=
isAllowLocalKey
([]
byte
(
"token"
),
[]
byte
(
"LODB-token-"
))
err
:=
isAllowLocalKey
([]
byte
(
"token"
),
[]
byte
(
"LODB-token-"
))
assert
.
Equal
(
t
,
err
,
types
.
ErrLocalKeyLen
)
assert
.
Equal
(
t
,
err
,
types
.
ErrLocalKeyLen
)
err
=
isAllowLocalKey
([]
byte
(
"token"
),
[]
byte
(
"LODB_token-a"
))
assert
.
Equal
(
t
,
err
,
types
.
ErrLocalPrefix
)
err
=
isAllowLocalKey
([]
byte
(
"token"
),
[]
byte
(
"LODB-token-a"
))
err
=
isAllowLocalKey
([]
byte
(
"token"
),
[]
byte
(
"LODB-token-a"
))
assert
.
Nil
(
t
,
err
)
assert
.
Nil
(
t
,
err
)
err
=
isAllowLocalKey
([]
byte
(
""
),
[]
byte
(
"LODB--a"
))
err
=
isAllowLocalKey
([]
byte
(
""
),
[]
byte
(
"LODB--a"
))
...
...
vendor/github.com/33cn/chain33/rpc/grpcclient/api_test.go
View file @
8c429796
...
@@ -46,6 +46,37 @@ func TestMultipleGRPC(t *testing.T) {
...
@@ -46,6 +46,37 @@ func TestMultipleGRPC(t *testing.T) {
assert
.
Equal
(
t
,
reply
.
Hash
,
[]
byte
(
"hello"
))
assert
.
Equal
(
t
,
reply
.
Hash
,
[]
byte
(
"hello"
))
}
}
func
TestMultipleGRPCLocalhost
(
t
*
testing
.
T
)
{
qapi
:=
new
(
mocks
.
QueueProtocolAPI
)
qapi
.
On
(
"Query"
,
"ticket"
,
"RandNumHash"
,
mock
.
Anything
)
.
Return
(
&
types
.
ReplyHash
{
Hash
:
[]
byte
(
"hello"
)},
nil
)
//testnode setup
rpcCfg
:=
new
(
types
.
RPC
)
rpcCfg
.
GrpcBindAddr
=
"localhost:8003"
rpcCfg
.
JrpcBindAddr
=
"localhost:8004"
rpcCfg
.
MainnetJrpcAddr
=
rpcCfg
.
JrpcBindAddr
rpcCfg
.
Whitelist
=
[]
string
{
"localhost"
,
"0.0.0.0"
}
rpcCfg
.
JrpcFuncWhitelist
=
[]
string
{
"*"
}
rpcCfg
.
GrpcFuncWhitelist
=
[]
string
{
"*"
}
rpc
.
InitCfg
(
rpcCfg
)
server
:=
rpc
.
NewGRpcServer
(
&
qmocks
.
Client
{},
qapi
)
assert
.
NotNil
(
t
,
server
)
go
server
.
Listen
()
time
.
Sleep
(
time
.
Second
)
//一个IP 有效,一个IP 无效
paraRemoteGrpcClient
:=
"localhost:8004,localhost:8003,localhost"
conn
,
err
:=
grpc
.
Dial
(
grpcclient
.
NewMultipleURL
(
paraRemoteGrpcClient
),
grpc
.
WithInsecure
())
assert
.
Nil
(
t
,
err
)
grpcClient
:=
types
.
NewChain33Client
(
conn
)
param
:=
&
types
.
ReqRandHash
{
ExecName
:
"ticket"
,
BlockNum
:
5
,
Hash
:
[]
byte
(
"hello"
),
}
reply
,
err
:=
grpcClient
.
QueryRandNum
(
context
.
Background
(),
param
)
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
reply
.
Hash
,
[]
byte
(
"hello"
))
}
func
TestNewParaClient
(
t
*
testing
.
T
)
{
func
TestNewParaClient
(
t
*
testing
.
T
)
{
qapi
:=
new
(
mocks
.
QueueProtocolAPI
)
qapi
:=
new
(
mocks
.
QueueProtocolAPI
)
qapi
.
On
(
"Query"
,
"ticket"
,
"RandNumHash"
,
mock
.
Anything
)
.
Return
(
&
types
.
ReplyHash
{
Hash
:
[]
byte
(
"hello"
)},
nil
)
qapi
.
On
(
"Query"
,
"ticket"
,
"RandNumHash"
,
mock
.
Anything
)
.
Return
(
&
types
.
ReplyHash
{
Hash
:
[]
byte
(
"hello"
)},
nil
)
...
...
vendor/github.com/33cn/chain33/rpc/grpcclient/resolver.go
View file @
8c429796
...
@@ -62,7 +62,7 @@ func (*multipleBuilder) Build(target resolver.Target, cc resolver.ClientConn, op
...
@@ -62,7 +62,7 @@ func (*multipleBuilder) Build(target resolver.Target, cc resolver.ClientConn, op
return
nil
,
err
return
nil
,
err
}
}
if
net
.
ParseIP
(
host
)
!=
nil
{
if
host
!=
""
{
r
.
addrs
=
append
(
r
.
addrs
,
resolver
.
Address
{
Addr
:
host
+
":"
+
port
})
r
.
addrs
=
append
(
r
.
addrs
,
resolver
.
Address
{
Addr
:
host
+
":"
+
port
})
}
}
}
}
...
...
vendor/github.com/33cn/chain33/system/dapp/manage/commands/config.go
View file @
8c429796
...
@@ -47,8 +47,8 @@ func ConfigTxCmd() *cobra.Command {
...
@@ -47,8 +47,8 @@ func ConfigTxCmd() *cobra.Command {
}
}
func
addConfigTxFlags
(
cmd
*
cobra
.
Command
)
{
func
addConfigTxFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"
key"
,
"k"
,
""
,
"
key string"
)
cmd
.
Flags
()
.
StringP
(
"
config_key"
,
"c"
,
""
,
"config
key string"
)
cmd
.
MarkFlagRequired
(
"key"
)
cmd
.
MarkFlagRequired
(
"
config_
key"
)
cmd
.
Flags
()
.
StringP
(
"operation"
,
"o"
,
""
,
"adding or deletion operation"
)
cmd
.
Flags
()
.
StringP
(
"operation"
,
"o"
,
""
,
"adding or deletion operation"
)
cmd
.
MarkFlagRequired
(
"operation"
)
cmd
.
MarkFlagRequired
(
"operation"
)
...
@@ -60,7 +60,7 @@ func addConfigTxFlags(cmd *cobra.Command) {
...
@@ -60,7 +60,7 @@ func addConfigTxFlags(cmd *cobra.Command) {
func
configTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
configTx
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
paraName
,
_
:=
cmd
.
Flags
()
.
GetString
(
"paraName"
)
key
,
_
:=
cmd
.
Flags
()
.
GetString
(
"key"
)
key
,
_
:=
cmd
.
Flags
()
.
GetString
(
"
config_
key"
)
op
,
_
:=
cmd
.
Flags
()
.
GetString
(
"operation"
)
op
,
_
:=
cmd
.
Flags
()
.
GetString
(
"operation"
)
opAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"value"
)
opAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"value"
)
...
...
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