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
67da83ac
Unverified
Commit
67da83ac
authored
Apr 21, 2021
by
Martin Holst Swende
Committed by
GitHub
Apr 21, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accounts/external, signer/core: add support for EIP-2930 transactions (#22585)
This adds support for signing EIP-2930 with clef.
parent
4b783c00
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
3 deletions
+65
-3
backend.go
accounts/external/backend.go
+14
-0
api.go
signer/core/api.go
+8
-0
cliui.go
signer/core/cliui.go
+12
-0
types.go
signer/core/types.go
+31
-3
No files found.
accounts/external/backend.go
View file @
67da83ac
...
@@ -212,6 +212,20 @@ func (api *ExternalSigner) SignTx(account accounts.Account, tx *types.Transactio
...
@@ -212,6 +212,20 @@ func (api *ExternalSigner) SignTx(account accounts.Account, tx *types.Transactio
To
:
to
,
To
:
to
,
From
:
common
.
NewMixedcaseAddress
(
account
.
Address
),
From
:
common
.
NewMixedcaseAddress
(
account
.
Address
),
}
}
// We should request the default chain id that we're operating with
// (the chain we're executing on)
if
chainID
!=
nil
{
args
.
ChainID
=
(
*
hexutil
.
Big
)(
chainID
)
}
// However, if the user asked for a particular chain id, then we should
// use that instead.
if
tx
.
Type
()
!=
types
.
LegacyTxType
&&
tx
.
ChainId
()
!=
nil
{
args
.
ChainID
=
(
*
hexutil
.
Big
)(
tx
.
ChainId
())
}
if
tx
.
Type
()
==
types
.
AccessListTxType
{
accessList
:=
tx
.
AccessList
()
args
.
AccessList
=
&
accessList
}
var
res
signTransactionResult
var
res
signTransactionResult
if
err
:=
api
.
client
.
Call
(
&
res
,
"account_signTransaction"
,
args
);
err
!=
nil
{
if
err
:=
api
.
client
.
Call
(
&
res
,
"account_signTransaction"
,
args
);
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
...
signer/core/api.go
View file @
67da83ac
...
@@ -534,6 +534,14 @@ func (api *SignerAPI) SignTransaction(ctx context.Context, args SendTxArgs, meth
...
@@ -534,6 +534,14 @@ func (api *SignerAPI) SignTransaction(ctx context.Context, args SendTxArgs, meth
return
nil
,
err
return
nil
,
err
}
}
}
}
if
args
.
ChainID
!=
nil
{
requestedChainId
:=
(
*
big
.
Int
)(
args
.
ChainID
)
if
api
.
chainID
.
Cmp
(
requestedChainId
)
!=
0
{
log
.
Error
(
"Signing request with wrong chain id"
,
"requested"
,
requestedChainId
,
"configured"
,
api
.
chainID
)
return
nil
,
fmt
.
Errorf
(
"requested chainid %d does not match the configuration of the signer"
,
requestedChainId
)
}
}
req
:=
SignTxRequest
{
req
:=
SignTxRequest
{
Transaction
:
args
,
Transaction
:
args
,
Meta
:
MetadataFromContext
(
ctx
),
Meta
:
MetadataFromContext
(
ctx
),
...
...
signer/core/cliui.go
View file @
67da83ac
...
@@ -118,6 +118,18 @@ func (ui *CommandlineUI) ApproveTx(request *SignTxRequest) (SignTxResponse, erro
...
@@ -118,6 +118,18 @@ func (ui *CommandlineUI) ApproveTx(request *SignTxRequest) (SignTxResponse, erro
fmt
.
Printf
(
"gas: %v (%v)
\n
"
,
request
.
Transaction
.
Gas
,
uint64
(
request
.
Transaction
.
Gas
))
fmt
.
Printf
(
"gas: %v (%v)
\n
"
,
request
.
Transaction
.
Gas
,
uint64
(
request
.
Transaction
.
Gas
))
fmt
.
Printf
(
"gasprice: %v wei
\n
"
,
request
.
Transaction
.
GasPrice
.
ToInt
())
fmt
.
Printf
(
"gasprice: %v wei
\n
"
,
request
.
Transaction
.
GasPrice
.
ToInt
())
fmt
.
Printf
(
"nonce: %v (%v)
\n
"
,
request
.
Transaction
.
Nonce
,
uint64
(
request
.
Transaction
.
Nonce
))
fmt
.
Printf
(
"nonce: %v (%v)
\n
"
,
request
.
Transaction
.
Nonce
,
uint64
(
request
.
Transaction
.
Nonce
))
if
chainId
:=
request
.
Transaction
.
ChainID
;
chainId
!=
nil
{
fmt
.
Printf
(
"chainid: %v
\n
"
,
chainId
)
}
if
list
:=
request
.
Transaction
.
AccessList
;
list
!=
nil
{
fmt
.
Printf
(
"Accesslist
\n
"
)
for
i
,
el
:=
range
*
list
{
fmt
.
Printf
(
" %d. %v
\n
"
,
i
,
el
.
Address
)
for
j
,
slot
:=
range
el
.
StorageKeys
{
fmt
.
Printf
(
" %d. %v
\n
"
,
j
,
slot
)
}
}
}
if
request
.
Transaction
.
Data
!=
nil
{
if
request
.
Transaction
.
Data
!=
nil
{
d
:=
*
request
.
Transaction
.
Data
d
:=
*
request
.
Transaction
.
Data
if
len
(
d
)
>
0
{
if
len
(
d
)
>
0
{
...
...
signer/core/types.go
View file @
67da83ac
...
@@ -76,6 +76,10 @@ type SendTxArgs struct {
...
@@ -76,6 +76,10 @@ type SendTxArgs struct {
// We accept "data" and "input" for backwards-compatibility reasons.
// We accept "data" and "input" for backwards-compatibility reasons.
Data
*
hexutil
.
Bytes
`json:"data"`
Data
*
hexutil
.
Bytes
`json:"data"`
Input
*
hexutil
.
Bytes
`json:"input,omitempty"`
Input
*
hexutil
.
Bytes
`json:"input,omitempty"`
// For non-legacy transactions
AccessList
*
types
.
AccessList
`json:"accessList,omitempty"`
ChainID
*
hexutil
.
Big
`json:"chainId,omitempty"`
}
}
func
(
args
SendTxArgs
)
String
()
string
{
func
(
args
SendTxArgs
)
String
()
string
{
...
@@ -93,8 +97,32 @@ func (args *SendTxArgs) toTransaction() *types.Transaction {
...
@@ -93,8 +97,32 @@ func (args *SendTxArgs) toTransaction() *types.Transaction {
}
else
if
args
.
Input
!=
nil
{
}
else
if
args
.
Input
!=
nil
{
input
=
*
args
.
Input
input
=
*
args
.
Input
}
}
if
args
.
To
==
nil
{
var
to
*
common
.
Address
return
types
.
NewContractCreation
(
uint64
(
args
.
Nonce
),
(
*
big
.
Int
)(
&
args
.
Value
),
uint64
(
args
.
Gas
),
(
*
big
.
Int
)(
&
args
.
GasPrice
),
input
)
if
args
.
To
!=
nil
{
_to
:=
args
.
To
.
Address
()
to
=
&
_to
}
var
data
types
.
TxData
if
args
.
AccessList
==
nil
{
data
=
&
types
.
LegacyTx
{
To
:
to
,
Nonce
:
uint64
(
args
.
Nonce
),
Gas
:
uint64
(
args
.
Gas
),
GasPrice
:
(
*
big
.
Int
)(
&
args
.
GasPrice
),
Value
:
(
*
big
.
Int
)(
&
args
.
Value
),
Data
:
input
,
}
}
else
{
data
=
&
types
.
AccessListTx
{
To
:
to
,
ChainID
:
(
*
big
.
Int
)(
args
.
ChainID
),
Nonce
:
uint64
(
args
.
Nonce
),
Gas
:
uint64
(
args
.
Gas
),
GasPrice
:
(
*
big
.
Int
)(
&
args
.
GasPrice
),
Value
:
(
*
big
.
Int
)(
&
args
.
Value
),
Data
:
input
,
AccessList
:
*
args
.
AccessList
,
}
}
}
return
types
.
NewT
ransaction
(
uint64
(
args
.
Nonce
),
args
.
To
.
Address
(),
(
*
big
.
Int
)(
&
args
.
Value
),
(
uint64
)(
args
.
Gas
),
(
*
big
.
Int
)(
&
args
.
GasPrice
),
input
)
return
types
.
NewT
x
(
data
)
}
}
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