diff --git a/api.json b/api.json index 771db68..f00f6a6 100644 --- a/api.json +++ b/api.json @@ -120,9 +120,10 @@ "interval": "20m", "daemon": "http://127.0.0.1:8545", "timeout": "10s", - "address": "0x9dd0226060b6d9644066029f4993CB2A40cF775D", + "address": "0xd92fa5a9732a0aec36dc8d5a6a1305dc2d3e09e6", "gas": "21000", "gasPrice": "50000000000", + "maxPriorityFee": "2000000000", "autoGas": true, "threshold": 500000000, "bgsave": false, diff --git a/payouts/payer.go b/payouts/payer.go index 174325d..bb7e230 100644 --- a/payouts/payer.go +++ b/payouts/payer.go @@ -20,15 +20,16 @@ import ( const txCheckInterval = 5 * time.Second type PayoutsConfig struct { - Enabled bool `json:"enabled"` - RequirePeers int64 `json:"requirePeers"` - Interval string `json:"interval"` - Daemon string `json:"daemon"` - Timeout string `json:"timeout"` - Address string `json:"address"` - Gas string `json:"gas"` - GasPrice string `json:"gasPrice"` - AutoGas bool `json:"autoGas"` + Enabled bool `json:"enabled"` + RequirePeers int64 `json:"requirePeers"` + Interval string `json:"interval"` + Daemon string `json:"daemon"` + Timeout string `json:"timeout"` + Address string `json:"address"` + Gas string `json:"gas"` + GasPrice string `json:"gasPrice"` + AutoGas bool `json:"autoGas"` + MaxPriorityFee string `json:"maxPriorityFee"` // In Shannon Threshold int64 `json:"threshold"` BgSave bool `json:"bgsave"` @@ -45,6 +46,11 @@ func (self PayoutsConfig) GasPriceHex() string { return hexutil.EncodeBig(x) } +func (self PayoutsConfig) MaxPriorityFeeHex() string { + x := util.String2Big(self.MaxPriorityFee) + return hexutil.EncodeBig(x) +} + type PayoutsProcessor struct { config *PayoutsConfig backend *storage.RedisClient @@ -179,7 +185,7 @@ func (u *PayoutsProcessor) process() { } value := hexutil.EncodeBig(amountInWei) - txHash, err := u.rpc.SendTransaction(u.config.Address, login, u.config.GasHex(), u.config.GasPriceHex(), value, u.config.AutoGas) + txHash, err := u.rpc.SendTransaction(u.config.Address, login, u.config.GasHex(), u.config.GasPriceHex(), u.config.MaxPriorityFeeHex(), value, u.config.AutoGas) if err != nil { log.Printf("Failed to send payment to %s, %v Shannon: %v. Check outgoing tx for %s in block explorer and docs/PAYOUTS.md", login, amount, err, login) diff --git a/rpc/rpc.go b/rpc/rpc.go index 61eb8f1..a41e7ee 100644 --- a/rpc/rpc.go +++ b/rpc/rpc.go @@ -206,15 +206,20 @@ func (r *RPCClient) GetPeerCount() (int64, error) { return strconv.ParseInt(strings.Replace(reply, "0x", "", -1), 16, 64) } -func (r *RPCClient) SendTransaction(from, to, gas, gasPrice, value string, autoGas bool) (string, error) { +func (r *RPCClient) SendTransaction(from, to, gas, gasPrice, maxPriorityFee, value string, autoGas bool) (string, error) { params := map[string]string{ "from": from, "to": to, "value": value, } if !autoGas { + // Sends as Legacy TX params["gas"] = gas params["gasPrice"] = gasPrice + } else { + // Sends as EIP1559 TX + params["gas"] = gas + params["maxPriorityFeePerGas"] = maxPriorityFee } rpcResp, err := r.doPost(r.Url, "eth_sendTransaction", []interface{}{params}) var reply string