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

P2EP proof of concept #3582

Closed
wants to merge 31 commits into from
Closed

Conversation

lontivero
Copy link
Collaborator

This PR is a PoC to implement a p2ep mechanism. Basically it starts a ephimeral tor hidden service (one with a disposable private key) and start listening on a local port for Payjoin requests.

Does not contains a working code. Don't test it. Don't run it.

@MaxHillebrand
Copy link
Member

@lontivero You cannot do that... teasing with such a major awesomeness, and then saying we cannot check it out and run it... the anticipation is killing me!!

Honestly, if Wasabi can receive P2EP... we could do so much cool stuff...

@lontivero
Copy link
Collaborator Author

@MaxHillebrand, you can play with this now.

  1. Make sure to stop all the tor instances (this is something you have to do only once)
  2. Open Wassabi (on testnet)
  3. Open a wallet
  4. Generate a new address
  5. Using the context menu copy the bip21 bitcoin uri to the clipboard
  6. Go to Send Tab
  7. Paste the bitcoin uri in the destination textbox (you have to see an onion endpoint in the payjoin endpoint textbox)
  8. Select a random coin
  9. Press Max
  10. Click on Send Transaction.

This is a PoC and that means that I want to evaluate the feasibility of the concept in wasabi. Do not expect perfect behavior always because the checks are not implemented.

@MaxHillebrand
Copy link
Member

MaxHillebrand commented Apr 24, 2020

