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
73227309
Commit
73227309
authored
Jun 13, 2017
by
Péter Szilágyi
Committed by
GitHub
Jun 13, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14604 from bas-vk/mobile-getfrom
mobile: use EIP155 signer for determining sender
parents
061889d4
b8793edd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
2 deletions
+34
-2
android_test.go
mobile/android_test.go
+29
-0
types.go
mobile/types.go
+5
-2
No files found.
mobile/android_test.go
View file @
73227309
...
@@ -37,6 +37,9 @@ package go;
...
@@ -37,6 +37,9 @@ package go;
import android.test.InstrumentationTestCase;
import android.test.InstrumentationTestCase;
import android.test.MoreAsserts;
import android.test.MoreAsserts;
import java.math.BigInteger;
import java.util.Arrays;
import org.ethereum.geth.*;
import org.ethereum.geth.*;
public class AndroidTest extends InstrumentationTestCase {
public class AndroidTest extends InstrumentationTestCase {
...
@@ -115,6 +118,32 @@ public class AndroidTest extends InstrumentationTestCase {
...
@@ -115,6 +118,32 @@ public class AndroidTest extends InstrumentationTestCase {
fail(e.toString());
fail(e.toString());
}
}
}
}
// Tests that recovering transaction signers works for both Homestead and EIP155
// signatures too. Regression test for go-ethereum issue #14599.
public void testIssue14599() {
try {
byte[] preEIP155RLP = new BigInteger("f901fc8032830138808080b901ae60056013565b6101918061001d6000396000f35b3360008190555056006001600060e060020a6000350480630a874df61461003a57806341c0e1b514610058578063a02b161e14610066578063dbbdf0831461007757005b610045600435610149565b80600160a060020a031660005260206000f35b610060610161565b60006000f35b6100716004356100d4565b60006000f35b61008560043560243561008b565b60006000f35b600054600160a060020a031632600160a060020a031614156100ac576100b1565b6100d0565b8060018360005260205260406000208190555081600060005260206000a15b5050565b600054600160a060020a031633600160a060020a031614158015610118575033600160a060020a0316600182600052602052604060002054600160a060020a031614155b61012157610126565b610146565b600060018260005260205260406000208190555080600060005260206000a15b50565b60006001826000526020526040600020549050919050565b600054600160a060020a031633600160a060020a0316146101815761018f565b600054600160a060020a0316ff5b561ca0c5689ed1ad124753d54576dfb4b571465a41900a1dff4058d8adf16f752013d0a01221cbd70ec28c94a3b55ec771bcbc70778d6ee0b51ca7ea9514594c861b1884", 16).toByteArray();
preEIP155RLP = Arrays.copyOfRange(preEIP155RLP, 1, preEIP155RLP.length);
byte[] postEIP155RLP = new BigInteger("f86b80847735940082520894ef5bbb9bba2e1ca69ef81b23a8727d889f3ef0a1880de0b6b3a7640000802ba06fef16c44726a102e6d55a651740636ef8aec6df3ebf009e7b0c1f29e4ac114aa057e7fbc69760b522a78bb568cfc37a58bfdcf6ea86cb8f9b550263f58074b9cc", 16).toByteArray();
postEIP155RLP = Arrays.copyOfRange(postEIP155RLP, 1, postEIP155RLP.length);
Transaction preEIP155 = new Transaction(preEIP155RLP);
Transaction postEIP155 = new Transaction(postEIP155RLP);
preEIP155.getFrom(null); // Homestead should accept homestead
preEIP155.getFrom(new BigInt(4)); // EIP155 should accept homestead (missing chain ID)
postEIP155.getFrom(new BigInt(4)); // EIP155 should accept EIP 155
try {
postEIP155.getFrom(null);
fail("EIP155 transaction accepted by Homestead");
} catch (Exception e) {}
} catch (Exception e) {
fail(e.toString());
}
}
}
}
`
`
...
...
mobile/types.go
View file @
73227309
...
@@ -264,8 +264,11 @@ func (tx *Transaction) GetHash() *Hash { return &Hash{tx.tx.Hash()} }
...
@@ -264,8 +264,11 @@ func (tx *Transaction) GetHash() *Hash { return &Hash{tx.tx.Hash()} }
func
(
tx
*
Transaction
)
GetSigHash
()
*
Hash
{
return
&
Hash
{
tx
.
tx
.
SigHash
(
types
.
HomesteadSigner
{})}
}
func
(
tx
*
Transaction
)
GetSigHash
()
*
Hash
{
return
&
Hash
{
tx
.
tx
.
SigHash
(
types
.
HomesteadSigner
{})}
}
func
(
tx
*
Transaction
)
GetCost
()
*
BigInt
{
return
&
BigInt
{
tx
.
tx
.
Cost
()}
}
func
(
tx
*
Transaction
)
GetCost
()
*
BigInt
{
return
&
BigInt
{
tx
.
tx
.
Cost
()}
}
func
(
tx
*
Transaction
)
GetFrom
()
(
address
*
Address
,
_
error
)
{
func
(
tx
*
Transaction
)
GetFrom
(
chainID
*
BigInt
)
(
address
*
Address
,
_
error
)
{
from
,
err
:=
types
.
Sender
(
types
.
HomesteadSigner
{},
tx
.
tx
)
if
chainID
==
nil
{
// Null passed from mobile app
chainID
=
new
(
BigInt
)
}
from
,
err
:=
types
.
Sender
(
types
.
NewEIP155Signer
(
chainID
.
bigint
),
tx
.
tx
)
return
&
Address
{
from
},
err
return
&
Address
{
from
},
err
}
}
...
...
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