[SIDESWAP] Fix USDt to LBTC atomic swap - dealer's suggested recv_amount#83
[SIDESWAP] Fix USDt to LBTC atomic swap - dealer's suggested recv_amount#83coelhogonzalo wants to merge 2 commits into
Conversation
31e89c4 to
e620ac6
Compare
|
I contacted the Blockstream team and asked if they could update the python binding to expose a Python-callable TxOut.unblind_with_ephemeral_sk(ephemeral_sk, address_blinding_pk) Will update this PR when they reply. |
e620ac6 to
eefcedd
Compare
43478b0 to
ae436f2
Compare
I fixed it by using wallycore directly. |
andycreed0x
left a comment
There was a problem hiding this comment.
Good fix! Thanks for the PR
| change_addr: Optional[str], | ||
| receive_ephemeral_sk: Optional[str], | ||
| change_ephemeral_sk: Optional[str], | ||
| addr_family: str = "lq", |
There was a problem hiding this comment.
You can make this testnet-compatible with a small change. As-is, this would break if you ever want to test swaps on testnet. From Claude's analysis:
addr_family is always hardcoded to "lq", but testnet addresses use tlq. So confidential_addr_segwit_to_ec_public_key(tlq1..., "lq") will throw a raw ValueError before ever reaching the PSET.
# In _verify_pset, derive and pass addr_family:
addr_family = "tlq" if network == "testnet" else "lq"| recv_delta = balances.get(recv_asset, 0) | ||
| if recv_delta != recv_amount: | ||
| if recv_asset == fee_asset: | ||
| min_recv_delta = recv_amount - fee_tolerance_sats |
There was a problem hiding this comment.
If recv_amount < fee_tolerance_sats, min_recv_delta goes negative, meaning a dealer could deliver 0 of the receive asset and still pass verification.
# Clamp to zero so the tolerance can't exceed the agreed amount
min_recv_delta = max(0, recv_amount - fee_tolerance_sats)| ) | ||
|
|
||
|
|
||
| def unblind_dealer_outputs( |
There was a problem hiding this comment.
The whole function is mocked out in every swap manager test.
(Something I always ask myself when reviewing: "is this test actually exercising the real functions and hitting the DB, or is everything mocked?"... might be useful for building tests.)
According to Claude:
what's missing is a test that doesn't patch this function and feeds it a real PSET ideally one honest case and one with a tampered asset.
|
Conflict in pyproject.toml appeared after PR #97 merged — likely a version bump conflict. Please rebase onto develop to resolve before merging. |
ae436f2 to
58afce3
Compare
closes #66 for more details check the ticket