2 use std::net::SocketAddr;
3 use bitcoin::secp256k1::PublicKey;
4 use lightning_block_sync::http::HttpEndpoint;
5 use tokio_postgres::Config;
8 pub(crate) const SCHEMA_VERSION: i32 = 1;
9 pub(crate) const SNAPSHOT_CALCULATION_INTERVAL: u32 = 3600 * 24; // every 24 hours, in seconds
10 pub(crate) const DOWNLOAD_NEW_GOSSIP: bool = true;
12 pub(crate) fn network_graph_cache_path() -> &'static str {
13 "./res/network_graph.bin"
16 pub(crate) fn db_connection_config() -> Config {
17 let mut config = Config::new();
18 let host = env::var("RAPID_GOSSIP_SYNC_SERVER_DB_HOST").unwrap_or("localhost".to_string());
19 let user = env::var("RAPID_GOSSIP_SYNC_SERVER_DB_USER").unwrap_or("alice".to_string());
20 let db = env::var("RAPID_GOSSIP_SYNC_SERVER_DB_NAME").unwrap_or("ln_graph_sync".to_string());
24 if let Ok(password) = env::var("RAPID_GOSSIP_SYNC_SERVER_DB_PASSWORD") {
25 config.password(&password);
30 pub(crate) fn bitcoin_rest_endpoint() -> HttpEndpoint {
31 let host = env::var("BITCOIN_REST_DOMAIN").unwrap_or("127.0.0.1".to_string());
32 let port = env::var("BITCOIN_REST_PORT")
33 .unwrap_or("8332".to_string())
35 .expect("BITCOIN_REST_PORT env variable must be a u16.");
36 let path = env::var("BITCOIN_REST_PATH").unwrap_or("/rest/".to_string());
37 HttpEndpoint::for_host(host).with_port(port).with_path(path)
40 pub(crate) fn db_config_table_creation_query() -> &'static str {
41 "CREATE TABLE IF NOT EXISTS config (
42 id SERIAL PRIMARY KEY,
47 pub(crate) fn db_announcement_table_creation_query() -> &'static str {
48 "CREATE TABLE IF NOT EXISTS channel_announcements (
49 id SERIAL PRIMARY KEY,
50 short_channel_id character varying(255) NOT NULL UNIQUE,
52 chain_hash character varying(255),
53 announcement_signed BYTEA,
54 seen timestamp NOT NULL DEFAULT NOW()
58 pub(crate) fn db_channel_update_table_creation_query() -> &'static str {
59 "CREATE TABLE IF NOT EXISTS channel_updates (
60 id SERIAL PRIMARY KEY,
61 composite_index character varying(255) UNIQUE,
62 chain_hash character varying(255),
63 short_channel_id character varying(255),
65 channel_flags integer,
68 cltv_expiry_delta integer,
69 htlc_minimum_msat bigint,
70 fee_base_msat integer,
71 fee_proportional_millionths integer,
72 htlc_maximum_msat bigint,
74 seen timestamp NOT NULL DEFAULT NOW()
78 pub(crate) fn db_index_creation_query() -> &'static str {
80 CREATE INDEX IF NOT EXISTS channels_seen ON channel_announcements(seen);
81 CREATE INDEX IF NOT EXISTS channel_updates_scid ON channel_updates(short_channel_id);
82 CREATE INDEX IF NOT EXISTS channel_updates_direction ON channel_updates(direction);
83 CREATE INDEX IF NOT EXISTS channel_updates_seen ON channel_updates(seen);
88 pub(crate) fn ln_peers() -> Vec<(PublicKey, SocketAddr)> {
91 // (hex_utils::to_compressed_pubkey("033d8656219478701227199cbd6f670335c8d408a92ae88b962c49d4dc0e83e025").unwrap(), "34.65.85.39:9735".parse().unwrap()),
94 // (hex_utils::to_compressed_pubkey("03db10aa09ff04d3568b0621750794063df401e6853c79a21a83e1a3f3b5bfb0c8").unwrap(), "69.59.18.80:9735".parse().unwrap())
97 // (hex_utils::to_compressed_pubkey("03037dc08e9ac63b82581f79b662a4d0ceca8a8ca162b1af3551595b8f2d97b70a").unwrap(), "104.196.249.140:9735".parse().unwrap())
99 // Wallet of Satoshi | 035e4ff418fc8b5554c5d9eea66396c227bd429a3251c8cbc711002ba215bfc226@170.75.163.209:9735
100 (hex_utils::to_compressed_pubkey("035e4ff418fc8b5554c5d9eea66396c227bd429a3251c8cbc711002ba215bfc226").unwrap(), "170.75.163.209:9735".parse().unwrap())