1
0

Remove zeroconf option for submarine swaps

Since we now accept random swap providers, it is unreasonable
to keep that option.
This commit is contained in:
ThomasV
2025-03-21 18:14:19 +01:00
parent 3db26c4ecb
commit 6e92a00ec4
4 changed files with 5 additions and 28 deletions

View File

@@ -70,7 +70,6 @@ MSG_FORWARD_SWAP_FUNDING_MEMPOOL = (
MSG_REVERSE_SWAP_FUNDING_MEMPOOL = ( MSG_REVERSE_SWAP_FUNDING_MEMPOOL = (
_('The funding transaction has been detected.') + " " + _('The funding transaction has been detected.') + " " +
_('Your claiming transaction will be broadcast when the funding transaction is confirmed.') + " " + _('Your claiming transaction will be broadcast when the funding transaction is confirmed.') + " " +
_('You may choose to broadcast it earlier, although that would not be trustless.') + " " +
_("If you go offline before broadcasting the claiming transaction and let the swap time out, " _("If you go offline before broadcasting the claiming transaction and let the swap time out, "
"you will not get back the already pre-paid mining fees.") "you will not get back the already pre-paid mining fees.")
) )

View File

@@ -46,11 +46,10 @@ class SwapDialog(WindowModalDialog, QtEventListener):
self.is_reverse = is_reverse if is_reverse is not None else True self.is_reverse = is_reverse if is_reverse is not None else True
vbox = QVBoxLayout(self) vbox = QVBoxLayout(self)
toolbar, menu = create_toolbar_with_menu(self.config, '') toolbar, menu = create_toolbar_with_menu(self.config, '')
menu.addToggle( menu.addAction(
_('Zeroconf swap'), self.toggle_zeroconf _('Choose swap server'),
).setEnabled(self.lnworker.can_have_recoverable_channels()) lambda: self.window.choose_swapserver_dialog(transport),
if not self.config.SWAPSERVER_URL: ).setEnabled(not self.config.SWAPSERVER_URL)
menu.addAction(_('Choose swap server'), lambda: self.window.choose_swapserver_dialog(transport))
vbox.addLayout(toolbar) vbox.addLayout(toolbar)
self.description_label = WWLabel(self.get_description()) self.description_label = WWLabel(self.get_description())
self.send_amount_e = BTCAmountEdit(self.window.get_decimal_point) self.send_amount_e = BTCAmountEdit(self.window.get_decimal_point)
@@ -64,7 +63,6 @@ class SwapDialog(WindowModalDialog, QtEventListener):
# send_follows is used to know whether the send amount field / receive # send_follows is used to know whether the send amount field / receive
# amount field should be adjusted after the fee slider was moved # amount field should be adjusted after the fee slider was moved
self.send_follows = False self.send_follows = False
self.zeroconf = False
self.send_amount_e.follows = False self.send_amount_e.follows = False
self.recv_amount_e.follows = False self.recv_amount_e.follows = False
self.toggle_button.clicked.connect(self.toggle_direction) self.toggle_button.clicked.connect(self.toggle_direction)
@@ -112,15 +110,6 @@ class SwapDialog(WindowModalDialog, QtEventListener):
fee_slider.update() fee_slider.update()
self.register_callbacks() self.register_callbacks()
def toggle_zeroconf(self):
self.zeroconf = not self.zeroconf
if self.zeroconf:
msg = "\n\n".join([
"Zero-confirmation swap: Your wallet will not wait until the funding transaction is confirmed.",
"Note that this option is risky: the server can steal your funds if they double-spend the funding transaction."
])
self.window.show_warning(msg)
def closeEvent(self, event): def closeEvent(self, event):
self.unregister_callbacks() self.unregister_callbacks()
event.accept() event.accept()
@@ -266,7 +255,6 @@ class SwapDialog(WindowModalDialog, QtEventListener):
transport, transport,
lightning_amount_sat=lightning_amount, lightning_amount_sat=lightning_amount,
expected_onchain_amount_sat=onchain_amount + self.swap_manager.get_swap_tx_fee(), expected_onchain_amount_sat=onchain_amount + self.swap_manager.get_swap_tx_fee(),
zeroconf=self.zeroconf,
) )
try: try:
# we must not leave the context, so we use run_couroutine_dialog # we must not leave the context, so we use run_couroutine_dialog

