Commit da2a702
fix: cooperative close uses actual spent amount instead of voucher ceiling
On cooperative close, the server required the close voucher's
cumulativeAmount to be >= highest_voucher_amount (the pre-authorized
reservation). This meant clients were charged the full reservation
even when actual usage was much lower (e.g., $4 for a SELECT 1 query).
This ports the fix from mppx (wevm/mppx#196) and wallet
(tempoxyz/wallet#349):
1. The minimum close amount is now max(channel.spent, on_chain.settled)
instead of highest_voucher_amount, allowing clients to close at
actual usage cost.
2. The store update only overwrites highest_voucher_amount when the
close amount is actually higher, preserving the original voucher
for settlement if the close is at a lower (actual spent) amount.
Amp-Thread-ID: https://ampcode.com/threads/T-019d5503-2e85-70ff-81ed-b5093c920fd5
Co-authored-by: Amp <amp@ampcode.com>1 parent dfea6bb commit da2a702
1 file changed
+26
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
821 | 821 | | |
822 | 822 | | |
823 | 823 | | |
824 | | - | |
825 | | - | |
826 | | - | |
827 | | - | |
828 | | - | |
829 | | - | |
830 | 824 | | |
831 | 825 | | |
832 | 826 | | |
| |||
839 | 833 | | |
840 | 834 | | |
841 | 835 | | |
842 | | - | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
843 | 847 | | |
844 | | - | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
845 | 852 | | |
846 | 853 | | |
847 | 854 | | |
| |||
948 | 955 | | |
949 | 956 | | |
950 | 957 | | |
| 958 | + | |
951 | 959 | | |
952 | 960 | | |
953 | | - | |
954 | | - | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
955 | 971 | | |
956 | 972 | | |
957 | 973 | | |
| |||
0 commit comments