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

Send Payjoin #365

Merged
merged 4 commits into from
Dec 20, 2024
Merged

Send Payjoin #365

merged 4 commits into from
Dec 20, 2024

Conversation

DanGould
Copy link
Contributor

@DanGould DanGould commented Dec 19, 2024

This is a basic sender implementation that may be merged so we can build off of it. It does not include any isolate behavior or do accounting properly. I would like help getting the accounting right by taking data from a signed payjoin and pushing it into the Transaction model @ethicnology.

This separates the signing and "confirmed" stages and marshals successful payjoins to the final screen. I don't think a new payjoin handshake screen is merited until the isolates can allow that behavior to happen outside of the send cubit.

Please see the commit log for hacks taken to get this working.

For a payjoin send:

  • when a payjoin address is pasted the UI should mention that the transaction is a payjoin on the build tx page (3rd commit)
  • the build process should be separated from the confirm process and we should have a screen to confirm the details (2nd commit)
  • after confirm there should be a status page for the payjoin (similar to swaps) - there is an option to exit and go to the transaction detail page or go back home
  • there should be a toast that notifies the user when a payjoin broadcasts
  • uri & address copy / paste should be separate

I ask reviewers to confirm errors are handled appropriately, since this flutter paradigm is new to me.

@ethicnology
Copy link
Collaborator

rebased on upstream/main

@DanGould
Copy link
Contributor Author

Thanks for the rebase.

@DanGould
Copy link
Contributor Author

There is a bug in here where after multiple sends the sender will throw: flutter: BdkError.electrum(field0: Electrum server error: "sendrawtransaction RPC error -26: {"code":-26,"message":"mandatory-script-verify-flag-failed (Witness program hash mismatch)"}") which must be from the broadcast call. My hunch is that the sender is trying to spend a UTXO that's already been spent but the wallet history hasn't updated, so the spend check during broadcast fails.

@DanGould DanGould force-pushed the pj branch 8 times, most recently from 4b49339 to 373616c Compare December 20, 2024 19:30
@i5hi
Copy link
Collaborator

i5hi commented Dec 20, 2024

The remaining UI related items can be left out of this PR

spacebear21 and others added 3 commits December 20, 2024 15:10
Parse the payjoin endpoint as a URI and add it to SendState.
Sends payjoin in place using the build, send, confirm flow.

There are 2 hacks to get this to work that I'm sure must be worked out.

1. BIP21 Uris are mangled by dart's Uri struct since BIP21 and form URI
   encoding are different specifications. This requires some reencoding
   of bip21 values before the sender gets initialized.

   In the future, the bip21 implementation here must be made spec
   compliant, perhaps by depending on the rust crate so as to use the
   same types in bdk, payjoin-flutter, etc.

2. TransactionDetails used to display historical data are missing. BDK
   defines a TransactionDetails type which is now deprecated in BDK 1.0
   which includes details like 'address', 'sent' amount, and 'received'
   amount. This PR makes no attempt to follow this paradigm.

   Somehow historical data must be populated so that history is
   accurately populated and the confirm screen and confirmed screen
   displays correct information.
This also toggles the text on the Confirm screen to give user state context.
This still ignores UI updates from the spawned isolate and doesn't even
have a proper splash screen for a confirmed send.

It has also yet to be smoke tested
@i5hi
Copy link
Collaborator

i5hi commented Dec 20, 2024

ACK!
Cheers @DanGould !

@i5hi
Copy link
Collaborator

i5hi commented Dec 20, 2024

I'll patch the linting issues after merge so we can move forward.

@i5hi i5hi merged commit 0d12316 into SatoshiPortal:main Dec 20, 2024
0 of 3 checks passed
@i5hi i5hi self-assigned this Dec 23, 2024
@ethicnology ethicnology removed their request for review December 23, 2024 13:22
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.

4 participants