sideswap-io / sideswapclient

GNU General Public License v3.0
36 stars 9 forks source link

ERROR sideswap_dealer::dealer wallet balance loading failed #33

Closed jomagalo closed 5 months ago

jomagalo commented 6 months ago

I try to play SideSwap dealer example and get the following errors:

cargo run -- config/dealer_example_config.toml
    Finished dev [unoptimized + debuginfo] target(s) in 0.39s
     Running `/home/jomagalo/sideswapclient/rust/target/debug/sideswap_dealer_example config/dealer_example_config.toml`
2024-02-28 17:48:53.239 DEBUG sideswap_common::ws::auto try ws connection...
2024-02-28 17:48:53.244 ERROR sideswap_dealer::dealer wallet balance loading failed: http://127.0.0.1:18891/wallet/: status code 500
2024-02-28 17:48:53.526 DEBUG tungstenite::handshake::client Client handshake done.
2024-02-28 17:48:53.526 DEBUG sideswap_common::ws::auto ws connected
thread '<unnamed>' panicked at sideswap_dealer/src/dealer.rs:1032:18:
list_unspent failed: http://127.0.0.1:18891/wallet/: status code 500
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '2024-02-28 17:48:53.745 INFO sideswap_common::ws::auto terminate ws connection loop
main' panicked at sideswap_dealer_example/src/main.rs:102:36:
called `Result::unwrap()` on an `Err` value: RecvError
cargo --version
cargo 1.76.0 (c84b36747 2024-01-18)
elements-cli -getinfo
Chain: liquidtestnet
Blocks: 1283691
Headers: 1283691
Verification progress: 100.0000%
Difficulty:

Network: in 0, out 6, total 6
Version: 230201
Time offset (s): 1
Proxies: 127.0.0.1:9050 (onion)
Min tx relay fee rate (BTC/kvB): 0.00000100

Wallet: dealer
Keypool size: 999
Transaction fee rate (-paytxfee) (BTC/kvB): 0.00000000

Balance: {"bitcoin":0.00100000}

Warnings:
elements-cli listunspent
[
  {
    "txid": "765d34224ff2ae1cd8ca7a7b652c90b9cc96ff9e35c48333c0317037e7395076",
    "vout": 0,
    "address": "tex1q573fahntw6j8gw98amhkh06s6zxm02m2zzrqqc",
    "label": "",
    "scriptPubKey": "0014a7a29ede6b76a47438a7eeef6bbf50d08db7ab6a",
    "amount": 0.00100000,
    "assetcommitment": "0b87cd48b356e21ebcf8151bd79ecc468a28b95016a82251eee82951783311e746",
    "asset": "144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49",
    "amountcommitment": "08f9a5dd65ab466c3fe25b918692e54dce3216c4f2e1036c4ce317156676ff4b33",
    "amountblinder": "6a4c858e098ae0b47daa06161468daa854bb0ad4514770b5685ae4c071f1c954",
    "assetblinder": "bb9839681d5db602883d5725f6fed73be4d75722cd920b76759fada852bcb3c9",
    "confirmations": 162,
    "spendable": true,
    "solvable": true,
    "desc": "wpkh([680b9505/0'/0'/0']03746d817c42b9d04b741ad09aa51b0e9c2e7337cd8be398e00c612ebb66bb236b)#d8hhj44r",
    "safe": true
  }
]
sideswap-io commented 6 months ago

The dealer expects the default wallet (with an empty name) to be available, and you have a wallet named dealer. Please create a wallet with the empty name first:

elements-cli createwallet ""
bitchad42 commented 5 months ago

We created a patch to make the code support this feature.

From 3a2435cd86f674efd0985e33d30d04ea17d17756 Mon Sep 17 00:00:00 2001
From: bitchad42 <bitchad@email.local>
Date: Thu, 21 Mar 2024 00:57:46 -0300
Subject: [PATCH] support wallet name

---
 rust/sideswap_dealer/src/rpc.rs | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/rust/sideswap_dealer/src/rpc.rs b/rust/sideswap_dealer/src/rpc.rs
index 6fa33f6..4f8301b 100644
--- a/rust/sideswap_dealer/src/rpc.rs
+++ b/rust/sideswap_dealer/src/rpc.rs
@@ -11,6 +11,7 @@ pub struct RpcServer {
     pub port: u16,
     pub login: String,
     pub password: String,
+    pub wallet: String,  // PATCH
 }

 pub trait RpcCall {
@@ -46,10 +47,11 @@ pub fn make_rpc_call<T: RpcCall>(
     trace!("make rpc request: {req}");

     // If two or more wallets are loaded, most RPC calls must include the wallet name in the URL path
-    let wallet_name = "";
+    // let wallet_name = "";  // PATCH
     let endpoint = format!(
         "http://{}:{}/wallet/{}",
-        &rpc_server.host, rpc_server.port, wallet_name
+        // &rpc_server.host, rpc_server.port, wallet_name  // PATCH
+        &rpc_server.host, rpc_server.port, rpc_server.wallet  // PATCH
     );

     let encoded_credentials = base64::engine::general_purpose::STANDARD
-- 
2.39.2

Of course the value would need to be made optional, which seems trivial.

sideswap-io commented 5 months ago

Patch merged (with minor modifications), thanks.