Skip to content

Commit

Permalink
Merge pull request #8 from Start9Labs/feature/nested-external-core-co…
Browse files Browse the repository at this point in the history
…nfig

Feature/nested external core config
  • Loading branch information
ProofOfKeags authored Mar 11, 2021
2 parents e2cc6c7 + 6cbbc0f commit b5c2fff
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 39 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ RUN ./configure LDFLAGS=-L`ls -d /opt/db*`/lib/ CPPFLAGS=-I`ls -d /opt/db*`/incl
--with-gui=no \
--disable-wallet \
--enable-util-cli
RUN make -j4
RUN make -j24
RUN strip ./src/bitcoin-cli

FROM alpine:3.12 as builder
Expand All @@ -64,7 +64,7 @@ ADD ./lightning /root/lightning
WORKDIR /root/lightning

RUN ./configure
RUN make
RUN make -j24
RUN make install

FROM alpine:3.12 as runner
Expand Down
83 changes: 53 additions & 30 deletions config_spec.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

alias:
type: string
name: Alias
Expand All @@ -23,10 +22,18 @@ bitcoind:
name: Bitcoin Core
description: |
The Bitcoin Core node to connect to:
- internal: The Bitcoin Core RPC Proxy service installed to your Embassy
- external: An unpruned Bitcoin Core node running on a different device
- quick-connect: A Quick Connect URL for an unpruned Bitcoin Core node
tag: type
- Internal: The Bitcoin Core RPC Proxy service installed to your Embassy
- External: An unpruned Bitcoin Core node running on a different device
tag:
id: type
name: Type
variantNames:
internal: Internal
external: External
description: |
The Bitcoin Core node to connect to:
- Internal: The Bitcoin Core RPC Proxy service installed to your Embassy
- External: An unpruned Bitcoin Core node running on a different device
default: internal
variants:
internal:
Expand Down Expand Up @@ -54,30 +61,46 @@ bitcoind:
target: config
index: 'users.[first(item => ''item.name = "c-lightning")].password'
external:
address:
type: string
name: Public Address
description: The public address of your Bitcoin Core RPC server
nullable: false
user:
type: string
name: RPC Username
description: The username for the RPC user on your Bitcoin Core RPC server
nullable: false
password:
type: string
name: RPC Password
description: The password for the RPC user on your Bitcoin Core RPC server
nullable: false
masked: true
quick-connect:
quick-connect-url:
type: string
name: Quick Connect URL
description: The Quick Connect URL for your Bitcoin Core RPC server
nullable: false
pattern: 'btcstandup://[^:]*:[^@]*@[a-zA-Z0-9.-]+:[0-9]+(/(\?(label=.+)?)?)?'
patternDescription: Must be a valid Quick Connect URL. For help, check out https://github.com/BlockchainCommons/Gordian/blob/master/Docs/Quick-Connect-API.md
connection-settings:
type: union
name: Connection Settings
description: Information to connect to an external unpruned Bitcoin Core node
tag:
id: type
name: Type
description: |
- Manual: Raw information for finding a Bitcoin Core node
- Quick Connect: A Quick Connect URL for a Bitcoin Core node
variantNames:
manual: Manual
quick-connect: Quick Connect
default: quick-connect
variants:
manual:
address:
type: string
name: Public Address
description: The public address of your Bitcoin Core RPC server
nullable: false
user:
type: string
name: RPC Username
description: The username for the RPC user on your Bitcoin Core RPC server
nullable: false
password:
type: string
name: RPC Password
description: The password for the RPC user on your Bitcoin Core RPC server
nullable: false
masked: true
quick-connect:
quick-connect-url:
type: string
name: Quick Connect URL
description: The Quick Connect URL for your Bitcoin Core RPC server
nullable: false
pattern: 'btcstandup://[^:]*:[^@]*@[a-zA-Z0-9.-]+:[0-9]+(/(\?(label=.+)?)?)?'
patternDescription: Must be a valid Quick Connect URL. For help, check out https://github.com/BlockchainCommons/Gordian/blob/master/Docs/Quick-Connect-API.md
rpc:
type: object
name: RPC Options
Expand Down Expand Up @@ -195,4 +218,4 @@ advanced:
Warning: This is #Reckless and you should not enable it unless you deeply understand the risks associated with
the Lightning Network.
default: false
default: false
26 changes: 19 additions & 7 deletions configurator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ enum BitcoinCoreConfig {
},
#[serde(rename_all = "kebab-case")]
External {
connection_settings: ExternalBitcoinCoreConfig,
},
}

#[derive(serde::Deserialize)]
#[serde(tag = "type")]
#[serde(rename_all = "kebab-case")]
enum ExternalBitcoinCoreConfig {
#[serde(rename_all = "kebab-case")]
Manual {
#[serde(deserialize_with = "deserialize_parse")]
address: Uri,
user: String,
Expand All @@ -67,7 +77,6 @@ enum BitcoinCoreConfig {
quick_connect_url: Uri,
},
}

#[derive(Deserialize)]
struct RpcConfig {
enabled: bool,
Expand Down Expand Up @@ -162,18 +171,21 @@ fn main() -> Result<(), anyhow::Error> {
password,
} => (user, password, format!("{}", address), 8332),
BitcoinCoreConfig::External {
address,
user,
password,
connection_settings:
ExternalBitcoinCoreConfig::Manual {
address,
user,
password,
},
} => (
user,
password,
format!("{}", address.host().unwrap()),
address.port_u16().unwrap_or(8332),
),
BitcoinCoreConfig::QuickConnect { quick_connect_url } => {
parse_quick_connect_url(quick_connect_url)?
}
BitcoinCoreConfig::External {
connection_settings: ExternalBitcoinCoreConfig::QuickConnect { quick_connect_url },
} => parse_quick_connect_url(quick_connect_url)?,
};
let rpc_bind: SocketAddr = if config.rpc.enabled {
([0, 0, 0, 0], 8080).into()
Expand Down

0 comments on commit b5c2fff

Please sign in to comment.