REElay 😡: BIP 78-compatible Gullible Payjoin PoC (WebSockets) #78
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.
This proof of concept demonstrates the ability to receive a payjoin using a relay instead of hosting a public
https
oronion
endpoint. I intend this to be an easy way to receive payjoin in testing environments and potentially as a BIP 78 payjoin v1 compatible fallback for a v2 Serverless Payjoin spec.BIP 78 Compatibility
The PSBT payload is neither encrypted nor authenticated, so it is compatible with BIP-78 senders without any changes. According spec terminology, the REElay is an unsecured payjoin server, so output substitution must be disabled. Unlike in a v2 Serverless Payjoin, there is no privacy protection from the REElay server.
Protocol Flow
bitcoin:BCRT1QGSKP9RN59L3KXJQPC5RNDC7M50RCH36WUV6232?amount=0.00888888&pj=https://reelay&pjos=0
&pj=
endpoint containing an Original PSBT body.The interaction is unchanged BIP 78 from the sender's perspective. The new protocol burden is shared between REElay and receiver.
Design
WebSockets allows a persistent connection so that the REElay may respond with
unavailable
if no receiver is connected. Using both HTTP and WebSockets allows for compatibility with existing deployments. The REElay server could support a secure, non-REE, asynchronous, version 2 payjoin protocol and offer the synchronous REElay version as a fallback to support senders having only payjoin v1 support. A production version could use any streaming protocol, not limited to WebSockets, and should use the same dependency as a v2 payjoin protocol to minimize network dependency requirements.What's missing?
Allocation
This PoC only hosts a single endpoint to receive payjoins at root. A production version would require a mechanism for receivers to allocate a subdirectory from which POST requests would be relayed. There has to be some way for the REElay to know who to relay requests to.
DoS Protection
There is no protection from someone connecting to the websocket over and over using up all of the REElay server's resources. There should be some API Token (warning: identifying), PoW (expensive), or other cost associated with making an allocation