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

rpcauth #169

Merged
merged 37 commits into from
Jun 27, 2023
Merged

rpcauth #169

merged 37 commits into from
Jun 27, 2023

Conversation

Fonta1n3
Copy link
Contributor

@Fonta1n3 Fonta1n3 commented Nov 7, 2021

  • Adds the 15 min average btc/usd exchange rate via Tor API call to blockchain.info
  • Utilizes rpcauth instead of plain text rpc credentials
  • rpcuser and rpcpassword can still be used but as far as Gordian Server is concerned it will only check for rpcauth=GordianServer:xxxx, if the GordianServer user has not been added it automatically generates its own rpcauth creds and adds them to the bitcoin.conf
  • If for some reason rpc creds are invalid it prompts the user to refresh the credentials in a graceful way (delete the existing invalid auth, ensure Bitcoin Core has been stopped, if the creds are missing when attempting to start bitcoind they will get automatically added via prompt)
  • Bug fixes where the installer prompt may have launched twice when editing the default bitcoin.conf settings prior to installation
  • Removes all scripts where native swift code could instead be used
  • Much improved handling of invalid rpc credentials
  • Python 3.9 and PythonKit are now embedded into the app allowing us to use rpcauth.py, Python can be removed with a simple file that translates rpcauth.py to Swift, however embedding python allows us to do some interesting things for future extensibility like integrating Join Market in its entirety as a native macOS app, c-lightning also has Python related code
  • ⚠️ This PR breaks Apples notarization of the dmg, this can be fixed by signing the embedded Python related libraries with the following script and disabling Disable Library Validation under the Hardened Runtime capability in Xcode:
function signThese() {
        find . -name "*.$1" | while read line; do
                codesign --force --verbose=4 --options=runtime --timestamp --sign "Developer ID Application: [INSERT YOUR CERT HERE]" $line
        done
}
  • ⚠️ This has only been tested on M1 MacBook, needs to be tested on Intel

…ping bitcoin core (not a script)

To do: use http in app delegate for quitting bitcoin core. Handle missing rpcauth in existing bitcoin.conf on an adhoc basis. Different classifications of rpcwhitelist (e.g. GordianServer user does not need them all but FullyNoded does). rpcauth for quickconnect 2.0. add python3 framework for m1 to avoid rosetta crashes.
refactor: use swit code instead of scripts where possible
fix: bug where editing settings would launch two install prompts
fix: better UX when bitcoin is installed the first time
@Fonta1n3 Fonta1n3 closed this Dec 2, 2021
@ChristopherA
Copy link
Contributor

Why closed?

@Fonta1n3
Copy link
Contributor Author

Fonta1n3 commented Dec 3, 2021

Why closed?

Seems there was no interest and I wanted to make more commits and not have them show up here. Can add back again.

@Fonta1n3 Fonta1n3 reopened this Dec 3, 2021
@Fonta1n3
Copy link
Contributor Author

Hey this fixes the update issue #180

@shannona
Copy link
Contributor

incorporating into dev branch for testing.

@shannona shannona merged commit aaa81db into BlockchainCommons:dev Jun 27, 2023
@shannona
Copy link
Contributor

shannona commented Jun 27, 2023

Unfortunately, the PR doesn't work.

Trying it out on a M1 machine where I cleaned out the files with KILLALL:

error: 
2023-06-27 12:19:43.023308-1000 GordianServer-macOS[11743:577452] [connection] nw_socket_handle_socket_event [C1.1.1.1.1:4] Socket SO_ERROR [61: Connection refused]
2023-06-27 12:19:43.024568-1000 GordianServer-macOS[11743:577452] [connection] nw_socket_handle_socket_event [C1.1.1.1.2:4] Socket SO_ERROR [61: Connection refused]
2023-06-27 12:19:43.029390-1000 GordianServer-macOS[11743:577452] Connection 1: received failure notification
2023-06-27 12:19:43.029455-1000 GordianServer-macOS[11743:577452] Connection 1: failed to connect 1:61, reason -1
2023-06-27 12:19:43.029478-1000 GordianServer-macOS[11743:577452] Connection 1: encountered error(1:61)
2023-06-27 12:19:43.029961-1000 GordianServer-macOS[11743:577452] Task <AC22A867-941A-47ED-B4C3-99131536F174>.<1> HTTP load failed, 0/0 bytes (error code: -1004 [1:61])
2023-06-27 12:19:43.033138-1000 GordianServer-macOS[11743:577378] Task <AC22A867-941A-47ED-B4C3-99131536F174>.<1> finished with error [-1004] Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={_kCFStreamErrorCodeKey=61, NSUnderlyingError=0x600002619fb0 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_NSURLErrorNWPathKey=satisfied (Path is satisfied), viable, interface: lo0, _kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <AC22A867-941A-47ED-B4C3-99131536F174>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <AC22A867-941A-47ED-B4C3-99131536F174>.<1>"
), NSLocalizedDescription=Could not connect to the server., NSErrorFailingURLStringKey=https://blockchain.info/ticker, NSErrorFailingURLKey=https://blockchain.info/ticker, _kCFStreamErrorDomainKey=1}
2023-06-27 12:19:43.965752-1000 GordianServer-macOS[11743:577378] [Window] Warning: Window NSWindow 0x125ef5800 ordered front from a non-active application and may order beneath the active application's windows.
2023-06-27 12:20:09.659669-1000 GordianServer-macOS[11743:577378] Metal API Validation Enabled

