mirror of
https://github.com/ZmnSCPxj/clboss.git
synced 2026-08-13 12:33:20 +02:00
dev-boltz-api.cpp: Support env-var URL/proxy overrides for non-mainnet testing.
The binary was hardcoded to talk to https://boltz.exchange/api via no proxy, which made it useless for verifying the signet Boltz backend added by the recent boltz_instances cherry-pick. Read two new optional environment variables on startup: BOLTZ_API_BASE URL prefix (default: https://boltz.exchange/api) BOLTZ_PROXY libcurl proxy (e.g. socks5h://127.0.0.1:9050) and pass them through to the Boltz::Connection constructor. No behavior change when neither variable is set, so existing usage continues to hit mainnet Boltz. Tested against signet Boltz via both paths: ./dev-boltz-api /getpairs # mainnet, default BOLTZ_API_BASE=http://127.0.0.1:8080 \ ./dev-boltz-api /getpairs # signet via socat BOLTZ_API_BASE=http://boltz7ck...onion \ BOLTZ_PROXY=socks5h://127.0.0.1:9050 \ ./dev-boltz-api /getpairs # signet direct via Tor
This commit is contained in:
parent
df0ed1147b
commit
8dbde86789
1 changed files with 11 additions and 1 deletions
|
|
@ -5,12 +5,17 @@
|
|||
#include"Jsmn/Object.hpp"
|
||||
#include"Json/Out.hpp"
|
||||
#include"Util/make_unique.hpp"
|
||||
#include<cstdlib>
|
||||
#include<iostream>
|
||||
#include<sstream>
|
||||
#include<string>
|
||||
|
||||
/* argv[1] == /api
|
||||
* argv[2] == JSON
|
||||
*
|
||||
* Environment overrides:
|
||||
* BOLTZ_API_BASE URL prefix (default: https://boltz.exchange/api)
|
||||
* BOLTZ_PROXY libcurl proxy (e.g. socks5h://127.0.0.1:9050)
|
||||
*/
|
||||
int main(int argc, char** argv) {
|
||||
if (argc < 2 || argc > 3) {
|
||||
|
|
@ -31,8 +36,13 @@ int main(int argc, char** argv) {
|
|||
);
|
||||
}
|
||||
|
||||
auto base = std::string("https://boltz.exchange/api");
|
||||
if (auto e = std::getenv("BOLTZ_API_BASE")) base = e;
|
||||
auto proxy = std::string("");
|
||||
if (auto e = std::getenv("BOLTZ_PROXY")) proxy = e;
|
||||
|
||||
Ev::ThreadPool tp;
|
||||
auto cc = Boltz::Connection(tp);
|
||||
auto cc = Boltz::Connection(tp, base, proxy);
|
||||
|
||||
auto code = Ev::lift().then([&]() {
|
||||
return cc.api(api, std::move(json));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue