diff --git a/protocol/backend/backend.go b/protocol/backend/backend.go index 7407c2cd..a8e28aba 100644 --- a/protocol/backend/backend.go +++ b/protocol/backend/backend.go @@ -160,7 +160,7 @@ func NewBackend(cfg *Config) (Backend, error) { } else { log.Debugf("instantiated backend with external sender") var err error - sender, err = txsender.NewExternalSender(cfg.Ctx, cfg.EthereumClient, cfg.SwapContractAddress) + sender, err = txsender.NewExternalSender(cfg.Ctx, cfg.Environment, cfg.EthereumClient, cfg.SwapContractAddress) if err != nil { return nil, err } diff --git a/protocol/txsender/external_sender.go b/protocol/txsender/external_sender.go index ac604b75..7ef005e9 100644 --- a/protocol/txsender/external_sender.go +++ b/protocol/txsender/external_sender.go @@ -22,7 +22,7 @@ var ( errTransactionTimeout = errors.New("timed out waiting for transaction to be signed") errNoSwapWithID = errors.New("no swap with given id") - transactionTimeout = time.Minute * 2 // arbitrary, TODO vary this based on env + transactionTimeout = time.Minute * 2 // amount of time user has to sign message ) // Transaction represents a transaction to be signed by the front-end @@ -52,13 +52,18 @@ type ExternalSender struct { } // NewExternalSender returns a new ExternalSender -func NewExternalSender(ctx context.Context, ec *ethclient.Client, +func NewExternalSender(ctx context.Context, env common.Environment, ec *ethclient.Client, contractAddr ethcommon.Address) (*ExternalSender, error) { abi, err := swapfactory.SwapFactoryMetaData.GetAbi() if err != nil { return nil, err } + switch env { + case common.Mainnet, common.Stagenet: + transactionTimeout = time.Hour + } + return &ExternalSender{ ctx: ctx, ec: ec, diff --git a/protocol/xmrtaker/swap_state.go b/protocol/xmrtaker/swap_state.go index 4ef11781..c0156452 100644 --- a/protocol/xmrtaker/swap_state.go +++ b/protocol/xmrtaker/swap_state.go @@ -315,7 +315,7 @@ func (s *swapState) tryRefund() (ethcommon.Hash, error) { log.Debugf("tryRefund isReady=%v untilT0=%vs untilT1=%vs", isReady, untilT0.Seconds(), untilT1.Seconds()) - if (untilT0 > 0 || isReady) && untilT1 > 0 { + if (untilT0 > 0 && isReady) && untilT1 > 0 { // we've passed t0 but aren't past t1 yet, so we need to wait until t1 log.Infof("waiting until time %s to refund", s.t1) <-time.After(untilT1) diff --git a/rpc/ws.go b/rpc/ws.go index 9dfd1294..924c18f8 100644 --- a/rpc/ws.go +++ b/rpc/ws.go @@ -194,8 +194,7 @@ func (s *wsServer) handleSigner(ctx context.Context, conn *websocket.Conn, offer for { select { // TODO: check if conn closes or swap exited - case <-time.After(time.Minute): // TODO: vary timeout based on env - _ = conn.Close() + case <-time.After(time.Hour): // TODO: vary timeout based on env return fmt.Errorf("signer timed out") case <-ctx.Done(): return nil diff --git a/scripts/setup-stagenet.sh b/scripts/setup-stagenet.sh index daef06a6..8e074d6e 100644 --- a/scripts/setup-stagenet.sh +++ b/scripts/setup-stagenet.sh @@ -2,14 +2,14 @@ bash ./scripts/install-monero-linux.sh echo "starting monerod..." -./monero-x86_64-linux-gnu-v0.17.3.2/monerod --detach --stagenet --rpc-bind-port 18081 & +nohup ./monero-x86_64-linux-gnu-v0.17.3.2/monerod --detach --stagenet --rpc-bind-port 18081 & sleep 5 echo "starting monero-wallet-rpc on port 18083..." -./monero-x86_64-linux-gnu-v0.17.3.2/monero-wallet-rpc --rpc-bind-port 18083 --disable-rpc-login --wallet-dir ./bob-test-keys --stagenet --trusted-daemon +nohup ./monero-x86_64-linux-gnu-v0.17.3.2/monero-wallet-rpc --rpc-bind-port 18083 --disable-rpc-login --wallet-dir ./bob-test-keys --stagenet --trusted-daemon echo "starting monero-wallet-rpc on port 18084..." -./monero-x86_64-linux-gnu-v0.17.3.2/monero-wallet-rpc --rpc-bind-port 18084 --disable-rpc-login --wallet-dir ./alice-test-keys --stagenet --trusted-daemon +nohup ./monero-x86_64-linux-gnu-v0.17.3.2/monero-wallet-rpc --rpc-bind-port 18084 --disable-rpc-login --wallet-dir ./alice-test-keys --stagenet --trusted-daemon # open Bob's wallet (must have funds) sleep 5 @@ -19,4 +19,4 @@ curl http://localhost:18083/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"ope curl http://localhost:18083/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":get_accounts","params":{}}' -H 'Content-Type: application/json' # start mining (if synced) -# curl http://localhost:18083/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":start_mining","params":{"threads_count":1,"do_background_mining":true,"ignore_battery":false}}' -H 'Content-Type: application/json' \ No newline at end of file +# curl http://localhost:18083/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":start_mining","params":{"threads_count":1,"do_background_mining":true,"ignore_battery":false}}' -H 'Content-Type: application/json' diff --git a/ui/src/App.svelte b/ui/src/App.svelte index 8a9da891..438bbc05 100644 --- a/ui/src/App.svelte +++ b/ui/src/App.svelte @@ -22,6 +22,10 @@ + + + +
@@ -34,7 +38,7 @@ {#if $currentAccount} - Account: {$currentAccount} + {:else} {/if}