No buttons at all are illuminated. (So not only can you not START or STOP, but VERIFY is gray too, as is the network choice.)
rpc host is listed as unauthenticated.

Bitcoin 25 update was also not allowed to minimize variables.

==

Trying it out on an older (non-M1) machine where the directory was still in place:

  • tries to update rpcauth info and fails
  • end up in a state where you can't START or STOP Gordian Server
2023-06-27 12:25:15.844346-1000 GordianServer-macOS[93699:1301986] [Nib Loading] Failed to connect (newWindowClicked) outlet from (GordianServer_macOS.AppDelegate) to (NSMenuItem): missing setter or instance variable
2023-06-27 12:25:15.931763-1000 GordianServer-macOS[93699:1301986] [Nib Loading] Failed to connect (perrDetailsButton) outlet from (GordianServer_macOS.ViewController) to (NSButton): missing setter or instance variable
env = ["VERSION": "bitcoin-25.0", "DATADIR": "/Users/shannona/Library/Application Support/Bitcoin", "CHAIN": "main", "BINARY_NAME": "bitcoin-25.0-x86_64-apple-darwin.tar.gz", "PREFIX": "bitcoin-25.0"]
libraryPath: /Users/shannona/Library/Developer/Xcode/DerivedData/GordianServer-macOS-bbduasnibbaxrzehsuwymrtjouxg/Build/Products/Debug/GordianServer-macOS.app/Contents/Resources/Python/Versions/3.10/Python
python version: 3.10.0 (v3.10.0:b494f5935c, Oct  4 2021, 14:59:20) [Clang 12.0.5 (clang-1205.0.22.11)]
env = ["BINARY_NAME": "bitcoin-25.0-x86_64-apple-darwin.tar.gz", "VERSION": "bitcoin-25.0", "PREFIX": "bitcoin-25.0", "CHAIN": "main", "DATADIR": "/Users/shannona/Library/Application Support/Bitcoin"]
Jun 27 12:25:18.012 [notice] Tor 0.4.4.6 (git-b7e5e4bdcaf0086e) running on Darwin with Libevent 2.1.11-stable, OpenSSL 3.0.0-alpha11-dev, Zlib 1.2.11, Liblzma 5.2.4, and Libzstd N/A.
Jun 27 12:25:18.012 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Jun 27 12:25:18.012 [notice] Read configuration file "/Users/shannona/.torrc".
Jun 27 12:25:18.015 [notice] Opening Socks listener on 127.0.0.1:19150
Jun 27 12:25:18.015 [notice] Opened Socks listener on 127.0.0.1:19150
Jun 27 12:25:18.015 [notice] Opening DNS listener on 127.0.0.1:12346
Jun 27 12:25:18.015 [notice] Opened DNS listener on 127.0.0.1:12346
Jun 27 12:25:18.015 [notice] Opening Control listener on /Users/shannona/.gordian/.tor/cp
Jun 27 12:25:18.015 [notice] Opened Control listener on /Users/shannona/.gordian/.tor/cp
2023-06-27 12:25:20.700978-1000 GordianServer-macOS[93699:1301986] Metal API Validation Enabled
2023-06-27 12:25:20.777206-1000 GordianServer-macOS[93699:1301986] [default] CGSWindowShmemCreateWithPort failed on port 0
2023-06-27 12:25:20.790366-1000 GordianServer-macOS[93699:1301986] [default] CGSWindowShmemCreateWithPort failed on port 0
2023-06-27 12:25:20.793884-1000 GordianServer-macOS[93699:1301986] [Window] Warning: Window _NSAlertPanel 0x7fbabebaab30 ordered front from a non-active application and may order beneath the active application's windows.
2023-06-27 12:25:20.829323-1000 GordianServer-macOS[93699:1302559] [connection] nw_socket_handle_socket_event [C1.1.1.1:4] Socket SO_ERROR [61: Connection refused]
2023-06-27 12:25:20.831081-1000 GordianServer-macOS[93699:1302559] [connection] nw_socket_handle_socket_event [C1.1.1.2:4] Socket SO_ERROR [61: Connection refused]
2023-06-27 12:25:20.831959-1000 GordianServer-macOS[93699:1302559] Connection 1: received failure notification
2023-06-27 12:25:20.832017-1000 GordianServer-macOS[93699:1302559] Connection 1: failed to connect 1:61, reason -1
2023-06-27 12:25:20.832041-1000 GordianServer-macOS[93699:1302559] Connection 1: encountered error(1:61)
2023-06-27 12:25:20.832434-1000 GordianServer-macOS[93699:1302559] Task <E75920D3-575B-4C3C-912E-6EEAE0A0FC97>.<1> HTTP load failed, 0/0 bytes (error code: -1004 [1:61])
python version: 3.10.0 (v3.10.0:b494f5935c, Oct  4 2021, 14:59:20) [Clang 12.0.5 (clang-1205.0.22.11)]
2023-06-27 12:25:28.581145-1000 GordianServer-macOS[93699:1301986] Task <E75920D3-575B-4C3C-912E-6EEAE0A0FC97>.<1> finished with error [-1004] Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={_kCFStreamErrorCodeKey=61, NSUnderlyingError=0x600003b77420 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_NSURLErrorNWPathKey=satisfied (Path is satisfied), viable, interface: lo0, _kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <E75920D3-575B-4C3C-912E-6EEAE0A0FC97>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <E75920D3-575B-4C3C-912E-6EEAE0A0FC97>.<1>"
), NSLocalizedDescription=Could not connect to the server., NSErrorFailingURLStringKey=https://blockchain.info/ticker, NSErrorFailingURLKey=https://blockchain.info/ticker, _kCFStreamErrorDomainKey=1}
script: CheckForBitcoinCore
output: Bitcoin Core version v25.0.0
Copyright (C) 2009-2023 The Bitcoin Core developers

