Repository navigation
Fix --bitcoin-rpc-cookie: the cookie is never base64 encoded - #216
Open
bitsagarob wants to merge 1 commit into
Open
bitsagarob wants to merge 1 commit into
bitsagarob wants to merge 1 commit into
Conversation
The cookie was sent verbatim as an HTTP Basic credential, so Core rejected every request with 401. Reuse auth_token_from_cookie, which already does this encode for spaced's own RPC server.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
--bitcoin-rpc-cookiealways gets401 Unauthorizedfrom Bitcoin Core.BitcoinRpcAuth::to_tokenreturns the cookie file contents unchanged, but the result is sent asAuthorization: Basic <token>, which has to be base64. TheUserPassarm right above it encodes correctly, so passing--bitcoin-rpc-userand--bitcoin-rpc-passwordworks and only the cookie path is broken. The default cookie path fallback is affected too.auth_token_from_cookieinclient/src/auth.rsalready does exactly this encode and is used for spaced's own RPC server, so the fix just calls it.The
trim()is becauseread_to_stringkeeps a trailing newline if the cookie file has one, and that breaks Basic auth the same silent way.Tested against Bitcoin Core on mainnet: 401 before, syncs after, and user/password still works.