Repository navigation
Conversation
Coverage Report for CI Build 38081510397Coverage decreased (-0.03%) to 87.465%Details
Uncovered Changes
Coverage Regressions1 previously-covered line in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
5aec996 to
765bad7
Compare
Agree this is not very ergonomic to implement. I see three options:
Of the 3 I think the first would be the most useful and would also allow callers to access the fallback tx from any state that has a fallback tx, however I would like to hear other's thoughts on this since it involves exposing new things on the public API (@DanGould @spacebear21 ). Also interested in your opinion. For the cut through
Can you expand on what you mean by "fund it from a contributed input"? At this point there should not be any contributed inputs yet. Or are you just saying you're not adjusting the original output's value and just forcing sufficient inputs to be added later? I think thats appropriate. That said, should we maybe ensure that the input selected has sufficient value to cover the cut through output? and if no sufficient utxos exist throw an error?
I don't think you have to account for this as |
|
Rather than passing the mutable state around, I agree if the I think that means on FFI, this function would need to be added to every relevant struct, which could be done with a macro. |
|
Indeed the point of the issue is to figure out if our API can accommodate these use cases ergonomically. We need to look in Shepherd and SatSigner to figure out how they're using Cut-Through with our API and should have them listed here before deciding on an API change. |
This is mistaken: v2 URIs hardcode disabled strictly for backwards compatibility purposes, but v2 senders ignore this parameter, so a v2 receiver may still substitute outputs. IMO it's nice for the receiver to have the option to fund the cut-through with an input of their own, but I don't think that decision should be forced upon them (unless maybe the sender actually signals disabled output substitution). |
|
Regarding exposing the fallback tx on every typestate: one limitation to that approach is that it refers only to the original transaction, not the working proposal. After one substitution the receiver output it shows no longer exists. The WantsOutputs typestate was designed to allow calling these methods multiple times, e.g. for an exchange service facilitating batch withdrawals. It might be more correct to expose only |
|
I think |
|
Yes I think it's probably a good idea to split this PR in two independent ones |
|
at risk of overcommunicating @AdamuAbba please save the 2nd commit to a draft pr and drop it from this PR so that we can review and merge that on its own and keep the ball moving. Thanks for keeping up here and for this PR. |
|
@xstoicunicornx to answer your question:
Your second reading is the right one, and sorry for the wording: nothing is contributed at rust-payjoin/payjoin-cli/src/app/wallet.rs Lines 211 to 240 in 765bad7 Thanks for pointing me in the right direction, guys. I really appreciate the help. I'm going to go ahead with the instructions to split up this PR. Once #1949 is addressed, I can refactor the |
765bad7 to
28e59c7
Compare
--consolidate and --cut-through modes--consolidate mode
The receiver API accepts a list of inputs, letting a receiver merge their own UTXOs into the payjoin output rather than paying for a separate consolidation transaction. Only the integration tests demonstrated this; payjoin-cli always contributed a single privacy-preserving input. Add --consolidate [N] to `receive`, contributing up to N of the smallest available UTXOs on both the v1 and v2 receiver paths. Smallest first because every input costs the same to spend regardless of value, so small UTXOs are the ones worth merging. Store the choice per-session in the `receive_sessions` table. The resume path never sees the original command line, and for v2 that is the common case rather than an edge case: a receiver typically publishes a BIP21, goes offline, and returns to `resume` after the sender has posted, which is the run that reaches contribute_inputs. N defaults to 10 because BIP77 pads every message to a fixed size, capping the payjoin proposal at 7088 bytes. Contributing more than fits fails when the proposal is posted, leaving the session to be cancelled in favour of the fallback transaction. Signed-off-by: shytypes <[email protected]>
28e59c7 to
5fb019b
Compare
|
If this were mine to review I might look at how BitGo, Fortris etc think about interface they present to users for consolidation. IDK if it's by a certain number of coins Some people are already offering good consolidation & coin control as a savings benefit people are happy about. Leverage their work, because ultimately this is a reference for integrations with their systems. |
|
Thanks @DanGould, really useful steer. Agreed the CLI should mirror what integrators already offer. I'll catalogue how BitGo, Fortris and others expose consolidation (coin count, target, fee-rate or time based) and post my findings here before settling the flag's shape. P.S. I had to look up "clanker"... I should rewatch Star Wars 😅 |
|
Hey @DanGould, sorry this took a while. I catalogued how BitGo, Fortris and others expose consolidation:
BitGo's SDK is open source, but coin selection runs on its closed servers. I found no public Fortris code, so its column comes from its website and blog. BTCPay and Bull Bitcoin always contribute one input as payjoin receivers, so an N-input cap appears to be new. My proposal: keep
A fee-rate gate is possible too. I'd leave out a schedule, since a payjoin happens when a payment arrives. A target coin count could work as a stopping rule across payments, but BitGo's v2 API doesn't offer one and I found nobody else who does, so I'd skip it unless you see a use. What do you think of this direction? Disclosure: I used Claude for the research and to help structure this comment. |
Description
This PR Adds the first of the two receiver capabilities from #1859 to Payjoin CLI.
--cut-throughhas been split into its own PR, since it depends on #1949 exposing the fallback transaction on the receiver states that hold one.Commits
5fb019b:
--consolidateAdds
--consolidate [N]toreceive, contributing up to N of the smallest available UTXOs on both the v1 and v2 receiver paths instead of the single privacy-preserving input.For anyone reviewing this commit:
The cap exists because of the BIP77 message size limit. Padding leaves 7088 bytes for the receiver's reply (
PADDED_PLAINTEXT_B_LENGTH); I hit 33,183 with a large UTXO set. It only fails when the receiver tries to post the proposal, so the session has to be cancelled in favour of the fallback. 10 seemed like a safe default; I haven't worked out where the real limit falls.The setting is persisted per session.
Configonly reads the flags when the subcommand isReceive, so aresumerun never sees them, and for v2resumeis the normal path, since that is usually the run reachingcontribute_inputs. The choice is stored in the CLI'sreceive_sessionstable as a serialisedreceive_optionscolumn, matching howreceive_session_events.event_dataalready works. It reads as an application preference rather than protocol state.This is the first schema migration in
db/mod.rs.CREATE TABLE IF NOT EXISTSleaves an existing table untouched, so upgrading databases would not get the column. There is an explicitALTER TABLEguarded by apragma_table_infocheck.Smallest UTXOs first, via a new
select_receiver_utxos.list_unspentkeeps its ordering sotry_preserving_privacyis unchanged.Testing:
receiver_consolidates_utxos_v2asserts the receiver's five UTXOs become one, and covers the persistence above since everything after the BIP21 runs throughresume. The v1 path is covered by compilation only.Follow-up
--cut-throughis written and working on both receiver paths, with its own e2e test, but it currently keeps a copy of the original transaction and passes it alongside the session to reachWantsOutputs. Once #1949 is addressed I can drop that workaround, refactor the commit and open it for review.Disclosure: co-authored by Claude Code
Pull Request Checklist
Please confirm the following before requesting review: