diff --git a/client/asset/eth/eth.go b/client/asset/eth/eth.go
index e3e38b44b4..431f6ae4e4 100644
--- a/client/asset/eth/eth.go
+++ b/client/asset/eth/eth.go
@@ -368,7 +368,8 @@ type monitoredTx struct {
// replacedTx could be set when the tx is created, be immutable, and not
// need the mutex, but since Redeem doesn't know if the transaction is a
// replacement or a new one, this variable is set in recordReplacementTx.
- replacedTx *common.Hash
+ replacedTx *common.Hash
+ errorsBroadcasted uint16
}
// MarshalBinary marshals a monitoredTx into a byte array.
@@ -3235,8 +3236,13 @@ func (w *assetWallet) SwapConfirmations(ctx context.Context, coinID dex.Bytes, c
}
spent = swapData.State >= dexeth.SSRedeemed
- confs = uint32(hdr.Number.Uint64() - swapData.BlockHeight + 1)
-
+ tip := hdr.Number.Uint64()
+ // TODO: If tip < swapData.BlockHeight (which has been observed), what does
+ // that mean? Are we using the wrong provider in a multi-provider setup? How
+ // do we resolve provider relevance?
+ if tip >= swapData.BlockHeight {
+ confs = uint32(hdr.Number.Uint64() - swapData.BlockHeight + 1)
+ }
return
}
@@ -3763,6 +3769,8 @@ func (w *assetWallet) resubmitRedemption(tx *types.Transaction, contractVersion
var replacementHash common.Hash
copy(replacementHash[:], txs[0])
+ w.log.Infof("Redemption transaction %s was broadcast to replace transaction %s (original tx: %s)", replacementHash, monitoredTx.tx.Hash(), tx.Hash())
+
if monitoredTx != nil {
err = w.recordReplacementTx(monitoredTx, replacementHash)
if err != nil {
@@ -4041,11 +4049,27 @@ func (w *assetWallet) confirmRedemption(coinID dex.Bytes, redemption *asset.Rede
w.clearMonitoredTx(monitoredTx)
return confStatus(txConfsNeededToConfirm, txHash), nil
}
- replacementTxHash, err := w.resubmitRedemption(tx, contractVer, nil, feeWallet, monitoredTx)
- if err != nil {
- return nil, err
+
+ w.log.Errorf("Redemption transaction rejected!!! Tx %s failed to redeem %s funds", tx.Hash(), dex.BipIDSymbol(w.assetID))
+ // Only broadcast a single replacement before giving up.
+ if monitoredTx.replacedTx == nil {
+ w.log.Infof("Attempting to resubmit a %s redemption with secret hash %s", dex.BipIDSymbol(w.assetID), hex.EncodeToString(secretHash[:]))
+ replacementTxHash, err := w.resubmitRedemption(tx, contractVer, nil, feeWallet, monitoredTx)
+ if err != nil {
+ return nil, err
+ }
+ return confStatus(0, *replacementTxHash), nil
}
- return confStatus(0, *replacementTxHash), nil
+ // We've failed to redeem twice. We can't keep broadcasting txs into the
+ // void. We have to give up. Print a bunch of errors and then report
+ // the redemption as confirmed so we'll stop following it.
+ if monitoredTx.errorsBroadcasted < 100 {
+ monitoredTx.errorsBroadcasted++
+ return nil, fmt.Errorf("failed to redeem %s swap with secret hash %s twice. not trying again",
+ dex.BipIDSymbol(w.assetID), hex.EncodeToString(secretHash[:]))
+ }
+ const aTonOfFakeConfs = 1e3
+ return confStatus(aTonOfFakeConfs, txHash), nil
}
if confirmations > 0 {
return confStatus(confirmations, txHash), nil
@@ -4637,10 +4661,9 @@ func getFileCredentials(chain, path string, net dex.Network) (seed []byte, provi
}
seed = p.Seed
for _, uri := range p.Providers[chain][net.String()] {
- if strings.HasPrefix(uri, "#") || strings.HasPrefix(uri, ";") {
- continue
+ if !strings.HasPrefix(uri, "#") && !strings.HasPrefix(uri, ";") {
+ providers = append(providers, uri)
}
- providers = append(providers, uri)
}
if net == dex.Simnet && len(providers) == 0 {
u, _ := user.Current()
@@ -5319,7 +5342,7 @@ func getGasEstimates(ctx context.Context, cl, acl ethFetcher, c contractor, ac t
copy(randomAddr[:], encode.RandomBytes(20))
transferTx, err := tc.transfer(txOpts, randomAddr, big.NewInt(1))
if err != nil {
- return fmt.Errorf("error estimating transfer gas: %w", err)
+ return fmt.Errorf("transfer error: %w", err)
}
if err = waitForConfirmation(ctx, cl, transferTx.Hash()); err != nil {
return fmt.Errorf("error waiting for transfer tx: %w", err)
diff --git a/client/asset/polygon/polygon.go b/client/asset/polygon/polygon.go
index cd78a5dc9a..809e0c3506 100644
--- a/client/asset/polygon/polygon.go
+++ b/client/asset/polygon/polygon.go
@@ -30,6 +30,8 @@ func init() {
asset.Register(BipID, &Driver{})
registerToken(simnetTokenID, "A token wallet for the DEX test token. Used for testing DEX software.", dex.Simnet)
registerToken(usdcTokenID, "The USDC Ethereum ERC20 token.", dex.Mainnet, dex.Testnet)
+ registerToken(wbtcTokenID, "Wrapped BTC.", dex.Mainnet)
+ registerToken(wethTokenID, "Wrapped ETH.", dex.Mainnet)
}
const (
@@ -43,6 +45,8 @@ const (
var (
simnetTokenID, _ = dex.BipSymbolID("dextt.polygon")
usdcTokenID, _ = dex.BipSymbolID("usdc.polygon")
+ wethTokenID, _ = dex.BipSymbolID("weth.polygon")
+ wbtcTokenID, _ = dex.BipSymbolID("wbtc.polygon")
// WalletInfo defines some general information about a Polygon Wallet(EVM
// Compatible).
diff --git a/client/webserver/site/src/html/bodybuilder.tmpl b/client/webserver/site/src/html/bodybuilder.tmpl
index d50ce4f641..865f54d0e0 100644
--- a/client/webserver/site/src/html/bodybuilder.tmpl
+++ b/client/webserver/site/src/html/bodybuilder.tmpl
@@ -103,7 +103,7 @@
{{end}}
{{define "bottom"}}
-
+