Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RIP Esplora, configure bitcoin-d as chain source. #21

Merged
merged 1 commit into from
Nov 8, 2024

Conversation

G8XSU
Copy link
Contributor

@G8XSU G8XSU commented Nov 5, 2024

  • RIP Esplora
  • Configure bitcoin-d as chain source.

Not too worried about increasing number of cli args,
In later PRs we move the whole config to a file and only take config file path as input.

@G8XSU G8XSU requested a review from jkczyz November 5, 2024 18:57
@jkczyz
Copy link

jkczyz commented Nov 5, 2024

  • RIP Esplora
  • Configure bitcoin-d as chain source.

Not too worried about increasing number of cli args, In later PRs we move the whole config to a file and only take config file path as input.

IIUC, the file-based config approach will allow for using Esplora if desired?

@G8XSU
Copy link
Contributor Author

G8XSU commented Nov 5, 2024

IIUC, the file-based config approach will allow for using Esplora if desired?

I don't think it makes much sense to use ldk-server with esplora given myriad of problems related to scaling/trust/rate-limiting.
For ldk-server we will mostly only support bitcoind.
Adding esplora can be an option in future if need be but not a priority right now and mostly discouraged.

Copy link
Collaborator

@tnull tnull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK for switching to bitcoind RPC, but please let's not make the user supply a plaintext password on the command line.

@@ -24,7 +24,7 @@ fn main() {

if args.len() < 6 {
eprintln!(
"Usage: {} storage_path listening_addr rest_svc_addr network esplora_server_url",
"Usage: {} storage_path listening_addr rest_svc_addr network bitcoind_rpc_addr bitcoind_rpc_user bitcoind_rpc_password",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not take a plaintext password from command line here, please. Let's parse username password from the default .cookie file and let the user supply an override path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does sound like a good idea, but this needs more thought.

iiuc, the .cookie is ephemeral and is meant for local-only access; it is read-only if we use the same user for bitcoin-d as the LDK daemon.

For remote access, I think the RPC user and pass in bitcoin.conf need to be set.

Similarly, it is equivalent to have an rpc-user and rpc-pass in ldk-server.conf.

Generally, just relying on RPC (pass) isn't a sufficient security measure; most people need to configure bitcoind with secure network access in addition to RPC authentication.

I checked this for both LND and c-lightning; they do it the same way i.e., credentials in a file: https://docs.corelightning.org/reference/lightningd-config.

We should probably switch to rpc-auth instead of rpc-user-password for the bitcoind connection.

Currently, given that the cookie method restricts bitcoin-d usage to local-only, I don't think we should restrict ourselves to that method.

Copy link
Collaborator

@tnull tnull Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, it is equivalent to have an rpc-user and rpc-pass in ldk-server.conf.

Mhh, I tend to disagree. Supplying these parameters via shell input means that they might get inadvertently distributed across different hosts/history files. IMO, there is a notable difference between reading RPC credentials from (likely hopefully protected by 700 permissions) config file and reading them as arguments, which might leak to other users on the same host through ps or similar.

We should probably switch to rpc-auth instead of rpc-user-password for the bitcoind connection.

Not sure how rpc-auth is different here? It's just the username and the hashed password in a single string, which is exactly the .cookie format?

Copy link
Contributor Author

@G8XSU G8XSU Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mhh, I tend to disagree. Supplying these parameters via shell input means that they might get inadvertently distributed across different hosts/history files. IMO, there is a notable difference between reading RPC credentials from (likely hopefully protected by 700 permissions) config file

As noted in main PR description, CLI reading is a stop-gap solution until the next PR which introduces read all args from file.
All the CLI options are moving to a config file. Hence it is is equivalent.

Not sure how rpc-auth is different here? It's just the username and the hashed password in a single string, which is exactly the .cookie format?

RPCAuth refers https://github.com/bitcoin/bitcoin/blob/master/share/rpcauth/rpcauth.py , where we configure
`rpcauth=$username:$SALT$hash

It is different from .cookie since .cookie is ephemeral and is meant for local access only.

Afaik, rpc-auth is the preffered method for accessing bitcoind remotely: https://bitcoin.stackexchange.com/a/90420

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted in main PR description, CLI reading is a stop-gap solution until the next PR which introduces read all args from file. All the CLI options are moving to a config file. Hence it is is equivalent.

Is there a pressing need for this PR? Why not just do the next one instead?

Copy link
Contributor Author

@G8XSU G8XSU Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a pressing need for this PR? Why not just do the next one instead?

I don't see a reason to block this on next one, given they are independent from functionality perspective.
Reading from config is in milestone-3 (#11), and i will have to prioritize it. It also helps me if all the possible config options are checked-in more or less, before i think about config-file schema. Also hoping that it is easier to test with bitcoind than setup local esplora.

Given I have already said that we will move all args to config file, and only take config-file path as input, i assume we can move forward with that?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RPCAuth refers https://github.com/bitcoin/bitcoin/blob/master/share/rpcauth/rpcauth.py , where we configure `rpcauth=$username:$SALT$hash

It is different from .cookie since .cookie is ephemeral and is meant for local access only.

Afaik, rpc-auth is the preffered method for accessing bitcoind remotely: https://bitcoin.stackexchange.com/a/90420

It's literally the same scheme. The .cookie just houses rpcauth token with user __cookie__ and a random password. If we implement reading .cookie files first, we'd get a way to supply rpcauth params from file for free.

In any case, I don't want to hold up this PR over it if we agree that this is a stop-gap solution that will be dropped in the future anyways.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will defer to y'all, but note we already have code supporting cookie-based auth in LDK sample.

Copy link
Contributor Author

@G8XSU G8XSU Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's literally the same scheme.

The reason the cookie doesn't work for us is that it is ephemeral.
Not really an option for us as default unless we support other methods.

@moneyball
Copy link

moneyball commented Nov 7, 2024 via email

@tnull
Copy link
Collaborator

tnull commented Nov 7, 2024

How do Core, LND, and CLN handle it?

They offer multiple options but usually storing credentials in a config (or in Core's case dedicated .cookie / LND's case macaroon) file is preferred. CLN even just allows RPC access via a local socket file, essentially disallowing (or making really hard) to access from the network.

I think we should implement multiple ways eventually, but reading from command line shouldn't be the default, IMO.

@G8XSU
Copy link
Contributor Author

G8XSU commented Nov 7, 2024

I think we should implement multiple ways eventually, but reading from command line shouldn't be the default, IMO.

As mentioned in main PR description, CLI reading is a stop-gap solution until the next PR which introduces read all args from file. Reading from file is the default.

Reading from .cookie doesn't work because it is ephemeral and is meant for local, same-user access only.
Rpc-auth is the preffered method for remote access.

server/src/main.rs Outdated Show resolved Hide resolved
@G8XSU G8XSU requested a review from tnull November 7, 2024 16:10
@G8XSU G8XSU mentioned this pull request Nov 7, 2024
13 tasks
@G8XSU
Copy link
Contributor Author

G8XSU commented Nov 7, 2024

Squash fixups early to avoid another review cycle.

@tnull tnull merged commit f32a2ba into lightningdevkit:main Nov 8, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants