1
0
Files
electrum/electrum
SomberNight 63ea5587a2 swaps: revise send/recv amount calculation
- document SwapManager._get_recv_amount and SwapManager._get_send_amount
- change calculations so that they match the boltz-backend
  - note that in the reverse swap case, the server does not care about the on-chain claim tx the client
    needs to pay for. This introduced some implicit hacks and inconsistencies in the code in the past,
    it is still a bit ugly but at least this is now explicit.
- SwapManager._get_recv_amount and SwapManager._get_send_amount are now proper inverses of each other

-----

Here are some code snippets to play around with in Qt console.
For the forward swap case:
```
from electrum import ecc; lnworker = wallet.lnworker; sm = lnworker.swap_manager

invoice = network.run_from_another_thread(lnworker.create_invoice(amount_msat=3000000*1000, message="swap", expiry=86400))[1]; request_data = {"type": "submarine", "pairId": "BTC/BTC", "orderSide": "sell", "invoice": invoice, "refundPublicKey": ecc.GENERATOR.get_public_key_bytes().hex()}

network.send_http_on_proxy('post', sm.api_url + '/createswap', json=request_data, timeout=30)

sm.get_send_amount(3000000, is_reverse=False)
sm.get_recv_amount(3026730, is_reverse=False)
```

For the reverse swap case:
```
from electrum import ecc; import os; lnworker = wallet.lnworker; sm = lnworker.swap_manager

request_data = {"type": "reversesubmarine", "pairId": "BTC/BTC", "orderSide": "buy", "invoiceAmount": 3000000, "preimageHash": os.urandom(32).hex(), "claimPublicKey": ecc.GENERATOR.get_public_key_bytes().hex()}

network.send_http_on_proxy('post', sm.api_url + '/createswap', json=request_data, timeout=30)

sm.get_recv_amount(3000000, is_reverse=True)
sm.get_send_amount(2974443, is_reverse=True)
```
2021-03-28 18:36:04 +02:00
..
2021-02-17 17:28:13 +01:00
2021-03-21 00:36:23 -04:00
2020-06-23 19:25:07 +02:00
2021-03-19 10:17:02 +01:00
2020-08-20 18:58:52 +02:00
2021-03-19 10:17:02 +01:00
2021-03-23 17:30:40 +01:00
2021-03-21 00:36:23 -04:00
2021-03-26 14:28:34 +01:00
2020-06-05 13:17:01 +02:00
2021-03-21 00:36:23 -04:00
2021-03-21 00:36:23 -04:00
2021-03-21 00:36:23 -04:00
2021-03-03 15:35:38 +01:00
2021-03-21 00:36:23 -04:00
2021-03-21 00:36:23 -04:00
2021-03-20 18:26:58 +00:00
2021-03-12 12:41:10 +01:00
2021-03-21 00:36:23 -04:00
2021-03-25 19:33:40 +01:00
2021-03-21 00:36:23 -04:00
2021-03-21 00:36:23 -04:00
2021-02-23 22:38:53 +01:00
2019-02-11 20:21:24 +01:00
2020-10-23 02:17:31 +00:00
2021-03-21 00:36:23 -04:00
2021-03-21 00:36:23 -04:00