mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-06 02:38:11 +01:00
Allow BCH as coin_to in ADS swaps.
This commit is contained in:
@@ -678,8 +678,12 @@ class BasicSwap(BaseApp):
|
|||||||
|
|
||||||
return self.coin_clients[use_coinid][interface_ind]
|
return self.coin_clients[use_coinid][interface_ind]
|
||||||
|
|
||||||
def isBchXmrSwap(self, offer: Offer):
|
def isBchXmrSwap(self, offer: Offer) -> bool:
|
||||||
return (offer.coin_from == Coins.BCH or offer.coin_to == Coins.BCH) and offer.swap_type == SwapTypes.XMR_SWAP
|
if offer.swap_type != SwapTypes.XMR_SWAP:
|
||||||
|
return False
|
||||||
|
if self.is_reverse_ads_bid(offer.coin_from, offer.coin_to):
|
||||||
|
return offer.coin_to == Coins.BCH
|
||||||
|
return offer.coin_from == Coins.BCH
|
||||||
|
|
||||||
def pi(self, protocol_ind):
|
def pi(self, protocol_ind):
|
||||||
if protocol_ind not in self.protocolInterfaces:
|
if protocol_ind not in self.protocolInterfaces:
|
||||||
@@ -1368,8 +1372,6 @@ class BasicSwap(BaseApp):
|
|||||||
raise e
|
raise e
|
||||||
|
|
||||||
def is_reverse_ads_bid(self, coin_from, coin_to) -> bool:
|
def is_reverse_ads_bid(self, coin_from, coin_to) -> bool:
|
||||||
if coin_to == Coins.BCH:
|
|
||||||
return True
|
|
||||||
return coin_from in self.scriptless_coins + self.coins_without_segwit
|
return coin_from in self.scriptless_coins + self.coins_without_segwit
|
||||||
|
|
||||||
def validateSwapType(self, coin_from, coin_to, swap_type):
|
def validateSwapType(self, coin_from, coin_to, swap_type):
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2022-2023 tecnovert
|
# Copyright (c) 2024 The Basicswap developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
@@ -320,12 +320,12 @@ class BCHInterface(BTCInterface):
|
|||||||
def pkh_to_address(self, pkh: bytes) -> str:
|
def pkh_to_address(self, pkh: bytes) -> str:
|
||||||
# pkh is ripemd160(sha256(pk))
|
# pkh is ripemd160(sha256(pk))
|
||||||
assert (len(pkh) == 20)
|
assert (len(pkh) == 20)
|
||||||
prefix = self.chainparams_network()['hrp']
|
network = self._network.upper()
|
||||||
address = Address("P2PKH", b'\x76\xa9\x14' + pkh + b'\x88\xac')
|
address = Address("P2PKH" if network == "MAINNET" else "P2PKH-" + network, pkh)
|
||||||
address.prefix = prefix
|
|
||||||
return address.cash_address()
|
return address.cash_address()
|
||||||
|
|
||||||
def encodeSharedAddress(self, Kbv, Kbs):
|
def encodeSharedAddress(self, Kbv: bytes, Kbs: bytes) -> str:
|
||||||
return self.pkh_to_address(hash160(Kbs))
|
return self.pkh_to_address(hash160(Kbs))
|
||||||
|
|
||||||
def addressToLockingBytecode(self, address: str) -> bytes:
|
def addressToLockingBytecode(self, address: str) -> bytes:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2021-2024 tecnovert
|
# Copyright (c) 2024 The Basicswap developers
|
||||||
# Distributed under the MIT software license, see the accompanying
|
# Distributed under the MIT software license, see the accompanying
|
||||||
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user