View File

@@ -68,10 +68,6 @@ class HttpSwapServer(Logger, EventListener):
"limits": { "limits": {
"maximal": sm._max_amount, "maximal": sm._max_amount,
"minimal": sm._min_amount, "minimal": sm._min_amount,
"maximalZeroConf": {
"baseAsset": 0,
"quoteAsset": 0
}
}, },
"fees": { "fees": {
"percentage": sm.percentage, "percentage": sm.percentage,

View File

@@ -155,7 +155,6 @@ class SwapData(StoredObject):
_funding_prevout = None # type: Optional[TxOutpoint] # for RBF _funding_prevout = None # type: Optional[TxOutpoint] # for RBF
_payment_hash = None _payment_hash = None
_zeroconf = False
_payment_pending = False # for forward swaps _payment_pending = False # for forward swaps
@property @property
@@ -411,7 +410,7 @@ class SwapManager(Logger):
return return
txin, locktime = self.create_claim_txin(txin=txin, swap=swap) txin, locktime = self.create_claim_txin(txin=txin, swap=swap)
# note: there is no csv in the script, we just set this so that txbatcher waits for one confirmation # note: there is no csv in the script, we just set this so that txbatcher waits for one confirmation
csv = 1 if (swap.is_reverse and not swap._zeroconf) else 0 csv = 1 if swap.is_reverse else 0
name = 'swap claim' if swap.is_reverse else 'swap refund' name = 'swap claim' if swap.is_reverse else 'swap refund'
can_be_batched = bool(csv) if swap.is_reverse else True can_be_batched = bool(csv) if swap.is_reverse else True
sweep_info = SweepInfo( sweep_info = SweepInfo(
@@ -685,8 +684,6 @@ class SwapManager(Logger):
} }
data = await transport.send_request_to_server('createnormalswap', request_data) data = await transport.send_request_to_server('createnormalswap', request_data)
payment_hash = bytes.fromhex(data["preimageHash"]) payment_hash = bytes.fromhex(data["preimageHash"])
zeroconf = data["acceptZeroConf"]
onchain_amount = data["expectedAmount"] onchain_amount = data["expectedAmount"]
locktime = data["timeoutBlockHeight"] locktime = data["timeoutBlockHeight"]
lockup_address = data["address"] lockup_address = data["address"]
@@ -804,7 +801,6 @@ class SwapManager(Logger):
*, *,
lightning_amount_sat: int, lightning_amount_sat: int,
expected_onchain_amount_sat: int, expected_onchain_amount_sat: int,
zeroconf: bool=False,
channels: Optional[Sequence['Channel']] = None, channels: Optional[Sequence['Channel']] = None,
) -> Optional[str]: ) -> Optional[str]:
"""send on Lightning, receive on-chain """send on Lightning, receive on-chain
@@ -887,7 +883,6 @@ class SwapManager(Logger):
prepay_hash=prepay_hash, prepay_hash=prepay_hash,
onchain_amount_sat=onchain_amount, onchain_amount_sat=onchain_amount,
lightning_amount_sat=lightning_amount_sat) lightning_amount_sat=lightning_amount_sat)
swap._zeroconf = zeroconf
# initiate fee payment. # initiate fee payment.
if fee_invoice: if fee_invoice:
fee_invoice_obj = Invoice.from_bech32(fee_invoice) fee_invoice_obj = Invoice.from_bech32(fee_invoice)
@@ -1105,7 +1100,6 @@ class SwapManager(Logger):
response = { response = {
"id": swap.payment_hash.hex(), "id": swap.payment_hash.hex(),
'preimageHash': swap.payment_hash.hex(), 'preimageHash': swap.payment_hash.hex(),
"acceptZeroConf": False,
"expectedAmount": swap.onchain_amount, "expectedAmount": swap.onchain_amount,
"timeoutBlockHeight": swap.locktime, "timeoutBlockHeight": swap.locktime,
"address": swap.lockup_address, "address": swap.lockup_address,