Skip to content

Add L-BTC funding option to WapuPay direct-fiat orders#122

Draft
andycreed0x wants to merge 1 commit into
developfrom
use-lbtc-on-wapupay
Draft

Add L-BTC funding option to WapuPay direct-fiat orders#122
andycreed0x wants to merge 1 commit into
developfrom
use-lbtc-on-wapupay

Conversation

@andycreed0x

Copy link
Copy Markdown
Collaborator

Purpose

Direct-fiat orders created via WapuPay can now be funded with L-BTC on Liquid, in addition to USDT. Sending funding_method: "LBTC" on order creation gets a Liquid address funded with real satoshis instead of USDT.

Description

Verified live against WapuPay's stage sandbox for both rails, including the order-status / fund-order reload paths. The quote/preview endpoint (tentative-amount) returns a 500 for LBTC, so wapupay_quote and the CLI's pre-confirm preview intentionally stay USDT-only and never pass funding_method.

Main Changes

  • ✨ Add funding_method param ("USDT" default / "LBTC") to WapuPayManager.create_order, validated up front before any network call
  • ✨ Thread funding_method through the MCP tool (wapupay_create_order), the MCP input schema, and the CLI (aqua wapupay create-order --funding-method)
  • ✨ Make pay_instructions currency-aware: the L-BTC rail tells the caller to send the real funding_amount_sat sats, instead of USDT-derived base units
  • 🐛 Fix WapuPayOrder.from_dict silently dropping funding_amount_sat for any Liquid-network order — it assumed Liquid always meant USDT, which would have wiped the real L-BTC sat amount on every reload (order-status, orders, fund-order). Now keyed off funding_currency instead of funding_network alone
  • 🐛 Clear total_funding_amount_base_units on the L-BTC rail so a USDT-scale figure is never paired with the L-BTC asset_id in the response (found and fixed during adversarial review — a defensive guard against a would-be ~10⁸x overpayment if a consumer read that field directly instead of pay_instructions)
  • 📝 Correct the now-inaccurate "rail pinned to Liquid USDT" claims in AGENTS.md and module docstrings
  • ✅ Add tests: LBTC order creation/persistence round-trip, invalid funding_method rejection, from_dict sat-preservation regression, USDT default preserved, and a money-safety regression test for the base-units guard

Checklist

  • No hardcoded values (they should go in constants.py, .env, or our database)
  • Added/updated tests (if necessary)
  • Added/updated relevant documentation (if necessary)

Direct-fiat orders can now be funded with L-BTC on Liquid, not just
USDT. Add a `funding_method` param (default "USDT") threaded through
create_order → the MCP tool → the MCP schema → the CLI
(`--funding-method`), and make pay_instructions currency-aware: the
L-BTC rail sends real satoshis (funding_amount_sat) instead of
USDT-derived base units.

Also fixes a persistence bug this feature would otherwise trigger:
WapuPayOrder.from_dict dropped funding_amount_sat for any Liquid-network
order, assuming Liquid always meant USDT. That wiped the real L-BTC sat
amount on every reload (order-status, orders, fund-order). Now keyed off
funding_currency instead, and total_funding_amount_base_units is cleared
on the L-BTC rail so a USDT-scale figure is never paired with the L-BTC
asset_id.

The quote/preview endpoint stays USDT-only (WapuPay 500s on LBTC there),
so wapupay_quote and the CLI's pre-confirm preview are untouched.

Verified live against WapuPay's stage sandbox for both rails, including
the order-status/fund-order reload paths.
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