Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
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
张蕾
Geth-Modification
Commits
86ec2130
Commit
86ec2130
authored
Sep 29, 2018
by
reinerRubin
Committed by
Felix Lange
Sep 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/types: make tx signature values optional in JSON (#17742)
parent
3d782bc7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
12 deletions
+23
-12
transaction.go
core/types/transaction.go
+14
-9
transaction_test.go
core/types/transaction_test.go
+9
-3
No files found.
core/types/transaction.go
View file @
86ec2130
...
...
@@ -153,16 +153,21 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error {
if
err
:=
dec
.
UnmarshalJSON
(
input
);
err
!=
nil
{
return
err
}
var
V
byte
if
isProtectedV
(
dec
.
V
)
{
chainID
:=
deriveChainId
(
dec
.
V
)
.
Uint64
()
V
=
byte
(
dec
.
V
.
Uint64
()
-
35
-
2
*
chainID
)
}
else
{
V
=
byte
(
dec
.
V
.
Uint64
()
-
27
)
}
if
!
crypto
.
ValidateSignatureValues
(
V
,
dec
.
R
,
dec
.
S
,
false
)
{
return
ErrInvalidSig
withSignature
:=
dec
.
V
.
Sign
()
!=
0
||
dec
.
R
.
Sign
()
!=
0
||
dec
.
S
.
Sign
()
!=
0
if
withSignature
{
var
V
byte
if
isProtectedV
(
dec
.
V
)
{
chainID
:=
deriveChainId
(
dec
.
V
)
.
Uint64
()
V
=
byte
(
dec
.
V
.
Uint64
()
-
35
-
2
*
chainID
)
}
else
{
V
=
byte
(
dec
.
V
.
Uint64
()
-
27
)
}
if
!
crypto
.
ValidateSignatureValues
(
V
,
dec
.
R
,
dec
.
S
,
false
)
{
return
ErrInvalidSig
}
}
*
tx
=
Transaction
{
data
:
dec
}
return
nil
}
...
...
core/types/transaction_test.go
View file @
86ec2130
...
...
@@ -185,6 +185,7 @@ func TestTransactionJSON(t *testing.T) {
}
signer
:=
NewEIP155Signer
(
common
.
Big1
)
transactions
:=
make
([]
*
Transaction
,
0
,
50
)
for
i
:=
uint64
(
0
);
i
<
25
;
i
++
{
var
tx
*
Transaction
switch
i
%
2
{
...
...
@@ -193,20 +194,25 @@ func TestTransactionJSON(t *testing.T) {
case
1
:
tx
=
NewContractCreation
(
i
,
common
.
Big0
,
1
,
common
.
Big2
,
[]
byte
(
"abcdef"
))
}
transactions
=
append
(
transactions
,
tx
)
t
x
,
err
:=
SignTx
(
tx
,
signer
,
key
)
signedT
x
,
err
:=
SignTx
(
tx
,
signer
,
key
)
if
err
!=
nil
{
t
.
Fatalf
(
"could not sign transaction: %v"
,
err
)
}
transactions
=
append
(
transactions
,
signedTx
)
}
for
_
,
tx
:=
range
transactions
{
data
,
err
:=
json
.
Marshal
(
tx
)
if
err
!=
nil
{
t
.
Error
f
(
"json.Marshal failed: %v"
,
err
)
t
.
Fatal
f
(
"json.Marshal failed: %v"
,
err
)
}
var
parsedTx
*
Transaction
if
err
:=
json
.
Unmarshal
(
data
,
&
parsedTx
);
err
!=
nil
{
t
.
Error
f
(
"json.Unmarshal failed: %v"
,
err
)
t
.
Fatal
f
(
"json.Unmarshal failed: %v"
,
err
)
}
// compare nonce, price, gaslimit, recipient, amount, payload, V, R, S
...
...
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