Please contribute if you find Bitcoin Core useful. Visit
<https://bitcoincore.org/> for further information about the software.
The source code is available from <https://github.com/bitcoin/bitcoin>.

This is experimental software.
Distributed under the MIT software license, see the accompanying file COPYING
or <https://opensource.org/licenses/MIT>

error: 
script: IsProcessRunning
output: 93026
Running

error: 
2023-06-27 12:25:29.076388-1000 GordianServer-macOS[93699:1301986] [default] CGSWindowShmemCreateWithPort failed on port 0
2023-06-27 12:25:29.084795-1000 GordianServer-macOS[93699:1301986] [default] CGSWindowShmemCreateWithPort failed on port 0
2023-06-27 12:25:31.244141-1000 GordianServer-macOS[93699:1301986] [default] CGSWindowShmemCreateWithPort failed on port 0
2023-06-27 12:25:31.252642-1000 GordianServer-macOS[93699:1301986] [default] CGSWindowShmemCreateWithPort failed on port 0

The START and STOP buttons are not available, though I think Bitcoin is running, as Server later asked if it should be left running when I killed Server.

rpc host is unauthenticated.

This was AFTER allowing the Bitcoin 25 update, which also didn't work right (I had to close out the install window after installation, and then restart the Server.)

==

If I was going to dig into this more my process would be:

  1. Set Bitcoin 25 as the default download to minimize that variable.
  2. Make sure Bitcoin 25 is downloaded correctly.
  3. Then dig back into the failed setup.
  4. Then merge in the newer updates on Master
  5. Then debug further

@Fonta1n3
Copy link
Contributor Author

I have not tested this on a fresh install (recently)... it's a 2 year old PR. I've been using this for 2 years without any issues, will try and delete Gordian directory and see if I can replicate your issue.

Keep in mind this has nothing do with with the RPC authentication for the tor hidden service. It just replaces the need for storing rpc creds in plain text in your bitcoin.conf

@Fonta1n3
Copy link
Contributor Author

fwiw I deleted the .gordian directory and it installed for me without any issues.

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.

3 participants