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
05eef4b4
Commit
05eef4b4
authored
May 14, 2019
by
jiangpeng
Committed by
vipwzw
May 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify privacy createTx param
parent
c9d494d8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
38 additions
and
20 deletions
+38
-20
privacy.go
plugin/dapp/privacy/commands/privacy.go
+3
-3
privacy.proto
plugin/dapp/privacy/proto/privacy.proto
+22
-4
rpc.go
plugin/dapp/privacy/rpc/rpc.go
+2
-2
privacy.pb.go
plugin/dapp/privacy/types/privacy.pb.go
+0
-0
exec.go
plugin/dapp/privacy/wallet/exec.go
+1
-1
privacy.go
plugin/dapp/privacy/wallet/privacy.go
+4
-4
privacy_test.go
plugin/dapp/privacy/wallet/privacy_test.go
+2
-2
privacybizpolicy_test.go
plugin/dapp/privacy/wallet/privacybizpolicy_test.go
+4
-4
No files found.
plugin/dapp/privacy/commands/privacy.go
View file @
05eef4b4
...
@@ -124,7 +124,7 @@ func createPub2PrivTx(cmd *cobra.Command, args []string) {
...
@@ -124,7 +124,7 @@ func createPub2PrivTx(cmd *cobra.Command, args []string) {
return
return
}
}
params
:=
types
.
ReqCreateTransaction
{
params
:=
pty
.
ReqCreatePrivacyTx
{
Tokenname
:
tokenname
,
Tokenname
:
tokenname
,
Type
:
types
.
PrivacyTypePublic2Privacy
,
Type
:
types
.
PrivacyTypePublic2Privacy
,
Amount
:
amount
,
Amount
:
amount
,
...
@@ -186,7 +186,7 @@ func createPriv2PrivTx(cmd *cobra.Command, args []string) {
...
@@ -186,7 +186,7 @@ func createPriv2PrivTx(cmd *cobra.Command, args []string) {
return
return
}
}
params
:=
types
.
ReqCreateTransaction
{
params
:=
pty
.
ReqCreatePrivacyTx
{
Tokenname
:
tokenname
,
Tokenname
:
tokenname
,
Type
:
types
.
PrivacyTypePrivacy2Privacy
,
Type
:
types
.
PrivacyTypePrivacy2Privacy
,
Amount
:
amount
,
Amount
:
amount
,
...
@@ -250,7 +250,7 @@ func createPriv2PubTx(cmd *cobra.Command, args []string) {
...
@@ -250,7 +250,7 @@ func createPriv2PubTx(cmd *cobra.Command, args []string) {
return
return
}
}
params
:=
types
.
ReqCreateTransaction
{
params
:=
pty
.
ReqCreatePrivacyTx
{
Tokenname
:
tokenname
,
Tokenname
:
tokenname
,
Type
:
types
.
PrivacyTypePrivacy2Public
,
Type
:
types
.
PrivacyTypePrivacy2Public
,
Amount
:
amount
,
Amount
:
amount
,
...
...
plugin/dapp/privacy/proto/privacy.proto
View file @
05eef4b4
...
@@ -4,7 +4,6 @@ package types;
...
@@ -4,7 +4,6 @@ package types;
import
"common.proto"
;
import
"common.proto"
;
import
"transaction.proto"
;
import
"transaction.proto"
;
import
"wallet.proto"
;
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// message for Privacy
// message for Privacy
...
@@ -408,6 +407,26 @@ message WalletAccountPrivacy {
...
@@ -408,6 +407,26 @@ message WalletAccountPrivacy {
bytes
spendPrivKey
=
4
;
bytes
spendPrivKey
=
4
;
}
}
// 创建隐私交易请求
message
ReqCreatePrivacyTx
{
string
tokenname
=
1
;
// 构建交易类型
// 1:隐私交易 公开->隐私
// 2:隐私交易 隐私->隐私
// 3:隐私交易 隐私->公开
int32
type
=
2
;
int64
amount
=
3
;
string
note
=
4
;
// 普通交易的发送方
string
from
=
5
;
// 普通交易的接收方
string
to
=
6
;
// 隐私交易,接收方的公钥对
string
pubkeypair
=
10
;
int32
mixcount
=
11
;
int64
expire
=
12
;
}
service
privacy
{
service
privacy
{
// Privacy Trading
// Privacy Trading
// 显示指定地址的公钥对信息,可以作为后续交易参数
// 显示指定地址的公钥对信息,可以作为后续交易参数
...
@@ -419,5 +438,5 @@ service privacy {
...
@@ -419,5 +438,5 @@ service privacy {
// 使能隐私账户
// 使能隐私账户
rpc
EnablePrivacy
(
ReqEnablePrivacy
)
returns
(
RepEnablePrivacy
)
{}
rpc
EnablePrivacy
(
ReqEnablePrivacy
)
returns
(
RepEnablePrivacy
)
{}
// 创建隐私交易
// 创建隐私交易
rpc
CreateRawTransaction
(
ReqCreateTransaction
)
returns
(
Transaction
)
{}
rpc
CreateRawTransaction
(
ReqCreatePrivacyTx
)
returns
(
Transaction
)
{}
}
}
\ No newline at end of file
plugin/dapp/privacy/rpc/rpc.go
View file @
05eef4b4
...
@@ -51,7 +51,7 @@ func (g *channelClient) EnablePrivacy(ctx context.Context, in *pty.ReqEnablePriv
...
@@ -51,7 +51,7 @@ func (g *channelClient) EnablePrivacy(ctx context.Context, in *pty.ReqEnablePriv
return
data
.
(
*
pty
.
RepEnablePrivacy
),
nil
return
data
.
(
*
pty
.
RepEnablePrivacy
),
nil
}
}
func
(
g
*
channelClient
)
CreateRawTransaction
(
ctx
context
.
Context
,
in
*
types
.
ReqCreateTransaction
)
(
*
types
.
Transaction
,
error
)
{
func
(
g
*
channelClient
)
CreateRawTransaction
(
ctx
context
.
Context
,
in
*
pty
.
ReqCreatePrivacyTx
)
(
*
types
.
Transaction
,
error
)
{
data
,
err
:=
g
.
ExecWalletFunc
(
pty
.
PrivacyX
,
"CreateTransaction"
,
in
)
data
,
err
:=
g
.
ExecWalletFunc
(
pty
.
PrivacyX
,
"CreateTransaction"
,
in
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
@@ -145,7 +145,7 @@ func (c *Jrpc) EnablePrivacy(in *pty.ReqEnablePrivacy, result *json.RawMessage)
...
@@ -145,7 +145,7 @@ func (c *Jrpc) EnablePrivacy(in *pty.ReqEnablePrivacy, result *json.RawMessage)
}
}
// CreateRawTransaction create raw trasaction for json rpc
// CreateRawTransaction create raw trasaction for json rpc
func
(
c
*
Jrpc
)
CreateRawTransaction
(
in
*
types
.
ReqCreateTransaction
,
result
*
interface
{})
error
{
func
(
c
*
Jrpc
)
CreateRawTransaction
(
in
*
pty
.
ReqCreatePrivacyTx
,
result
*
interface
{})
error
{
reply
,
err
:=
c
.
cli
.
CreateRawTransaction
(
context
.
Background
(),
in
)
reply
,
err
:=
c
.
cli
.
CreateRawTransaction
(
context
.
Background
(),
in
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
plugin/dapp/privacy/types/privacy.pb.go
View file @
05eef4b4
This diff is collapsed.
Click to expand it.
plugin/dapp/privacy/wallet/exec.go
View file @
05eef4b4
...
@@ -39,7 +39,7 @@ func (policy *privacyPolicy) On_CreateUTXOs(req *privacytypes.ReqCreateUTXOs) (t
...
@@ -39,7 +39,7 @@ func (policy *privacyPolicy) On_CreateUTXOs(req *privacytypes.ReqCreateUTXOs) (t
return
reply
,
err
return
reply
,
err
}
}
func
(
policy
*
privacyPolicy
)
On_CreateTransaction
(
req
*
types
.
ReqCreateTransaction
)
(
types
.
Message
,
error
)
{
func
(
policy
*
privacyPolicy
)
On_CreateTransaction
(
req
*
privacytypes
.
ReqCreatePrivacyTx
)
(
types
.
Message
,
error
)
{
ok
,
err
:=
policy
.
getWalletOperate
()
.
CheckWalletStatus
()
ok
,
err
:=
policy
.
getWalletOperate
()
.
CheckWalletStatus
()
if
!
ok
{
if
!
ok
{
bizlog
.
Error
(
"createTransaction"
,
"CheckWalletStatus cause error."
,
err
)
bizlog
.
Error
(
"createTransaction"
,
"CheckWalletStatus cause error."
,
err
)
...
...
plugin/dapp/privacy/wallet/privacy.go
View file @
05eef4b4
...
@@ -562,7 +562,7 @@ func (policy *privacyPolicy) buildInput(privacykeyParirs *privacy.Privacy, build
...
@@ -562,7 +562,7 @@ func (policy *privacyPolicy) buildInput(privacykeyParirs *privacy.Privacy, build
return
privacyInput
,
utxosInKeyInput
,
realkeyInputSlice
,
selectedUtxo
,
nil
return
privacyInput
,
utxosInKeyInput
,
realkeyInputSlice
,
selectedUtxo
,
nil
}
}
func
(
policy
*
privacyPolicy
)
createTransaction
(
req
*
types
.
ReqCreateTransaction
)
(
*
types
.
Transaction
,
error
)
{
func
(
policy
*
privacyPolicy
)
createTransaction
(
req
*
privacytypes
.
ReqCreatePrivacyTx
)
(
*
types
.
Transaction
,
error
)
{
switch
req
.
Type
{
switch
req
.
Type
{
case
types
.
PrivacyTypePublic2Privacy
:
case
types
.
PrivacyTypePublic2Privacy
:
return
policy
.
createPublic2PrivacyTx
(
req
)
return
policy
.
createPublic2PrivacyTx
(
req
)
...
@@ -574,7 +574,7 @@ func (policy *privacyPolicy) createTransaction(req *types.ReqCreateTransaction)
...
@@ -574,7 +574,7 @@ func (policy *privacyPolicy) createTransaction(req *types.ReqCreateTransaction)
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
func
(
policy
*
privacyPolicy
)
createPublic2PrivacyTx
(
req
*
types
.
ReqCreateTransaction
)
(
*
types
.
Transaction
,
error
)
{
func
(
policy
*
privacyPolicy
)
createPublic2PrivacyTx
(
req
*
privacytypes
.
ReqCreatePrivacyTx
)
(
*
types
.
Transaction
,
error
)
{
viewPubSlice
,
spendPubSlice
,
err
:=
parseViewSpendPubKeyPair
(
req
.
GetPubkeypair
())
viewPubSlice
,
spendPubSlice
,
err
:=
parseViewSpendPubKeyPair
(
req
.
GetPubkeypair
())
if
err
!=
nil
{
if
err
!=
nil
{
bizlog
.
Error
(
"createPublic2PrivacyTx"
,
"parse view spend public key pair failed. err "
,
err
)
bizlog
.
Error
(
"createPublic2PrivacyTx"
,
"parse view spend public key pair failed. err "
,
err
)
...
@@ -621,7 +621,7 @@ func (policy *privacyPolicy) createPublic2PrivacyTx(req *types.ReqCreateTransact
...
@@ -621,7 +621,7 @@ func (policy *privacyPolicy) createPublic2PrivacyTx(req *types.ReqCreateTransact
return
tx
,
nil
return
tx
,
nil
}
}
func
(
policy
*
privacyPolicy
)
createPrivacy2PrivacyTx
(
req
*
types
.
ReqCreateTransaction
)
(
*
types
.
Transaction
,
error
)
{
func
(
policy
*
privacyPolicy
)
createPrivacy2PrivacyTx
(
req
*
privacytypes
.
ReqCreatePrivacyTx
)
(
*
types
.
Transaction
,
error
)
{
//需要燃烧的utxo
//需要燃烧的utxo
utxoBurnedAmount
:=
privacytypes
.
PrivacyTxFee
utxoBurnedAmount
:=
privacytypes
.
PrivacyTxFee
...
@@ -708,7 +708,7 @@ func (policy *privacyPolicy) createPrivacy2PrivacyTx(req *types.ReqCreateTransac
...
@@ -708,7 +708,7 @@ func (policy *privacyPolicy) createPrivacy2PrivacyTx(req *types.ReqCreateTransac
return
tx
,
nil
return
tx
,
nil
}
}
func
(
policy
*
privacyPolicy
)
createPrivacy2PublicTx
(
req
*
types
.
ReqCreateTransaction
)
(
*
types
.
Transaction
,
error
)
{
func
(
policy
*
privacyPolicy
)
createPrivacy2PublicTx
(
req
*
privacytypes
.
ReqCreatePrivacyTx
)
(
*
types
.
Transaction
,
error
)
{
//需要燃烧的utxo
//需要燃烧的utxo
utxoBurnedAmount
:=
privacytypes
.
PrivacyTxFee
utxoBurnedAmount
:=
privacytypes
.
PrivacyTxFee
...
...
plugin/dapp/privacy/wallet/privacy_test.go
View file @
05eef4b4
...
@@ -119,7 +119,7 @@ func (mock *PrivacyMock) CreateUTXOs(sender string, pubkeypair string, amount in
...
@@ -119,7 +119,7 @@ func (mock *PrivacyMock) CreateUTXOs(sender string, pubkeypair string, amount in
privacyInfo
,
_
:=
mock
.
policy
.
getPrivacyKeyPairs
()
privacyInfo
,
_
:=
mock
.
policy
.
getPrivacyKeyPairs
()
dbbatch
:=
mock
.
store
.
NewBatch
(
true
)
dbbatch
:=
mock
.
store
.
NewBatch
(
true
)
for
n
:=
0
;
n
<
count
;
n
++
{
for
n
:=
0
;
n
<
count
;
n
++
{
tx
:=
mock
.
createPublic2PrivacyTx
(
&
ty
pes
.
ReqCreateTransaction
{
tx
:=
mock
.
createPublic2PrivacyTx
(
&
ty
.
ReqCreatePrivacyTx
{
Tokenname
:
mock
.
tokenName
,
Tokenname
:
mock
.
tokenName
,
Type
:
1
,
Type
:
1
,
Amount
:
amount
,
Amount
:
amount
,
...
@@ -188,7 +188,7 @@ func (mock *PrivacyMock) CreateUTXOs(sender string, pubkeypair string, amount in
...
@@ -188,7 +188,7 @@ func (mock *PrivacyMock) CreateUTXOs(sender string, pubkeypair string, amount in
dbbatch
.
Write
()
dbbatch
.
Write
()
}
}
func
(
mock
*
PrivacyMock
)
createPublic2PrivacyTx
(
req
*
ty
pes
.
ReqCreateTransaction
)
*
types
.
Transaction
{
func
(
mock
*
PrivacyMock
)
createPublic2PrivacyTx
(
req
*
ty
.
ReqCreatePrivacyTx
)
*
types
.
Transaction
{
viewPubSlice
,
spendPubSlice
,
err
:=
parseViewSpendPubKeyPair
(
req
.
GetPubkeypair
())
viewPubSlice
,
spendPubSlice
,
err
:=
parseViewSpendPubKeyPair
(
req
.
GetPubkeypair
())
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
return
nil
...
...
plugin/dapp/privacy/wallet/privacybizpolicy_test.go
View file @
05eef4b4
...
@@ -375,7 +375,7 @@ func Test_CreateTransaction(t *testing.T) {
...
@@ -375,7 +375,7 @@ func Test_CreateTransaction(t *testing.T) {
mock
.
setBlockChainHeight
(
10020
)
mock
.
setBlockChainHeight
(
10020
)
testCases
:=
[]
struct
{
testCases
:=
[]
struct
{
req
*
ty
pes
.
ReqCreateTransaction
req
*
ty
.
ReqCreatePrivacyTx
needReply
*
types
.
Transaction
needReply
*
types
.
Transaction
needError
error
needError
error
}{
}{
...
@@ -383,7 +383,7 @@ func Test_CreateTransaction(t *testing.T) {
...
@@ -383,7 +383,7 @@ func Test_CreateTransaction(t *testing.T) {
needError
:
types
.
ErrInvalidParam
,
needError
:
types
.
ErrInvalidParam
,
},
},
{
// 公对私测试
{
// 公对私测试
req
:
&
ty
pes
.
ReqCreateTransaction
{
req
:
&
ty
.
ReqCreatePrivacyTx
{
Tokenname
:
types
.
BTY
,
Tokenname
:
types
.
BTY
,
Type
:
1
,
Type
:
1
,
Amount
:
100
*
types
.
Coin
,
Amount
:
100
*
types
.
Coin
,
...
@@ -393,7 +393,7 @@ func Test_CreateTransaction(t *testing.T) {
...
@@ -393,7 +393,7 @@ func Test_CreateTransaction(t *testing.T) {
//needError:types.ErrAddrNotExist,
//needError:types.ErrAddrNotExist,
},
},
{
// 私对私测试
{
// 私对私测试
req
:
&
ty
pes
.
ReqCreateTransaction
{
req
:
&
ty
.
ReqCreatePrivacyTx
{
Tokenname
:
types
.
BTY
,
Tokenname
:
types
.
BTY
,
Type
:
2
,
Type
:
2
,
Amount
:
10
*
types
.
Coin
,
Amount
:
10
*
types
.
Coin
,
...
@@ -403,7 +403,7 @@ func Test_CreateTransaction(t *testing.T) {
...
@@ -403,7 +403,7 @@ func Test_CreateTransaction(t *testing.T) {
needError
:
types
.
ErrAddrNotExist
,
needError
:
types
.
ErrAddrNotExist
,
},
},
{
// 私对公测试
{
// 私对公测试
req
:
&
ty
pes
.
ReqCreateTransaction
{
req
:
&
ty
.
ReqCreatePrivacyTx
{
Tokenname
:
types
.
BTY
,
Tokenname
:
types
.
BTY
,
Type
:
3
,
Type
:
3
,
Amount
:
10
*
types
.
Coin
,
Amount
:
10
*
types
.
Coin
,
...
...
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