haveno-dex / haveno

Decentralized P2P exchange platform built on Monero and Tor
https://haveno.exchange
GNU Affero General Public License v3.0
987 stars 109 forks source link

get network details from file #911

Open chefnaphtha opened 4 months ago

chefnaphtha commented 4 months ago

i think haveno should get the network details from a json (or other) file, at some point an ui for this would be nice

the network operators would release the network json file, which will then be downloaded by people that want to connect to that network and loaded into the main haveno app

right now the way its done is to fork the app and hardcode the network details into the code, then build that separately. i think it's a waste of computing resources and a security risk (people running random binaries off the internet), not to mention it's simply inefficient to have a completely separate binary for every single network when only a few vars need to change

the variables that would need to be loaded from the json file (and un-hardcoded) are:

arbitrator public keys (string[]): https://github.com/haveno-dex/haveno/commit/946a80f5168342ecec578431d42354bfe88b652f https://github.com/haveno-dex/haveno/commit/a22c9035efd53de41fe8e3e52a774ab58d756794 https://github.com/haveno-dex/haveno/commit/4ecfe15714b3093b8711fa3e659f94a5b19259ec

fees (object?) https://github.com/haveno-dex/haveno/commit/e532f2ddc6e606430c97bcfff9bcf0514ed0d755

seednodes (string[]) (this is hardcoded into a file, code that reads that file needs to be updated) https://github.com/haveno-dex/haveno/commit/14486131830980cc14c48997495bf4f3e560e399

xmr network (mainnet/stagenet/testnet) (string) (this is in package.gradle, same as above) https://github.com/haveno-dex/haveno/commit/58ffc9a5f22816c77733813ef103f1403c5a15f5

my proposed config file example would look something like this:

{
  "xmrNetwork": "mainnet",
  "arbitratorKeys": [
    "029da09bc04dea33cd11a31bc1c05aa830b9180acb84e5370ee7fde60cae9f3d03",
    "02834de139c2767cd11f000f8ea71a3e168fec81132850a4a2cce65385da57a98a"
  ],
  "fees": {
    "arbitratorAssignsTradeFeeAddress": true, // maybe should be shortened? not sure what this does exactly
    "ratios": { // in the code, this is percentages
      "maker": 0.005, // but this is 0.5%, not 0.005%, so ratios is more accurate imo
      "taker": 0.001,
      "penalty": 0.02
    }
  },
  "seedNodes": [
    "gq2reknmxhmf3lnakkyzflr72kbtkpueui7utk3w7qfziuesbjsnkayd.onion:1002 (@anon1)",
    "bugc27z7lqjgpwmhbuu3kuwoq2bhailj573r32jm5ydwrcqrwjtblnid.onion:1002 (@anon2)",
    "c66xsfwbequrnytwlp7cz7oirs6q4grxmqyny7afuvc6r4e3cn2ynoqd.onion:1003 (@anon1)"
  ]
}
chefnaphtha commented 4 months ago

also the haveno folder in the home dir being global and not per-network should probably be fixed before this is released but a separate issue for that is probably best

monerobull commented 4 months ago

There should be some warning about the importance of the files integrity, otherwise scammers could ask people to add their own nodes/arbitrators to it to my understanding put them on an orderbook where every single offer is made and arbitrated by the scammer, allowing them to drain any trade. Maybe also some mechanism to check the integrity against existing networks like a hash of the file and a big warning if it doesn't match.