Skip to content

Commit 730376d

Browse files
author
Yunshi Sun
authored
Merge pull request #67 from renproject/release/3.0.11
Fix gas price for withdrawing ETH from the darknode
2 parents 1fbbbca + 1ade641 commit 730376d

File tree

5 files changed

+17
-7
lines changed

5 files changed

+17
-7
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 3.0.11
2+
- Use suggest gas price for withdrawing ETH.
3+
14
## 3.0.10
25
- Improve `update` command to support suffix tags #61
36
- Show darknodes versions when from the `list` command.

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.10
1+
3.0.11

cmd/down.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ func destroyNode(ctx *cli.Context) error {
9797

9898
// Withdraw ETH and REN in the darknode address to the provided receiver address
9999
func withdraw(ctx *cli.Context) error {
100+
// Create a context for the entire withdraw process
101+
c, cancel := context.WithTimeout(context.Background(), 30*time.Second)
102+
defer cancel()
103+
104+
// Parse the input parameters
100105
name := ctx.Args().First()
101106
if err := util.ValidateNodeName(name); err != nil {
102107
return err
@@ -122,11 +127,13 @@ func withdraw(ctx *cli.Context) error {
122127
}
123128

124129
// Create a transactor for ethereum tx
130+
gasPrice, err := client.EthClient().SuggestGasPrice(c)
131+
if err != nil {
132+
return err
133+
}
125134
ethAddr := crypto.PubkeyToAddress(config.Keystore.Ecdsa.PublicKey)
126-
c, cancel := context.WithTimeout(context.Background(), time.Minute)
127-
defer cancel()
128135
auth := bind.NewKeyedTransactor(config.Keystore.Ecdsa.PrivateKey)
129-
auth.GasPrice = big.NewInt(5000000000) // Set GasPrise to 5 Gwei
136+
auth.GasPrice = gasPrice
130137
auth.Context = c
131138

132139
// Check REN balance first
@@ -164,7 +171,7 @@ func withdraw(ctx *cli.Context) error {
164171
if err != nil {
165172
return err
166173
}
167-
gas := ethtypes.Gwei(5 * 21000)
174+
gas := ethtypes.Wei(gasPrice.Uint64() * 21000)
168175
zero := ethtypes.Wei(0)
169176
if balance.Gt(zero) {
170177
if balance.Gt(gas) {

cmd/update.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ systemctl --user restart darknode`, url, ver)
9696
}
9797

9898
func validateVersion(version string) error {
99-
ctx, cancel := context.WithTimeout(context.Background(), 5 *time.Second)
99+
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
100100
defer cancel()
101101

102102
client := github.NewClient(nil)

util/node.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func ValidateTags(have, required string) bool {
167167
// LatestStableRelease checks the darknode release repo and return the version
168168
// of the latest release.
169169
func LatestStableRelease() (string, error) {
170-
ctx, cancel := context.WithTimeout(context.Background(), 5 *time.Second)
170+
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
171171
defer cancel()
172172

173173
client := github.NewClient(nil)

0 commit comments

Comments
 (0)