diff --git a/protocol/txsender/external_sender.go b/protocol/txsender/external_sender.go
index 9fad024b..ac604b75 100644
--- a/protocol/txsender/external_sender.go
+++ b/protocol/txsender/external_sender.go
@@ -104,7 +104,7 @@ func (s *ExternalSender) AddID(id types.Hash) {
s.Lock()
defer s.Unlock()
_, has := s.swaps[id]
- if !has {
+ if has {
return
}
diff --git a/rpc/net.go b/rpc/net.go
index a2491079..19036290 100644
--- a/rpc/net.go
+++ b/rpc/net.go
@@ -3,6 +3,7 @@ package rpc
import (
"fmt"
"net/http"
+ "strings"
"time"
"github.com/noot/atomic-swap/common"
@@ -132,7 +133,7 @@ func (s *NetService) takeOffer(multiaddr, offerID string,
offer *types.Offer
)
for _, maybeOffer := range queryResp.Offers {
- if maybeOffer.GetID().String() == offerID {
+ if strings.Compare(maybeOffer.GetID().String(), offerID) == 0 {
found = true
offer = maybeOffer
break
@@ -145,7 +146,7 @@ func (s *NetService) takeOffer(multiaddr, offerID string,
swapState, err := s.xmrtaker.InitiateProtocol(providesAmount, offer)
if err != nil {
- return nil, "", err
+ return nil, "", fmt.Errorf("failed to initiate protocol: %w", err)
}
skm, err := swapState.SendKeysMessage()
diff --git a/rpc/ws.go b/rpc/ws.go
index c90f5d2a..9dfd1294 100644
--- a/rpc/ws.go
+++ b/rpc/ws.go
@@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"net/http"
+ "time"
"github.com/noot/atomic-swap/common/rpctypes"
"github.com/noot/atomic-swap/common/types"
@@ -192,6 +193,10 @@ 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()
+ return fmt.Errorf("signer timed out")
case <-ctx.Done():
return nil
case tx := <-txsOutCh:
diff --git a/scripts/setup-devnet.sh b/scripts/setup-devnet.sh
index e67f45ca..c5273026 100755
--- a/scripts/setup-devnet.sh
+++ b/scripts/setup-devnet.sh
@@ -4,7 +4,7 @@
MONERO_DIR="../monero-x86_64-linux-gnu-v0.17.3.0"
# either a TMPDIR is set, or use /tmp
LOG_DIR=${TMPDIR:-"/tmp"}
-ALICE_P2P_ADDRESS="12D3KooWF5dTdfrVv6oFwGGGyobfxtZBVhVR654wt5ED6PU1SBqd"
+ALICE_P2P_ADDRESS="12D3KooWBD82zGTFqk6Qmu5zeS6dQfiaAcn8go2QWE29HPmRX3yB"
echo "cleanup"
pkill -e -f monero;
@@ -25,7 +25,7 @@ echo "Zzz... 10s"
sleep 10
echo "mine blocks for XMRMaker"
-curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"generateblocks","params":{"wallet_address":"45GcPCBQgCG3tYcYqLdj4iQixpDZYw1MGew4PH1rthp9X2YrB2c2dty1r7SwhbCXw1RJMvfy8cW1UXyeESTAuLkV5bTrZRe","amount_of_blocks":100}' -H 'Content-Type: application/json' &> $LOG_DIR/block-mining-bob.log &
+curl -X POST http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"generateblocks","params":{"wallet_address":"43wote1FPHrQQL35p3LMbNGi4J6zLcwUF9EZiw2xKfyzbQVhFXQ3VcmFuM4RDK7gxh8FGgN2C3ssXcSeJR2wY2Gx92b5gxn","amount_of_blocks":100}' -H 'Content-Type: application/json' &> $LOG_DIR/block-mining-bob.log &
echo "Zzz... 15s"
sleep 15
@@ -37,7 +37,7 @@ echo "start monero-wallet-rpc for XMRMaker on port 18083"
./monero-wallet-rpc --rpc-bind-port 18083 --password "" --disable-rpc-login --wallet-dir . &> $LOG_DIR/bob-wallet-rpc.log &
echo "launch XMRTaker swapd"
-../swapd --dev-xmrtaker &> $LOG_DIR/alice-swapd.log &
+../swapd --dev-xmrtaker --external-signer --contract-address 0xe78A0F7E598Cc8b0Bb87894B0F60dD2a88d6a8Ab &> $LOG_DIR/alice-swapd.log &
echo "Zzz... 10s"
sleep 10
diff --git a/scripts/setup-env.sh b/scripts/setup-env.sh
index 26e61257..2944ef94 100755
--- a/scripts/setup-env.sh
+++ b/scripts/setup-env.sh
@@ -3,12 +3,12 @@
# install monero and run daemon and wallet RPC servers for alice and bob
bash ./scripts/install-monero-linux.sh
echo "starting monerod..."
-./monero-x86_64-linux-gnu-v0.17.3.2/monerod --detach --regtest --offline --fixed-difficulty=1 --rpc-bind-port 18081 &
+./monero-x86_64-linux-gnu-v0.17.3.0/monerod --detach --regtest --offline --fixed-difficulty=1 --rpc-bind-port 18081 --keep-fakechain &
sleep 5
echo "starting monero-wallet-rpc on port 18083..."
mkdir bob-test-keys
-./monero-x86_64-linux-gnu-v0.17.3.2/monero-wallet-rpc --rpc-bind-port 18083 --disable-rpc-login --wallet-dir ./bob-test-keys &> monero-wallet-cli-bob.log &
+./monero-x86_64-linux-gnu-v0.17.3.0/monero-wallet-rpc --rpc-bind-port 18083 --disable-rpc-login --wallet-dir ./bob-test-keys &> monero-wallet-cli-bob.log &
MONERO_WALLET_CLI_BOB_PID=$!
sleep 5
@@ -16,7 +16,7 @@ curl http://localhost:18083/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"cre
echo "starting monero-wallet-rpc on port 18084..."
mkdir alice-test-keys
-./monero-x86_64-linux-gnu-v0.17.3.2/monero-wallet-rpc --rpc-bind-port 18084 --disable-rpc-login --wallet-dir ./alice-test-keys &> monero-wallet-cli-alice.log &
+./monero-x86_64-linux-gnu-v0.17.3.0/monero-wallet-rpc --rpc-bind-port 18084 --disable-rpc-login --wallet-dir ./alice-test-keys &> monero-wallet-cli-alice.log &
MONERO_WALLET_CLI_ALICE_PID=$!
# install ganache and run
diff --git a/testerconfig.json b/testerconfig.json
index de19c0b9..fed6da6f 100644
--- a/testerconfig.json
+++ b/testerconfig.json
@@ -1,4 +1,5 @@
[
"ws://localhost:8081",
- "ws://localhost:8082"
+ "ws://localhost:8082",
+ "ws://localhost:8080"
]
\ No newline at end of file
diff --git a/ui/rollup.config.js b/ui/rollup.config.js
index 18d72a35..f79789f6 100644
--- a/ui/rollup.config.js
+++ b/ui/rollup.config.js
@@ -45,7 +45,7 @@ export default {
},
plugins: [
json({
- compact: true
+ compact: true,
}),
svelte({
preprocess: sveltePreprocess({ sourceMap: !production }),
diff --git a/ui/src/App.svelte b/ui/src/App.svelte
index dc9f4c3a..8a9da891 100644
--- a/ui/src/App.svelte
+++ b/ui/src/App.svelte
@@ -13,11 +13,8 @@
getPeers()
}
- let account = null;
-
const connectMetamask = () => {
connectAccount()
- account = $currentAccount
}
@@ -36,7 +33,11 @@
|
-
+ {#if $currentAccount}
+ Account: {$currentAccount}
+ {:else}
+
+ {/if}
|
diff --git a/ui/src/components/TakeDealDialog.svelte b/ui/src/components/TakeDealDialog.svelte
index d51faa33..80aa1d28 100644
--- a/ui/src/components/TakeDealDialog.svelte
+++ b/ui/src/components/TakeDealDialog.svelte
@@ -1,6 +1,7 @@