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

Implement ReceiveOnly and ReceiveSend signer types #106

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

irriden
Copy link
Collaborator

@irriden irriden commented Aug 20, 2023

This passes the following test:

Two signers connected to broker. One is ReceiveSend, the other is ReceiveOnly.

First send some keysends to the node, with ReceiveOnly settling them.

Then send a keysend to the other way, from the node to a peer.

Broker immediately switches to the ReceiveSend signer, syncs the state, and sends the keysend.

It's all about watching for PreapproveKeysend and PreapproveInvoice messages, and switching to the appropriate ReceiveSend signer when these come through.

Watching for on-chain sends still todo.

@irriden
Copy link
Collaborator Author

irriden commented Aug 20, 2023

Should address #105

reads the first byte of the hello message payload to determine the type.
if the payload is empty, the signer type is receivesend, otherwise,
whatever the byte specifies.
signer types are then stored as values in the conns hash table
whenever a signer is added to it.
make it optional just like the cid field.
Everytime CLN wants to pay an invoice, or send a keysend, the very first
message it sends is either PreapproveInvoice, or PreapproveKeysend. So
these should go only to signers that have the send feature.
If for some reason the send signer crashes, and broker starts talking to
a receiveonly signer, 1) broker will see that it's receive only, so it
will wait for a send signer to connect back. 2) if broker still sends,
the receive only signer can be programmed to immediately reject any
preapprove messages.
Copy link
Collaborator

@Evanfeenstra Evanfeenstra left a comment

Choose a reason for hiding this comment

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

  • in broker/src/main, you removed the client_action, which can set the connected status to true or false. Instead you added add_client. So there is no way for a signer to disconnect anymore (by publishing BYE)

  • why does connections.current need (String, SignerType)? Since we have the SignerType in the client map anyway.. seems like its stored in two places?

@irriden
Copy link
Collaborator Author

irriden commented Sep 5, 2023

I think I've addressed point 2 here: 9f5be6f

Now wondering if instead of ReceiveOnly and ReceiveSend we should have three independent bit flags so to speak - Signer, Receive, Send.

ReceiveOnly would have Signer and Receive set.
ReceiveSend would have Signer, Send, and Receive set.
And if you wanted a message to be signed by any signer, you would only set Signer.

@irriden
Copy link
Collaborator Author

irriden commented Sep 5, 2023

This could help get rid of these weird cases where the signer type is set to None maybe? Haven't looked closely.

@Evanfeenstra
Copy link
Collaborator

To be honest i think ReceiveOnly and ReceiveSend is simpler to understand

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.

2 participants