Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/ethapi: default to 0x00-account instead of local accounts for calls #20702

Merged
merged 2 commits into from
Feb 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 6 additions & 18 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,17 +764,13 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
if state == nil || err != nil {
return nil, 0, false, err
}
// Set sender address or use a default if none specified

// Set sender address or use zero address if none specified.
var addr common.Address
if args.From == nil {
if wallets := b.AccountManager().Wallets(); len(wallets) > 0 {
if accounts := wallets[0].Accounts(); len(accounts) > 0 {
addr = accounts[0].Address
}
}
} else {
if args.From != nil {
addr = *args.From
}

// Override the fields of specified contracts before execution.
for addr, account := range overrides {
// Override account nonce.
Expand Down Expand Up @@ -906,17 +902,9 @@ func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash
}
cap = hi

// Set sender address or use a default if none specified
if args.From == nil {
if wallets := b.AccountManager().Wallets(); len(wallets) > 0 {
if accounts := wallets[0].Accounts(); len(accounts) > 0 {
args.From = &accounts[0].Address
}
}
}
// Use zero-address if none other is available
// Use zero address if sender unspecified.
if args.From == nil {
args.From = &common.Address{}
args.From = new(common.Address)
}
// Create a helper to check if a gas allowance results in an executable transaction
executable := func(gas uint64) bool {
Expand Down