feat(cli): serve the RFC 0006 payment surface from a development purse - #745
Draft
tommyldev wants to merge 1 commit into
Draft
feat(cli): serve the RFC 0006 payment surface from a development purse#745tommyldev wants to merge 1 commit into
tommyldev wants to merge 1 commit into
Conversation
The headless host answered every payment.* call with PermissionDenied or "Payments are not supported", so a product could not exercise its balance or top-up flow outside the phone hosts. A host can now install a PaymentPurse on the signing-host runtime; the CLI installs a development purse persisted in the session directory that discloses balances without a prompt and credits top-ups from a product account without moving funds. Hosts without a purse answer exactly as before.
|
CI Status: not green, 1 item needs attention.
All job results
Commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
truapi-host devnow serves the RFC 0006 payment surface from a local development purse:payment.subscribeBalanceandpayment.topUpwork against a JSON-backed balance instead of failing withPermissionDenied/Unknown("Payments are not supported in dot.li"). To get there,truapi-platformgains aPaymentPursetrait that any host can install on the signing-host runtime, and the CLI installs a dev implementation of it.Before this, a product could only exercise its balance or top-up flow on the iOS/Android hosts.
What changes
truapi-platform: newPaymentPursetrait withsubscribe_balance(purse) -> BoxStream<Balance>(current value first, then every change) andtop_up(purse, amount, source). It is not aPlatformsupertrait. LikePermissionStatusHost, it is installed set-once on the runtime, so existing platform implementations do not change.truapi-server:RuntimeServicesholds the installed purse, set throughSigningHostRuntime::set_payment_purse.Payment::balance_subscribeandtop_uproute to it when present. Without a purse the responses are identical to before;wire_result_shapepasses unchanged, so desktop and web behaviour does not move.requestandstatus_subscribestay unimplemented.truapi-host-cli:dev_purse.rskeeps per-purse balances in<session>/dev-purse.json. Atokio::sync::watchfan-out gives every subscriber the current balance, then deduplicated changes.top_upcredits from aProductAccountsource and rejectsPrivateKeyandCoinswithInvalidSourcerather than pretending to spend a pasted secret. Balance disclosure needs no prompt because the CLI already auto-approves every confirmation.truapi-codegen: goldenhost-callbacks.tsgains the additivePaymentPurseinterface.Scope
A top-up credits the purse and moves nothing on chain; the log line says so. The purse is a plain number for exercising product flows on testnets. A wallet-backed host would implement the same trait against real funds.
Verified
cargo fmt --check,cargo clippy --all-targetson the three crates: clean.cargo test -p truapi-host-cli dev_purse(2),-p truapi-server --test wire_result_shape(13, unchanged),-p truapi-codegen(goldens),-p truapi-platform: pass.truapi-host dev --network previewnet:payment.subscribeBalancepushes0,payment.topUp(1_250_000, ProductAccount{Index(1)})returns ok, the subscription pushes1250000, anddev-purse.jsonpersists it across a restart.Open questions for review
--dev-purse) rather than installing it unconditionally indev?PaymentPursealso coverrequest/status_subscribenow, or wait for a real backend?