~/WalletWasabi/WalletWasabi.Gui$ sudo killall tor
~/WalletWasabi/WalletWasabi.Gui$ dotnet run 
2020-04-24 11:06:47 INFO	WalletManager (30)	.ctor finished in 385 milliseconds.
2020-04-24 11:06:47 INFO	Global (83)	.ctor finished in 891 milliseconds.
2020-04-24 11:06:47 INFO	Program (43)	Wasabi GUI started (95ef6d22-7083-4e05-b004-fb0dbd53d7ee).
2020-04-24 11:06:49 INFO	TorProcessManager (253)	Starting Tor monitor...
2020-04-24 11:06:49 INFO	Global (172)	TorProcessManager is initialized.
2020-04-24 11:06:49 INFO	TransactionStore (29)	MempoolStore.InitializeAsync finished in 144 milliseconds.
2020-04-24 11:06:49 INFO	TorProcessManager (118)	Tor instance found at /home/user/.walletwasabi/client/tor/Tor/tor.
2020-04-24 11:06:49 INFO	TorProcessManager (147)	Started Tor process with shell command: LD_LIBRARY_PATH=$LD_LIBRARY_PATH:=/home/user/.walletwasabi/client/tor/Tor && export LD_LIBRARY_PATH && cd /home/user/.walletwasabi/client/tor/Tor && ./tor --SOCKSPort 127.0.0.1:9050 --DataDirectory /home/user/.walletwasabi/client/tordata --GeoIPFile /home/user/.walletwasabi/client/tor/Data/Tor/geoip --GeoIPv6File /home/user/.walletwasabi/client/tor/Data/Tor/geoip6 --HashedControlPassword 16:F44A5EEADC1D0EDC6074748B610587E5348B2914231E9292E2F4C8B1DF --ControlPort 9051 --Log "notice file /home/user/.walletwasabi/client/TorLogs.txt".
2020-04-24 11:06:49 CRITICAL	Global (379)	System.Net.Sockets.SocketException (111): Connection refused
   at System.Net.Sockets.Socket.BeginConnectEx(EndPoint remoteEP, Boolean flowContext, AsyncCallback callback, Object state)
   at System.Net.Sockets.Socket.UnsafeBeginConnect(EndPoint remoteEP, AsyncCallback callback, Object state, Boolean flowContext)
   at System.Net.Sockets.Socket.BeginConnect(EndPoint remoteEP, AsyncCallback callback, Object state)
   at System.Net.Sockets.Socket.BeginConnect(IPAddress address, Int32 port, AsyncCallback requestCallback, Object state)
   at System.Net.Sockets.TcpClient.BeginConnect(IPAddress address, Int32 port, AsyncCallback requestCallback, Object state)
   at System.Net.Sockets.TcpClient.<>c.<ConnectAsync>b__27_0(IPAddress targetAddess, Int32 targetPort, AsyncCallback callback, Object state)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncImpl[TArg1,TArg2](Func`5 beginMethod, Func`2 endFunction, Action`1 endAction, TArg1 arg1, TArg2 arg2, Object state, TaskCreationOptions creationOptions)
   at System.Threading.Tasks.TaskFactory.FromAsync[TArg1,TArg2](Func`5 beginMethod, Action`1 endMethod, TArg1 arg1, TArg2 arg2, Object state, TaskCreationOptions creationOptions)
   at System.Threading.Tasks.TaskFactory.FromAsync[TArg1,TArg2](Func`5 beginMethod, Action`1 endMethod, TArg1 arg1, TArg2 arg2, Object state)
   at System.Net.Sockets.TcpClient.ConnectAsync(IPAddress address, Int32 port)
   at WalletWasabi.TorControl.TorControlClient.ConnectAsync() in /home/user/WalletWasabi/WalletWasabi/TorControl/TorControlClient.cs:line 27
   at WalletWasabi.Gui.P2EP.P2EPServer.StartAsync(CancellationToken cancellationToken) in /home/user/WalletWasabi/WalletWasabi.Gui/P2EP/P2EPServer.cs:line 36
   at WalletWasabi.Gui.Global.InitializeNoWalletAsync() in /home/user/WalletWasabi/WalletWasabi.Gui/Global.cs:line 186
2020-04-24 11:06:49 WARNING	Global (653)	Process is exiting.
2020-04-24 11:06:50 INFO	Global (727)	Synchronizer is stopped.
2020-04-24 11:06:50 INFO	TransactionStore (29)	ConfirmedStore.InitializeAsync finished in 457 milliseconds.
2020-04-24 11:06:50 INFO	AllTransactionStore (28)	InitializeAsync finished in 533 milliseconds.
2020-04-24 11:06:50 INFO	HostedServices (80)	Stopped Software Update Checker.
2020-04-24 11:06:50 INFO	HostedServices (130)	Disposed Software Update Checker.
2020-04-24 11:06:50 INFO	Global (736)	Stopped background services.
2020-04-24 11:06:50 INFO	Global (785)	TorManager is stopped.
2020-04-24 11:06:50 DEBUG	AsyncMutex (419)	Waiting for: MatureIndex-76A7981, ImmatureIndex-C37E732.
2020-04-24 11:06:50 ERROR	AsyncMutex (330)	OperationCanceledException: AsyncMutex.LockAsync failed because quit is pending on: Transactions-1BE1821. in Transactions-1BE1821.
2020-04-24 11:06:50 ERROR	TransactionStore (391)	System.IO.IOException: Could not acquire system wide mutex on Transactions-1BE1821.
 ---> System.OperationCanceledException: AsyncMutex.LockAsync failed because quit is pending on: Transactions-1BE1821.
   at Nito.AsyncEx.AsyncMutex.LockAsync(CancellationToken cancellationToken, Int32 pollInterval) in /home/user/WalletWasabi/WalletWasabi/Nito/AsyncEx/AsyncMutex.cs:line 281
   --- End of inner exception stack trace ---
   at Nito.AsyncEx.AsyncMutex.LockAsync(CancellationToken cancellationToken, Int32 pollInterval) in /home/user/WalletWasabi/WalletWasabi/Nito/AsyncEx/AsyncMutex.cs:line 338
   at WalletWasabi.Blockchain.Transactions.TransactionStore.TryCommitToFileAsync(ITxStoreOperation operation) in /home/user/WalletWasabi/WalletWasabi/Blockchain/Transactions/TransactionStore.cs:line 309
2020-04-24 11:06:52 INFO	Global (415)	Loaded AddressManager from `/home/user/.walletwasabi/client/AddressManager/AddressManagerTestNet.dat`.
2020-04-24 11:06:52 INFO	MainWindow.xaml (109)	UiConfig is saved.
2020-04-24 11:06:53 INFO	MainWindow.xaml (117)	WalletManagerViewModel closed.
2020-04-24 11:06:58 INFO	IndexStore (45)	InitializeAsync finished in 8 seconds.
2020-04-24 11:06:58 INFO	BitcoinStore (39)	InitializeAsync finished in 8 seconds.
2020-04-24 11:06:58 INFO	Global (793)	AsyncMutex(es) are stopped.
2020-04-24 11:06:58 INFO	Global (809)	Wasabi stopped gracefully (95ef6d22-7083-4e05-b004-fb0dbd53d7ee).

@MaxHillebrand
Copy link
Member

MaxHillebrand commented Apr 24, 2020

I think I did this before, but now it worked...

First, sudo killall tor,
then, dotnet run, which will fail with the above logs,
then again, dotnet run, [not again sudo killall tor] which will make the build succeed.

I made a successful transaction with @lontivero, and it worked flawlessly, despite both of us having very shitty internet connection.

There is a notification when the PayJoin is being negotiated.
screenshot_20200424_160723

You can do a PayJoin within the same wallet, so receiving address and spending coin are both form the same wallet. Still, it does some negotiation over tor. Is this necessary / desired?

The sender sees Building Transaction in the status bar - maybe this can be changed to Negotiating PayJoin or something [this is not specific to this PR, rather the other sending payjoin PR].

@lontivero
Copy link
Collaborator Author

Really cool but it is not time for this yes. We have to be able to control Tor and that's something we cannot do right now. Closing, we can revive it later.

@DanGould
Copy link
Contributor

@lontivero what part of tor was not able to be controled at the time of this PoC?

@nopara73
Copy link
Contributor

@DanGould, @adamPetho is going to work on this (RPC only.) I think he'd love to take your help.

@lontivero
Copy link
Collaborator Author

@DanGould to do this Wasabi needs to create an ephemeral onion services and also destroy them, for that it needs to be able to connect and authenticate against the Tor control port. This means you have to start Tor with the control port activated.

This PoC implements a TorControlClient that is a toy, less than100 LoC, which authenticates with password instead of cookie. I created a library for controlling Tor with the goal of using it in Wasabi but it is not read yet: https://github.com/lontivero/torino

@nopara73 I don't understand what you mean by RPC here but just in case I want to let clear that exposing the RPC endpoint to internet is the worse idea ever, anyway i am sure that's not what you mean.

@adamPetho
Copy link
Collaborator

@DanGould Yes, i gladly accept any help

@DanGould
Copy link
Contributor

@adamPetho I'm active on slack & looking forward to collaborating 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants