mirror of
https://github.com/RoboSats/robosats.git
synced 2025-07-18 00:33:15 +00:00
Fix nodeapp nostr relay
This commit is contained in:
@ -8,6 +8,7 @@ import {
|
||||
FederationContext,
|
||||
type UseFederationStoreType,
|
||||
} from '../../../contexts/FederationContext';
|
||||
import { AppContext, UseAppStoreType } from '../../../contexts/AppContext';
|
||||
|
||||
interface Props {
|
||||
order: Order;
|
||||
@ -42,13 +43,16 @@ const EncryptedChat: React.FC<Props> = ({
|
||||
status,
|
||||
}: Props): React.JSX.Element => {
|
||||
const [turtleMode, setTurtleMode] = useState<boolean>(false);
|
||||
const { hostUrl, settings } = useContext<UseAppStoreType>(AppContext);
|
||||
const { garage } = useContext<UseGarageStoreType>(GarageContext);
|
||||
const { federation } = useContext<UseFederationStoreType>(FederationContext);
|
||||
|
||||
useEffect(() => {
|
||||
// const slot = garage.getSlot();
|
||||
const coordinator = federation.getCoordinator(order.shortAlias);
|
||||
federation.roboPool.connect([coordinator.getRelayUrl()]);
|
||||
federation.roboPool.connect([
|
||||
coordinator.getRelayUrl(settings.network, hostUrl, settings.selfhostedClient),
|
||||
]);
|
||||
|
||||
// const since = new Date(order.created_at);
|
||||
// since.setDate(since.getDate() - 2);
|
||||
@ -79,7 +83,7 @@ const EncryptedChat: React.FC<Props> = ({
|
||||
|
||||
const recipient = {
|
||||
publicKey: order.is_maker ? order.taker_nostr_pubkey : order.maker_nostr_pubkey,
|
||||
relayUrl: coordinator.getRelayUrl(),
|
||||
relayUrl: coordinator.getRelayUrl(settings.network, hostUrl, settings.selfhostedClient),
|
||||
};
|
||||
|
||||
const wrappedEvent = nip17.wrapEvent(slot?.nostrSecKey, recipient, content);
|
||||
|
@ -304,8 +304,12 @@ export class Coordinator {
|
||||
}
|
||||
};
|
||||
|
||||
getRelayUrl = (): string => {
|
||||
return `ws://${this.url.replace(/^https?:\/\//, '')}/nostr`;
|
||||
getRelayUrl = (network: 'mainnet' | 'testnet', hostUrl: string, selfHosted: boolean): string => {
|
||||
if (selfHosted && this.shortAlias !== 'local') {
|
||||
return `ws://${hostUrl.replace(/^https?:\/\//, '')}/${network}/${this.shortAlias}/relay`;
|
||||
} else {
|
||||
return `ws://${this.url.replace(/^https?:\/\//, '')}/relay`;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ export class Federation {
|
||||
if (tesnetHost) settings.network = 'testnet';
|
||||
this.connection = null;
|
||||
|
||||
this.roboPool = new RoboPool(settings, Object.values(this.coordinators));
|
||||
this.roboPool = new RoboPool(settings, hostUrl, Object.values(this.coordinators));
|
||||
}
|
||||
|
||||
private coordinators: Record<string, Coordinator>;
|
||||
@ -163,8 +163,13 @@ export class Federation {
|
||||
updateUrl = async (origin: Origin, settings: Settings, hostUrl: string): Promise<void> => {
|
||||
const federationUrls = {};
|
||||
for (const coor of Object.values(this.coordinators)) {
|
||||
coor.updateUrl(origin, settings, hostUrl);
|
||||
federationUrls[coor.shortAlias] = coor.url;
|
||||
const { url, basePath } = coor.getEndpoint(
|
||||
settings.network,
|
||||
origin,
|
||||
settings.selfhostedClient,
|
||||
hostUrl,
|
||||
);
|
||||
federationUrls[coor.shortAlias] = url + basePath;
|
||||
}
|
||||
systemClient.setCookie('federation', JSON.stringify(federationUrls));
|
||||
};
|
||||
|
@ -10,18 +10,21 @@ interface RoboPoolEvents {
|
||||
}
|
||||
|
||||
class RoboPool {
|
||||
constructor(settings: Settings, coordinators: Coordinator[]) {
|
||||
constructor(settings: Settings, hostUrl: string, coordinators: Coordinator[]) {
|
||||
this.network = settings.network ?? 'mainnet';
|
||||
|
||||
this.relays = [];
|
||||
const federationRelays = coordinators.map((coord) => coord.getRelayUrl());
|
||||
const federationRelays = coordinators.map((coord) =>
|
||||
coord.getRelayUrl(settings.network, hostUrl, settings.selfhostedClient),
|
||||
);
|
||||
|
||||
if (settings.host) {
|
||||
const hostNostr = `ws://${settings.host.replace(/^https?:\/\//, '')}/nostr`;
|
||||
const hostNostr = `ws://${settings.host.replace(/^https?:\/\//, '')}/relay`;
|
||||
if (federationRelays.includes(hostNostr)) {
|
||||
this.relays.push(hostNostr);
|
||||
}
|
||||
}
|
||||
|
||||
while (this.relays.length < 3) {
|
||||
const randomRelay =
|
||||
federationRelays[Math.floor(Math.random() * Object.keys(federationRelays).length)];
|
||||
|
@ -665,7 +665,7 @@
|
||||
"RoboSats will try to pay your invoice 3 times with a one minute pause in between. If it keeps failing, you will be able to submit a new invoice. Check whether you have enough inbound liquidity. Remember that lightning nodes must be online in order to receive payments.": "RoboSats intentará pagar tu factura 3 veces con una pausa de un minuto entre cada intento. Si sigue fallando, podrás presentar una nueva factura. Comprueba si tienes suficiente liquidez entrante. Recuerda que los nodos de Lightning tienen que estar en línea para poder recibir pagos.",
|
||||
"Your invoice has expired or more than 3 payment attempts have been made. Submit a new invoice.": "Tu factura ha expirado o se han hecho más de 3 intentos de pago. Aporta una nueva factura.",
|
||||
"#82": "Phrases in components/TradeBox/Prompts/SendingSats.tsx",
|
||||
"Lightning payments are usually instantaneous, but sometimes a node in the route may be down, which can cause your payout to take up to 24 hours to arrive in your wallet.": "Los pagos lightning normalmente son instantaneos, pero a veces un nodo en la ruta puede estar caído y probocar que tu pago tarde hasta 24 horas e procesarse.",
|
||||
"Lightning payments are usually instantaneous, but sometimes a node in the route may be down, which can cause your payout to take up to 24 hours to arrive in your wallet.": "Los pagos lightning normalmente son instantaneos, pero a veces un nodo en la ruta puede estar caído y provocar que tu pago tarde hasta 24 horas e procesarse.",
|
||||
"RoboSats is trying to pay your lightning invoice. Remember that lightning nodes must be online in order to receive payments.": "RoboSats está intentando pagar tu factura de Lightning. Recuerda que los nodos Lightning deben estar en línea para recibir pagos.",
|
||||
"Taking too long?": "¿Tarda demasiado?",
|
||||
"#83": "Phrases in components/TradeBox/Prompts/Successful.tsx",
|
||||
|
70
nodeapp/coordinators/bazaar/locations.conf
Normal file
70
nodeapp/coordinators/bazaar/locations.conf
Normal file
@ -0,0 +1,70 @@
|
||||
# Libre Bazaar Mainnet Locations
|
||||
location /mainnet/bazaar/static/assets/avatars/ {
|
||||
proxy_pass http://mainnet_bazaar/static/assets/avatars/;
|
||||
}
|
||||
|
||||
location /mainnet/bazaar/api/ {
|
||||
# if ($request_method = 'OPTIONS') {
|
||||
# add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||
# add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
|
||||
# add_header 'Access-Control-Max-Age' 1728000;
|
||||
# add_header 'Content-Type' 'text/plain; charset=utf-8';
|
||||
# add_header 'Content-Length' 0;
|
||||
# return 204;
|
||||
# }
|
||||
# if ($request_method = 'POST') {
|
||||
# add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||
# add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
|
||||
# add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
|
||||
# }
|
||||
# if ($request_method = 'GET') {
|
||||
# add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||
# add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
|
||||
# add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
|
||||
# }
|
||||
proxy_pass http://mainnet_bazaar/api/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
location /mainnet/bazaar/ws/ {
|
||||
proxy_pass http://mainnet_bazaar/ws/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
location /mainnet/bazaar/relay/ {
|
||||
proxy_pass http://mainnet_bazaar/relay/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header Origin $http_origin;
|
||||
proxy_set_header Host $host;
|
||||
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
}
|
||||
|
||||
# BitcoinVeneto Coordinator Testnet Locations
|
||||
location /test/bazaar/static/assets/avatars/ {
|
||||
proxy_pass http://testnet_bazaar/static/assets/avatars/;
|
||||
}
|
||||
|
||||
location /testnet/bazaar/api/ {
|
||||
proxy_pass http://testnet_bazaar/api/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
location /testnet/bazaar/ws/ {
|
||||
proxy_pass http://testnet_bazaar/ws/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header Host $host;
|
||||
}
|
9
nodeapp/coordinators/bazaar/upstreams.conf
Normal file
9
nodeapp/coordinators/bazaar/upstreams.conf
Normal file
@ -0,0 +1,9 @@
|
||||
# Libre Bazaar Coordinator Mainnet
|
||||
upstream mainnet_bazaar {
|
||||
server localhost:107;
|
||||
}
|
||||
|
||||
# Libre Bazaar Coordinator Testnet
|
||||
upstream testnet_bazaar {
|
||||
server localhost:1007;
|
||||
}
|
@ -37,12 +37,15 @@ location /mainnet/lake/ws/ {
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
location /mainnet/lake/nostr/ {
|
||||
proxy_pass http://mainnet_lake/nostr/;
|
||||
location /mainnet/lake/relay/ {
|
||||
proxy_pass http://mainnet_lake/relay/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header Origin $http_origin;
|
||||
proxy_set_header Host $host;
|
||||
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
}
|
||||
|
||||
# TheBigLake Coordinator Testnet Locations
|
||||
|
@ -37,12 +37,15 @@ location /mainnet/moon/ws/ {
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
location /mainnet/moon/nostr/ {
|
||||
proxy_pass http://mainnet_moon/nostr/;
|
||||
location /mainnet/moon/relay/ {
|
||||
proxy_pass http://mainnet_moon/relay/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header Origin $http_origin;
|
||||
proxy_set_header Host $host;
|
||||
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
}
|
||||
|
||||
# Over the Moon Coordinator Testnet Locations
|
||||
|
@ -37,12 +37,15 @@ location /mainnet/temple/ws/ {
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
location /mainnet/temple/nostr/ {
|
||||
proxy_pass http://mainnet_temple/nostr/;
|
||||
location /mainnet/temple/relay/ {
|
||||
proxy_pass http://mainnet_temple/relay/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header Origin $http_origin;
|
||||
proxy_set_header Host $host;
|
||||
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
}
|
||||
|
||||
# Temple of Sats Coordinator Testnet Locations
|
||||
|
@ -37,12 +37,15 @@ location /mainnet/veneto/ws/ {
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
location /mainnet/veneto/nostr/ {
|
||||
proxy_pass http://mainnet_veneto/nostr/;
|
||||
location /mainnet/veneto/relay/ {
|
||||
proxy_pass http://mainnet_veneto/relay/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header Origin $http_origin;
|
||||
proxy_set_header Host $host;
|
||||
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
}
|
||||
|
||||
# BitcoinVeneto Coordinator Testnet Locations
|
||||
|
@ -36,6 +36,8 @@ http {
|
||||
include /etc/nginx/conf.d/veneto/upstreams.conf;
|
||||
# Over the Moon
|
||||
include /etc/nginx/conf.d/moon/upstreams.conf;
|
||||
# Libre Bazaar
|
||||
include /etc/nginx/conf.d/bazaar/upstreams.conf;
|
||||
|
||||
server {
|
||||
|
||||
@ -76,6 +78,8 @@ http {
|
||||
include /etc/nginx/conf.d/veneto/locations.conf;
|
||||
# Over the Moon
|
||||
include /etc/nginx/conf.d/moon/locations.conf;
|
||||
# Libre Bazaar
|
||||
include /etc/nginx/conf.d/bazaar/locations.conf;
|
||||
|
||||
# do not log healtchecks made against "/selfhosted"
|
||||
location /selfhosted {
|
||||
|
@ -56,6 +56,18 @@ testnet_moon_port=1006
|
||||
mainnet_moon_socat="socat tcp4-LISTEN:${mainnet_moon_port},reuseaddr,fork,keepalive,bind=127.0.0.1 SOCKS4A:${TOR_PROXY_IP:-127.0.0.1}:${mainnet_moon_onion}:80,socksport=${TOR_PROXY_PORT:-9050}"
|
||||
testnet_moon_socat="socat tcp4-LISTEN:${testnet_moon_port},reuseaddr,fork,keepalive,bind=127.0.0.1 SOCKS4A:${TOR_PROXY_IP:-127.0.0.1}:${testnet_moon_onion}:80,socksport=${TOR_PROXY_PORT:-9050}"
|
||||
|
||||
################################
|
||||
# Libre Bazaar
|
||||
# Mainnet
|
||||
mainnet_bazaar_onion=librebazovfmmkyi2jekraxsuso3mh622avuuzqpejixdl5dhuhb4tid.onion
|
||||
mainnet_bazaar_port=107
|
||||
# Testnet
|
||||
testnet_bazaar_onion=librebazovfmmkyi2jekraxsuso3mh622avuuzqpejixdl5dhuhb4tid.onion
|
||||
testnet_bazaar_port=1007
|
||||
# socat cmd
|
||||
mainnet_bazaar_socat="socat tcp4-LISTEN:${mainnet_bazaar_port},reuseaddr,fork,keepalive,bind=127.0.0.1 SOCKS4A:${TOR_PROXY_IP:-127.0.0.1}:${mainnet_bazaar_port}:80,socksport=${TOR_PROXY_PORT:-9050}"
|
||||
testnet_bazaar_socat="socat tcp4-LISTEN:${testnet_bazaar_port},reuseaddr,fork,keepalive,bind=127.0.0.1 SOCKS4A:${TOR_PROXY_IP:-127.0.0.1}:${testnet_bazaar_port}:80,socksport=${TOR_PROXY_PORT:-9050}"
|
||||
|
||||
|
||||
# RUN!
|
||||
$mainnet_temple_socat & $testnet_temple_socat & $mainnet_lake_socat & $testnet_lake_socat & $mainnet_veneto_socat & $testnet_veneto_socat & $mainnet_moon_socat & $testnet_moon_socat & nginx
|
||||
$mainnet_temple_socat & $testnet_temple_socat & $mainnet_lake_socat & $testnet_lake_socat & $mainnet_veneto_socat & $testnet_veneto_socat & $mainnet_moon_socat & $testnet_moon_socat & $mainnet_bazaar_socat & $testnet_bazaar_socat & nginx
|
Reference in New Issue
Block a user