mirror of
https://github.com/basicswap/basicswap.git
synced 2025-12-29 16:51:39 +01:00
tests: Disable test_13_locked_xmr when xmr version >= 0.18.4.
This commit is contained in:
@@ -2407,7 +2407,7 @@ class BasicSwap(BaseApp):
|
|||||||
cursor = self.openDB()
|
cursor = self.openDB()
|
||||||
try:
|
try:
|
||||||
offer = self.queryOne(Offer, cursor, {"offer_id": offer_id})
|
offer = self.queryOne(Offer, cursor, {"offer_id": offer_id})
|
||||||
ensure(offer, f"Offer not found: {offer_id.hex()}.")
|
ensure(offer, f"Offer not found: {self.log.id(offer_id)}.")
|
||||||
if "automation_strat_id" in data:
|
if "automation_strat_id" in data:
|
||||||
new_automation_strat_id = data["automation_strat_id"]
|
new_automation_strat_id = data["automation_strat_id"]
|
||||||
link = self.queryOne(
|
link = self.queryOne(
|
||||||
@@ -3152,7 +3152,7 @@ class BasicSwap(BaseApp):
|
|||||||
self.log.debug(f"postBid for offer: {self.log.id(offer_id)}")
|
self.log.debug(f"postBid for offer: {self.log.id(offer_id)}")
|
||||||
|
|
||||||
offer = self.getOffer(offer_id)
|
offer = self.getOffer(offer_id)
|
||||||
ensure(offer, f"Offer not found: {offer_id.hex()}.")
|
ensure(offer, f"Offer not found: {self.log.id(offer_id)}.")
|
||||||
ensure(offer.expire_at > self.getTime(), "Offer has expired")
|
ensure(offer.expire_at > self.getTime(), "Offer has expired")
|
||||||
|
|
||||||
if offer.swap_type == SwapTypes.XMR_SWAP:
|
if offer.swap_type == SwapTypes.XMR_SWAP:
|
||||||
@@ -3868,8 +3868,8 @@ class BasicSwap(BaseApp):
|
|||||||
try:
|
try:
|
||||||
use_cursor = self.openDB(cursor)
|
use_cursor = self.openDB(cursor)
|
||||||
bid, xmr_swap = self.getXmrBidFromSession(use_cursor, bid_id)
|
bid, xmr_swap = self.getXmrBidFromSession(use_cursor, bid_id)
|
||||||
ensure(bid, "Bid not found: {}.".format(bid_id.hex()))
|
ensure(bid, f"Bid not found: {self.log.id(bid_id)}.")
|
||||||
ensure(xmr_swap, "Adaptor-sig swap not found: {}.".format(bid_id.hex()))
|
ensure(xmr_swap, f"Adaptor-sig swap not found: {self.log.id(bid_id)}.")
|
||||||
ensure(bid.expire_at > now, "Bid expired")
|
ensure(bid.expire_at > now, "Bid expired")
|
||||||
|
|
||||||
last_bid_state = bid.state
|
last_bid_state = bid.state
|
||||||
@@ -3882,9 +3882,9 @@ class BasicSwap(BaseApp):
|
|||||||
)
|
)
|
||||||
|
|
||||||
offer, xmr_offer = self.getXmrOffer(bid.offer_id, cursor=use_cursor)
|
offer, xmr_offer = self.getXmrOffer(bid.offer_id, cursor=use_cursor)
|
||||||
ensure(offer, "Offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(offer, f"Offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
ensure(
|
ensure(
|
||||||
xmr_offer, "Adaptor-sig offer not found: {}.".format(bid.offer_id.hex())
|
xmr_offer, f"Adaptor-sig offer not found: {self.log.id(bid.offer_id)}."
|
||||||
)
|
)
|
||||||
ensure(offer.expire_at > now, "Offer has expired")
|
ensure(offer.expire_at > now, "Offer has expired")
|
||||||
|
|
||||||
@@ -4171,8 +4171,8 @@ class BasicSwap(BaseApp):
|
|||||||
try:
|
try:
|
||||||
use_cursor = self.openDB(cursor)
|
use_cursor = self.openDB(cursor)
|
||||||
bid, xmr_swap = self.getXmrBidFromSession(use_cursor, bid_id)
|
bid, xmr_swap = self.getXmrBidFromSession(use_cursor, bid_id)
|
||||||
ensure(bid, "Bid not found: {}.".format(bid_id.hex()))
|
ensure(bid, f"Bid not found: {self.log.id(bid_id)}.")
|
||||||
ensure(xmr_swap, "Adaptor-sig swap not found: {}.".format(bid_id.hex()))
|
ensure(xmr_swap, f"Adaptor-sig swap not found: {self.log.id(bid_id)}.")
|
||||||
ensure(bid.expire_at > now, "Bid expired")
|
ensure(bid.expire_at > now, "Bid expired")
|
||||||
|
|
||||||
last_bid_state = bid.state
|
last_bid_state = bid.state
|
||||||
@@ -4185,9 +4185,9 @@ class BasicSwap(BaseApp):
|
|||||||
)
|
)
|
||||||
|
|
||||||
offer, xmr_offer = self.getXmrOffer(bid.offer_id, cursor=use_cursor)
|
offer, xmr_offer = self.getXmrOffer(bid.offer_id, cursor=use_cursor)
|
||||||
ensure(offer, "Offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(offer, f"Offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
ensure(
|
ensure(
|
||||||
xmr_offer, "Adaptor-sig offer not found: {}.".format(bid.offer_id.hex())
|
xmr_offer, f"Adaptor-sig offer not found: {self.log.id(bid.offer_id)}."
|
||||||
)
|
)
|
||||||
ensure(offer.expire_at > now, "Offer has expired")
|
ensure(offer.expire_at > now, "Offer has expired")
|
||||||
|
|
||||||
@@ -5102,6 +5102,9 @@ class BasicSwap(BaseApp):
|
|||||||
ci_to.blocks_confirmed,
|
ci_to.blocks_confirmed,
|
||||||
bid.chain_b_height_start,
|
bid.chain_b_height_start,
|
||||||
bid_sender,
|
bid_sender,
|
||||||
|
check_amount=(
|
||||||
|
False if bid.debug_ind == DebugTypes.B_LOCK_TX_MISSED_SEND else True
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
if isinstance(found_tx, int) and found_tx == -1:
|
if isinstance(found_tx, int) and found_tx == -1:
|
||||||
@@ -5160,10 +5163,10 @@ class BasicSwap(BaseApp):
|
|||||||
xmr_offer = self.queryOne(XmrOffer, cursor, {"offer_id": offer.offer_id})
|
xmr_offer = self.queryOne(XmrOffer, cursor, {"offer_id": offer.offer_id})
|
||||||
ensure(
|
ensure(
|
||||||
xmr_offer,
|
xmr_offer,
|
||||||
"Adaptor-sig offer not found: {}.".format(offer.offer_id.hex()),
|
f"Adaptor-sig offer not found: {self.log.id(offer.offer_id)}.",
|
||||||
)
|
)
|
||||||
xmr_swap = self.queryOne(XmrSwap, cursor, {"bid_id": bid.bid_id})
|
xmr_swap = self.queryOne(XmrSwap, cursor, {"bid_id": bid.bid_id})
|
||||||
ensure(xmr_swap, "Adaptor-sig swap not found: {}.".format(bid.bid_id.hex()))
|
ensure(xmr_swap, f"Adaptor-sig swap not found: {self.log.id(bid.bid_id)}.")
|
||||||
|
|
||||||
if TxTypes.XMR_SWAP_A_LOCK_REFUND in bid.txns:
|
if TxTypes.XMR_SWAP_A_LOCK_REFUND in bid.txns:
|
||||||
refund_tx = bid.txns[TxTypes.XMR_SWAP_A_LOCK_REFUND]
|
refund_tx = bid.txns[TxTypes.XMR_SWAP_A_LOCK_REFUND]
|
||||||
@@ -5548,7 +5551,8 @@ class BasicSwap(BaseApp):
|
|||||||
cursor,
|
cursor,
|
||||||
)
|
)
|
||||||
elif (
|
elif (
|
||||||
chain_height - bid.xmr_b_lock_tx.chain_height
|
bid.xmr_b_lock_tx.state != TxStates.TX_CONFIRMED
|
||||||
|
and chain_height - bid.xmr_b_lock_tx.chain_height
|
||||||
>= ci_to.blocks_confirmed
|
>= ci_to.blocks_confirmed
|
||||||
):
|
):
|
||||||
self.logBidEvent(
|
self.logBidEvent(
|
||||||
@@ -6149,17 +6153,17 @@ class BasicSwap(BaseApp):
|
|||||||
try:
|
try:
|
||||||
use_cursor = self.openDB(cursor)
|
use_cursor = self.openDB(cursor)
|
||||||
bid, xmr_swap = self.getXmrBidFromSession(use_cursor, bid_id)
|
bid, xmr_swap = self.getXmrBidFromSession(use_cursor, bid_id)
|
||||||
ensure(bid, "Bid not found: {}.".format(bid_id.hex()))
|
ensure(bid, f"Bid not found: {self.log.id(bid_id)}.")
|
||||||
ensure(xmr_swap, "Adaptor-sig swap not found: {}.".format(bid_id.hex()))
|
ensure(xmr_swap, f"Adaptor-sig swap not found: {self.log.id(bid_id)}.")
|
||||||
|
|
||||||
if BidStates(bid.state) == BidStates.BID_STALLED_FOR_TEST:
|
if BidStates(bid.state) == BidStates.BID_STALLED_FOR_TEST:
|
||||||
self.log.debug(f"Bid stalled{self.log.id(bid_id)}")
|
self.log.debug(f"Bid stalled{self.log.id(bid_id)}")
|
||||||
return
|
return
|
||||||
|
|
||||||
offer, xmr_offer = self.getXmrOfferFromSession(use_cursor, bid.offer_id)
|
offer, xmr_offer = self.getXmrOfferFromSession(use_cursor, bid.offer_id)
|
||||||
ensure(offer, "Offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(offer, f"Offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
ensure(
|
ensure(
|
||||||
xmr_offer, "Adaptor-sig offer not found: {}.".format(bid.offer_id.hex())
|
xmr_offer, f"Adaptor-sig offer not found: {self.log.id(bid.offer_id)}."
|
||||||
)
|
)
|
||||||
|
|
||||||
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
||||||
@@ -6271,13 +6275,13 @@ class BasicSwap(BaseApp):
|
|||||||
try:
|
try:
|
||||||
cursor = self.openDB()
|
cursor = self.openDB()
|
||||||
bid, xmr_swap = self.getXmrBidFromSession(cursor, bid_id)
|
bid, xmr_swap = self.getXmrBidFromSession(cursor, bid_id)
|
||||||
ensure(bid, "Bid not found: {}.".format(bid_id.hex()))
|
ensure(bid, f"Bid not found: {self.log.id(bid_id)}.")
|
||||||
ensure(xmr_swap, "Adaptor-sig swap not found: {}.".format(bid_id.hex()))
|
ensure(xmr_swap, f"Adaptor-sig swap not found: {self.log.id(bid_id)}.")
|
||||||
|
|
||||||
offer, xmr_offer = self.getXmrOfferFromSession(cursor, bid.offer_id)
|
offer, xmr_offer = self.getXmrOfferFromSession(cursor, bid.offer_id)
|
||||||
ensure(offer, "Offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(offer, f"Offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
ensure(
|
ensure(
|
||||||
xmr_offer, "Adaptor-sig offer not found: {}.".format(bid.offer_id.hex())
|
xmr_offer, f"Adaptor-sig offer not found: {self.log.id(bid.offer_id)}."
|
||||||
)
|
)
|
||||||
|
|
||||||
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
||||||
@@ -7556,12 +7560,12 @@ class BasicSwap(BaseApp):
|
|||||||
ensure(len(bid_accept_data.initiate_txid) == 32, "Bad initiate_txid length")
|
ensure(len(bid_accept_data.initiate_txid) == 32, "Bad initiate_txid length")
|
||||||
ensure(len(bid_accept_data.contract_script) < 100, "Bad contract_script length")
|
ensure(len(bid_accept_data.contract_script) < 100, "Bad contract_script length")
|
||||||
|
|
||||||
self.log.debug("for bid {self.log.id(bid_accept_data.bid_msg_id)}.")
|
self.log.debug(f"for bid {self.log.id(bid_accept_data.bid_msg_id)}.")
|
||||||
|
|
||||||
bid_id: bytes = bid_accept_data.bid_msg_id
|
bid_id: bytes = bid_accept_data.bid_msg_id
|
||||||
bid, offer = self.getBidAndOffer(bid_id)
|
bid, offer = self.getBidAndOffer(bid_id)
|
||||||
ensure(bid is not None and bid.was_sent is True, "Unknown bid_id")
|
ensure(bid is not None and bid.was_sent is True, "Unknown bid_id")
|
||||||
ensure(offer, "Offer not found " + bid.offer_id.hex())
|
ensure(offer, f"Offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
|
|
||||||
ensure(bid.expire_at > now + self._bid_expired_leeway, "Bid expired")
|
ensure(bid.expire_at > now + self._bid_expired_leeway, "Bid expired")
|
||||||
ensure(msg["to"] == bid.bid_addr, "Received on incorrect address")
|
ensure(msg["to"] == bid.bid_addr, "Received on incorrect address")
|
||||||
@@ -7673,9 +7677,9 @@ class BasicSwap(BaseApp):
|
|||||||
self.log.debug(f"Receiving adaptor-sig bid {self.log.id(bid.bid_id)}.")
|
self.log.debug(f"Receiving adaptor-sig bid {self.log.id(bid.bid_id)}.")
|
||||||
|
|
||||||
offer, xmr_offer = self.getXmrOfferFromSession(cursor, bid.offer_id)
|
offer, xmr_offer = self.getXmrOfferFromSession(cursor, bid.offer_id)
|
||||||
ensure(offer, "Offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(offer, f"Offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
|
|
||||||
ensure(xmr_offer, "Adaptor-sig offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(xmr_offer, f"Adaptor-sig offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
xmr_swap = self.queryOne(XmrSwap, cursor, {"bid_id": bid.bid_id})
|
xmr_swap = self.queryOne(XmrSwap, cursor, {"bid_id": bid.bid_id})
|
||||||
ensure(xmr_swap, "Adaptor-sig swap not found: {}.".format(bid.bid_id.hex()))
|
ensure(xmr_swap, "Adaptor-sig swap not found: {}.".format(bid.bid_id.hex()))
|
||||||
|
|
||||||
@@ -7771,8 +7775,8 @@ class BasicSwap(BaseApp):
|
|||||||
self.log.debug(f"Receiving adaptor-sig bid accept {self.log.id(bid.bid_id)}.")
|
self.log.debug(f"Receiving adaptor-sig bid accept {self.log.id(bid.bid_id)}.")
|
||||||
|
|
||||||
offer, xmr_offer = self.getXmrOffer(bid.offer_id, cursor=cursor)
|
offer, xmr_offer = self.getXmrOffer(bid.offer_id, cursor=cursor)
|
||||||
ensure(offer, "Offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(offer, f"Offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
ensure(xmr_offer, "Adaptor-sig offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(xmr_offer, f"Adaptor-sig offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
xmr_swap = self.queryOne(XmrSwap, cursor, {"bid_id": bid.bid_id})
|
xmr_swap = self.queryOne(XmrSwap, cursor, {"bid_id": bid.bid_id})
|
||||||
ensure(xmr_swap, "Adaptor-sig swap not found: {}.".format(bid.bid_id.hex()))
|
ensure(xmr_swap, "Adaptor-sig swap not found: {}.".format(bid.bid_id.hex()))
|
||||||
|
|
||||||
@@ -7874,9 +7878,9 @@ class BasicSwap(BaseApp):
|
|||||||
|
|
||||||
offer_id = bid_data.offer_msg_id
|
offer_id = bid_data.offer_msg_id
|
||||||
offer, xmr_offer = self.getXmrOffer(offer_id)
|
offer, xmr_offer = self.getXmrOffer(offer_id)
|
||||||
ensure(offer and offer.was_sent, "Offer not found: {}.".format(offer_id.hex()))
|
ensure(offer and offer.was_sent, f"Offer not found: {self.log.id(offer_id)}.")
|
||||||
ensure(offer.swap_type == SwapTypes.XMR_SWAP, "Bid/offer swap type mismatch")
|
ensure(offer.swap_type == SwapTypes.XMR_SWAP, "Bid/offer swap type mismatch")
|
||||||
ensure(xmr_offer, "Adaptor-sig offer not found: {}.".format(offer_id.hex()))
|
ensure(xmr_offer, f"Adaptor-sig offer not found: {self.log.id(offer_id)}.")
|
||||||
|
|
||||||
ci_from = self.ci(offer.coin_from)
|
ci_from = self.ci(offer.coin_from)
|
||||||
ci_to = self.ci(offer.coin_to)
|
ci_to = self.ci(offer.coin_to)
|
||||||
@@ -7981,15 +7985,15 @@ class BasicSwap(BaseApp):
|
|||||||
|
|
||||||
self.log.debug(f"for bid {self.log.id(msg_data.bid_msg_id)}.")
|
self.log.debug(f"for bid {self.log.id(msg_data.bid_msg_id)}.")
|
||||||
bid, xmr_swap = self.getXmrBid(msg_data.bid_msg_id)
|
bid, xmr_swap = self.getXmrBid(msg_data.bid_msg_id)
|
||||||
ensure(bid, "Bid not found: {}.".format(msg_data.bid_msg_id.hex()))
|
ensure(bid, f"Bid not found: {self.log.id(msg_data.bid_msg_id)}.")
|
||||||
ensure(
|
ensure(
|
||||||
xmr_swap,
|
xmr_swap,
|
||||||
"Adaptor-sig swap not found: {}.".format(msg_data.bid_msg_id.hex()),
|
f"Adaptor-sig swap not found: {self.log.id(msg_data.bid_msg_id)}.",
|
||||||
)
|
)
|
||||||
|
|
||||||
offer, xmr_offer = self.getXmrOffer(bid.offer_id)
|
offer, xmr_offer = self.getXmrOffer(bid.offer_id)
|
||||||
ensure(offer, "Offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(offer, f"Offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
ensure(xmr_offer, "Adaptor-sig offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(xmr_offer, f"Adaptor-sig offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
|
|
||||||
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
||||||
ci_from = self.ci(offer.coin_to if reverse_bid else offer.coin_from)
|
ci_from = self.ci(offer.coin_to if reverse_bid else offer.coin_from)
|
||||||
@@ -8197,12 +8201,12 @@ class BasicSwap(BaseApp):
|
|||||||
self.log.debug(f"Signing adaptor-sig bid lock txns {self.logIDB(bid_id)}.")
|
self.log.debug(f"Signing adaptor-sig bid lock txns {self.logIDB(bid_id)}.")
|
||||||
|
|
||||||
bid, xmr_swap = self.getXmrBidFromSession(cursor, bid_id)
|
bid, xmr_swap = self.getXmrBidFromSession(cursor, bid_id)
|
||||||
ensure(bid, "Bid not found: {}.".format(bid_id.hex()))
|
ensure(bid, f"Bid not found: {self.log.id(bid_id)}.")
|
||||||
ensure(xmr_swap, "Adaptor-sig swap not found: {}.".format(bid_id.hex()))
|
ensure(xmr_swap, f"Adaptor-sig swap not found: {self.log.id(bid_id)}.")
|
||||||
|
|
||||||
offer, xmr_offer = self.getXmrOfferFromSession(cursor, bid.offer_id)
|
offer, xmr_offer = self.getXmrOfferFromSession(cursor, bid.offer_id)
|
||||||
ensure(offer, "Offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(offer, f"Offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
ensure(xmr_offer, "Adaptor-sig offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(xmr_offer, f"Adaptor-sig offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
|
|
||||||
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
||||||
coin_from = Coins(offer.coin_to if reverse_bid else offer.coin_from)
|
coin_from = Coins(offer.coin_to if reverse_bid else offer.coin_from)
|
||||||
@@ -8312,12 +8316,12 @@ class BasicSwap(BaseApp):
|
|||||||
)
|
)
|
||||||
|
|
||||||
bid, xmr_swap = self.getXmrBidFromSession(cursor, bid_id)
|
bid, xmr_swap = self.getXmrBidFromSession(cursor, bid_id)
|
||||||
ensure(bid, "Bid not found: {}.".format(bid_id.hex()))
|
ensure(bid, f"Bid not found: {self.log.id(bid_id)}.")
|
||||||
ensure(xmr_swap, "Adaptor-sig swap not found: {}.".format(bid_id.hex()))
|
ensure(xmr_swap, f"Adaptor-sig swap not found: {self.log.id(bid_id)}.")
|
||||||
|
|
||||||
offer, xmr_offer = self.getXmrOfferFromSession(cursor, bid.offer_id)
|
offer, xmr_offer = self.getXmrOfferFromSession(cursor, bid.offer_id)
|
||||||
ensure(offer, "Offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(offer, f"Offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
ensure(xmr_offer, "Adaptor-sig offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(xmr_offer, f"Adaptor-sig offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
|
|
||||||
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
||||||
coin_from = Coins(offer.coin_to if reverse_bid else offer.coin_from)
|
coin_from = Coins(offer.coin_to if reverse_bid else offer.coin_from)
|
||||||
@@ -8453,12 +8457,12 @@ class BasicSwap(BaseApp):
|
|||||||
)
|
)
|
||||||
|
|
||||||
bid, xmr_swap = self.getXmrBidFromSession(cursor, bid_id)
|
bid, xmr_swap = self.getXmrBidFromSession(cursor, bid_id)
|
||||||
ensure(bid, "Bid not found: {}.".format(bid_id.hex()))
|
ensure(bid, f"Bid not found: {self.log.id(bid_id)}.")
|
||||||
ensure(xmr_swap, "Adaptor-sig swap not found: {}.".format(bid_id.hex()))
|
ensure(xmr_swap, f"Adaptor-sig swap not found: {self.log.id(bid_id)}.")
|
||||||
|
|
||||||
offer, xmr_offer = self.getXmrOfferFromSession(cursor, bid.offer_id)
|
offer, xmr_offer = self.getXmrOfferFromSession(cursor, bid.offer_id)
|
||||||
ensure(offer, "Offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(offer, f"Offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
ensure(xmr_offer, "Adaptor-sig offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(xmr_offer, f"Adaptor-sig offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
|
|
||||||
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
||||||
ci_to = self.ci(offer.coin_from if reverse_bid else offer.coin_to)
|
ci_to = self.ci(offer.coin_from if reverse_bid else offer.coin_to)
|
||||||
@@ -8496,7 +8500,7 @@ class BasicSwap(BaseApp):
|
|||||||
):
|
):
|
||||||
bid.amount_to -= int(bid.amount_to * 0.1)
|
bid.amount_to -= int(bid.amount_to * 0.1)
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
f"Adaptor-sig bid {self.log.id(bid_id)}: Debug {bid.debug_ind} - Reducing lock b txn amount by 10%% to {ci_to.format_amount(bid.amount_to)}.",
|
f"Adaptor-sig bid {self.log.id(bid_id)}: Debug {bid.debug_ind} - Reducing lock b txn amount by 10% to {ci_to.format_amount(bid.amount_to)}.",
|
||||||
)
|
)
|
||||||
self.logBidEvent(
|
self.logBidEvent(
|
||||||
bid.bid_id,
|
bid.bid_id,
|
||||||
@@ -8507,7 +8511,7 @@ class BasicSwap(BaseApp):
|
|||||||
if bid.debug_ind == DebugTypes.SEND_LOCKED_XMR:
|
if bid.debug_ind == DebugTypes.SEND_LOCKED_XMR:
|
||||||
unlock_time = 10000
|
unlock_time = 10000
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
f"Adaptor-sig bid {self.log.id(bid_id)}: Debug {id.debug_ind} - Sending locked XMR."
|
f"Adaptor-sig bid {self.log.id(bid_id)}: Debug {bid.debug_ind} - Sending locked XMR."
|
||||||
)
|
)
|
||||||
self.logBidEvent(
|
self.logBidEvent(
|
||||||
bid.bid_id,
|
bid.bid_id,
|
||||||
@@ -8526,7 +8530,7 @@ class BasicSwap(BaseApp):
|
|||||||
)
|
)
|
||||||
if bid.debug_ind == DebugTypes.B_LOCK_TX_MISSED_SEND:
|
if bid.debug_ind == DebugTypes.B_LOCK_TX_MISSED_SEND:
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
f"Adaptor-sig bid {self.log.id(bid_id)}: Debug {bid.debug_ind} - Losing xmr lock tx {self.log.id(b_lock_tx_id)}."
|
f"Adaptor-sig bid {self.log.id(bid_id)}: Debug {bid.debug_ind} - Losing XMR lock tx {self.log.id(b_lock_tx_id)}."
|
||||||
)
|
)
|
||||||
self.logBidEvent(
|
self.logBidEvent(
|
||||||
bid.bid_id,
|
bid.bid_id,
|
||||||
@@ -8553,7 +8557,7 @@ class BasicSwap(BaseApp):
|
|||||||
):
|
):
|
||||||
delay = self.get_delay_retry_seconds()
|
delay = self.get_delay_retry_seconds()
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"Retrying sending adaptor-sig swap chain B lock tx for bid {self.log.id(bid_id)} in {delay} seconds."
|
f"Retrying sending adaptor-sig swap chain B lock tx for bid {self.log.id(bid_id)} in {delay} seconds."
|
||||||
)
|
)
|
||||||
self.createActionInSession(
|
self.createActionInSession(
|
||||||
delay, ActionTypes.SEND_XMR_SWAP_LOCK_TX_B, bid_id, cursor
|
delay, ActionTypes.SEND_XMR_SWAP_LOCK_TX_B, bid_id, cursor
|
||||||
@@ -8600,12 +8604,12 @@ class BasicSwap(BaseApp):
|
|||||||
self.log.debug(f"Sending bid secret for adaptor-sig bid {self.log.id(bid_id)}.")
|
self.log.debug(f"Sending bid secret for adaptor-sig bid {self.log.id(bid_id)}.")
|
||||||
|
|
||||||
bid, xmr_swap = self.getXmrBidFromSession(cursor, bid_id)
|
bid, xmr_swap = self.getXmrBidFromSession(cursor, bid_id)
|
||||||
ensure(bid, "Bid not found: {}.".format(bid_id.hex()))
|
ensure(bid, f"Bid not found: {self.log.id(bid_id)}.")
|
||||||
ensure(xmr_swap, "Adaptor-sig swap not found: {}.".format(bid_id.hex()))
|
ensure(xmr_swap, f"Adaptor-sig swap not found: {self.log.id(bid_id)}.")
|
||||||
|
|
||||||
offer, xmr_offer = self.getXmrOfferFromSession(cursor, bid.offer_id)
|
offer, xmr_offer = self.getXmrOfferFromSession(cursor, bid.offer_id)
|
||||||
ensure(offer, "Offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(offer, f"Offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
ensure(xmr_offer, "Adaptor-sig offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(xmr_offer, f"Adaptor-sig offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
|
|
||||||
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
||||||
|
|
||||||
@@ -8642,12 +8646,12 @@ class BasicSwap(BaseApp):
|
|||||||
)
|
)
|
||||||
|
|
||||||
bid, xmr_swap = self.getXmrBidFromSession(cursor, bid_id)
|
bid, xmr_swap = self.getXmrBidFromSession(cursor, bid_id)
|
||||||
ensure(bid, "Bid not found: {}.".format(bid_id.hex()))
|
ensure(bid, f"Bid not found: {self.log.id(bid_id)}.")
|
||||||
ensure(xmr_swap, "Adaptor-sig swap not found: {}.".format(bid_id.hex()))
|
ensure(xmr_swap, f"Adaptor-sig swap not found: {self.log.id(bid_id)}.")
|
||||||
|
|
||||||
offer, xmr_offer = self.getXmrOfferFromSession(cursor, bid.offer_id)
|
offer, xmr_offer = self.getXmrOfferFromSession(cursor, bid.offer_id)
|
||||||
ensure(offer, "Offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(offer, f"Offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
ensure(xmr_offer, "Adaptor-sig offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(xmr_offer, f"Adaptor-sig offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
|
|
||||||
if TxTypes.XMR_SWAP_A_LOCK_REFUND in bid.txns:
|
if TxTypes.XMR_SWAP_A_LOCK_REFUND in bid.txns:
|
||||||
self.log.warning(
|
self.log.warning(
|
||||||
@@ -8765,12 +8769,12 @@ class BasicSwap(BaseApp):
|
|||||||
)
|
)
|
||||||
|
|
||||||
bid, xmr_swap = self.getXmrBidFromSession(cursor, bid_id)
|
bid, xmr_swap = self.getXmrBidFromSession(cursor, bid_id)
|
||||||
ensure(bid, "Bid not found: {}.".format(bid_id.hex()))
|
ensure(bid, f"Bid not found: {self.log.id(bid_id)}.")
|
||||||
ensure(xmr_swap, "Adaptor-sig swap not found: {}.".format(bid_id.hex()))
|
ensure(xmr_swap, f"Adaptor-sig swap not found: {self.log.id(bid_id)}.")
|
||||||
|
|
||||||
offer, xmr_offer = self.getXmrOfferFromSession(cursor, bid.offer_id)
|
offer, xmr_offer = self.getXmrOfferFromSession(cursor, bid.offer_id)
|
||||||
ensure(offer, "Offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(offer, f"Offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
ensure(xmr_offer, "Adaptor-sig offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(xmr_offer, f"Adaptor-sig offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
|
|
||||||
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
||||||
coin_from = Coins(offer.coin_to if reverse_bid else offer.coin_from)
|
coin_from = Coins(offer.coin_to if reverse_bid else offer.coin_from)
|
||||||
@@ -8903,12 +8907,12 @@ class BasicSwap(BaseApp):
|
|||||||
)
|
)
|
||||||
|
|
||||||
bid, xmr_swap = self.getXmrBidFromSession(cursor, bid_id)
|
bid, xmr_swap = self.getXmrBidFromSession(cursor, bid_id)
|
||||||
ensure(bid, "Bid not found: {}.".format(bid_id.hex()))
|
ensure(bid, f"Bid not found: {self.log.id(bid_id)}.")
|
||||||
ensure(xmr_swap, "Adaptor-sig swap not found: {}.".format(bid_id.hex()))
|
ensure(xmr_swap, f"Adaptor-sig swap not found: {self.log.id(bid_id)}.")
|
||||||
|
|
||||||
offer, xmr_offer = self.getXmrOfferFromSession(cursor, bid.offer_id)
|
offer, xmr_offer = self.getXmrOfferFromSession(cursor, bid.offer_id)
|
||||||
ensure(offer, "Offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(offer, f"Offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
ensure(xmr_offer, "Adaptor-sig offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(xmr_offer, f"Adaptor-sig offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
|
|
||||||
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
||||||
coin_from = Coins(offer.coin_to if reverse_bid else offer.coin_from)
|
coin_from = Coins(offer.coin_to if reverse_bid else offer.coin_from)
|
||||||
@@ -8959,6 +8963,9 @@ class BasicSwap(BaseApp):
|
|||||||
b_fee_rate,
|
b_fee_rate,
|
||||||
bid.chain_b_height_start,
|
bid.chain_b_height_start,
|
||||||
lock_tx_vout=lock_tx_vout,
|
lock_tx_vout=lock_tx_vout,
|
||||||
|
spend_actual_balance=(
|
||||||
|
True if bid.debug_ind == DebugTypes.B_LOCK_TX_MISSED_SEND else False
|
||||||
|
),
|
||||||
)
|
)
|
||||||
self.log.debug(
|
self.log.debug(
|
||||||
f"Submitted lock B refund txn {self.log.id(txid)} to {ci_to.coin_name()} chain for bid {self.log.id(bid_id)}."
|
f"Submitted lock B refund txn {self.log.id(txid)} to {ci_to.coin_name()} chain for bid {self.log.id(bid_id)}."
|
||||||
@@ -9017,12 +9024,12 @@ class BasicSwap(BaseApp):
|
|||||||
)
|
)
|
||||||
|
|
||||||
bid, xmr_swap = self.getXmrBidFromSession(cursor, bid_id)
|
bid, xmr_swap = self.getXmrBidFromSession(cursor, bid_id)
|
||||||
ensure(bid, "Bid not found: {}.".format(bid_id.hex()))
|
ensure(bid, f"Bid not found: {self.log.id(bid_id)}.")
|
||||||
ensure(xmr_swap, "Adaptor-sig swap not found: {}.".format(bid_id.hex()))
|
ensure(xmr_swap, f"Adaptor-sig swap not found: {self.log.id(bid_id)}.")
|
||||||
|
|
||||||
offer, xmr_offer = self.getXmrOfferFromSession(cursor, bid.offer_id)
|
offer, xmr_offer = self.getXmrOfferFromSession(cursor, bid.offer_id)
|
||||||
ensure(offer, "Offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(offer, f"Offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
ensure(xmr_offer, "Adaptor-sig offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(xmr_offer, f"Adaptor-sig offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
|
|
||||||
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
||||||
addr_send_from: str = bid.bid_addr if reverse_bid else offer.addr_from
|
addr_send_from: str = bid.bid_addr if reverse_bid else offer.addr_from
|
||||||
@@ -9064,12 +9071,12 @@ class BasicSwap(BaseApp):
|
|||||||
bid_id = msg_data.bid_msg_id
|
bid_id = msg_data.bid_msg_id
|
||||||
|
|
||||||
bid, xmr_swap = self.getXmrBid(bid_id)
|
bid, xmr_swap = self.getXmrBid(bid_id)
|
||||||
ensure(bid, "Bid not found: {}.".format(bid_id.hex()))
|
ensure(bid, f"Bid not found: {self.log.id(bid_id)}.")
|
||||||
ensure(xmr_swap, "Adaptor-sig swap not found: {}.".format(bid_id.hex()))
|
ensure(xmr_swap, f"Adaptor-sig swap not found: {self.log.id(bid_id)}.")
|
||||||
|
|
||||||
offer, xmr_offer = self.getXmrOffer(bid.offer_id)
|
offer, xmr_offer = self.getXmrOffer(bid.offer_id)
|
||||||
ensure(offer, "Offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(offer, f"Offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
ensure(xmr_offer, "Adaptor-sig offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(xmr_offer, f"Adaptor-sig offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
|
|
||||||
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
||||||
coin_from = Coins(offer.coin_to if reverse_bid else offer.coin_from)
|
coin_from = Coins(offer.coin_to if reverse_bid else offer.coin_from)
|
||||||
@@ -9205,12 +9212,12 @@ class BasicSwap(BaseApp):
|
|||||||
bid_id = msg_data.bid_msg_id
|
bid_id = msg_data.bid_msg_id
|
||||||
|
|
||||||
bid, xmr_swap = self.getXmrBid(bid_id)
|
bid, xmr_swap = self.getXmrBid(bid_id)
|
||||||
ensure(bid, "Bid not found: {}.".format(bid_id.hex()))
|
ensure(bid, f"Bid not found: {self.log.id(bid_id)}.")
|
||||||
ensure(xmr_swap, "Adaptor-sig swap not found: {}.".format(bid_id.hex()))
|
ensure(xmr_swap, f"Adaptor-sig swap not found: {self.log.id(bid_id)}.")
|
||||||
|
|
||||||
offer, xmr_offer = self.getXmrOffer(bid.offer_id)
|
offer, xmr_offer = self.getXmrOffer(bid.offer_id)
|
||||||
ensure(offer, "Offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(offer, f"Offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
ensure(xmr_offer, "Adaptor-sig offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(xmr_offer, f"Adaptor-sig offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
|
|
||||||
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
||||||
ci_from = self.ci(offer.coin_to if reverse_bid else offer.coin_from)
|
ci_from = self.ci(offer.coin_to if reverse_bid else offer.coin_from)
|
||||||
@@ -9319,16 +9326,16 @@ class BasicSwap(BaseApp):
|
|||||||
|
|
||||||
bid_id = msg_data.bid_msg_id
|
bid_id = msg_data.bid_msg_id
|
||||||
bid, xmr_swap = self.getXmrBid(bid_id)
|
bid, xmr_swap = self.getXmrBid(bid_id)
|
||||||
ensure(bid, "Bid not found: {}.".format(bid_id.hex()))
|
ensure(bid, f"Bid not found: {self.log.id(bid_id)}.")
|
||||||
ensure(xmr_swap, "Adaptor-sig swap not found: {}.".format(bid_id.hex()))
|
ensure(xmr_swap, f"Adaptor-sig swap not found: {self.log.id(bid_id)}.")
|
||||||
|
|
||||||
if BidStates(bid.state) in (BidStates.BID_STALLED_FOR_TEST,):
|
if BidStates(bid.state) in (BidStates.BID_STALLED_FOR_TEST,):
|
||||||
self.log.debug(f"Bid stalled {self.log.id(bid_id)}.")
|
self.log.debug(f"Bid stalled {self.log.id(bid_id)}.")
|
||||||
return
|
return
|
||||||
|
|
||||||
offer, xmr_offer = self.getXmrOffer(bid.offer_id)
|
offer, xmr_offer = self.getXmrOffer(bid.offer_id)
|
||||||
ensure(offer, "Offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(offer, f"Offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
ensure(xmr_offer, "Adaptor-sig offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(xmr_offer, f"Adaptor-sig offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
|
|
||||||
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
reverse_bid: bool = self.is_reverse_ads_bid(offer.coin_from, offer.coin_to)
|
||||||
ci_from = self.ci(offer.coin_to if reverse_bid else offer.coin_from)
|
ci_from = self.ci(offer.coin_to if reverse_bid else offer.coin_from)
|
||||||
@@ -9397,9 +9404,9 @@ class BasicSwap(BaseApp):
|
|||||||
|
|
||||||
offer_id = bid_data.offer_msg_id
|
offer_id = bid_data.offer_msg_id
|
||||||
offer, xmr_offer = self.getXmrOffer(offer_id)
|
offer, xmr_offer = self.getXmrOffer(offer_id)
|
||||||
ensure(offer and offer.was_sent, "Offer not found: {}.".format(offer_id.hex()))
|
ensure(offer and offer.was_sent, f"Offer not found: {self.log.id(offer_id)}.")
|
||||||
ensure(offer.swap_type == SwapTypes.XMR_SWAP, "Bid/offer swap type mismatch")
|
ensure(offer.swap_type == SwapTypes.XMR_SWAP, "Bid/offer swap type mismatch")
|
||||||
ensure(xmr_offer, "Adaptor-sig offer not found: {}.".format(offer_id.hex()))
|
ensure(xmr_offer, f"Adaptor-sig offer not found: {self.log.id(offer_id)}.")
|
||||||
|
|
||||||
ci_from = self.ci(offer.coin_to)
|
ci_from = self.ci(offer.coin_to)
|
||||||
ci_to = self.ci(offer.coin_from)
|
ci_to = self.ci(offer.coin_from)
|
||||||
@@ -9506,12 +9513,12 @@ class BasicSwap(BaseApp):
|
|||||||
|
|
||||||
bid_id = msg_data.bid_msg_id
|
bid_id = msg_data.bid_msg_id
|
||||||
bid, xmr_swap = self.getXmrBid(bid_id)
|
bid, xmr_swap = self.getXmrBid(bid_id)
|
||||||
ensure(bid, "Bid not found: {}.".format(bid_id.hex()))
|
ensure(bid, f"Bid not found: {self.log.id(bid_id)}.")
|
||||||
ensure(xmr_swap, "Adaptor-sig swap not found: {}.".format(bid_id.hex()))
|
ensure(xmr_swap, f"Adaptor-sig swap not found: {self.log.id(bid_id)}.")
|
||||||
|
|
||||||
offer, xmr_offer = self.getXmrOffer(bid.offer_id)
|
offer, xmr_offer = self.getXmrOffer(bid.offer_id)
|
||||||
ensure(offer, "Offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(offer, f"Offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
ensure(xmr_offer, "Adaptor-sig offer not found: {}.".format(bid.offer_id.hex()))
|
ensure(xmr_offer, f"Adaptor-sig offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
|
|
||||||
ensure(msg["to"] == bid.bid_addr, "Received on incorrect address")
|
ensure(msg["to"] == bid.bid_addr, "Received on incorrect address")
|
||||||
ensure(msg["from"] == offer.addr_from, "Sent from incorrect address")
|
ensure(msg["from"] == offer.addr_from, "Sent from incorrect address")
|
||||||
@@ -9922,8 +9929,8 @@ class BasicSwap(BaseApp):
|
|||||||
try:
|
try:
|
||||||
cursor = self.openDB()
|
cursor = self.openDB()
|
||||||
bid, offer = self.getBidAndOffer(bid_id, cursor)
|
bid, offer = self.getBidAndOffer(bid_id, cursor)
|
||||||
ensure(bid, "Bid not found {}".format(bid_id.hex()))
|
ensure(bid, f"Bid not found: {self.log.id(bid_id)}.")
|
||||||
ensure(offer, "Offer not found {}".format(bid.offer_id.hex()))
|
ensure(offer, f"Offer not found: {self.log.id(bid.offer_id)}.")
|
||||||
|
|
||||||
has_changed = False
|
has_changed = False
|
||||||
if bid.state != data["bid_state"]:
|
if bid.state != data["bid_state"]:
|
||||||
|
|||||||
@@ -1495,7 +1495,14 @@ class BTCInterface(Secp256k1Interface):
|
|||||||
return (weight + wsf - 1) // wsf
|
return (weight + wsf - 1) // wsf
|
||||||
|
|
||||||
def findTxB(
|
def findTxB(
|
||||||
self, kbv, Kbs, cb_swap_value, cb_block_confirmed, restore_height, bid_sender
|
self,
|
||||||
|
kbv,
|
||||||
|
Kbs,
|
||||||
|
cb_swap_value: int,
|
||||||
|
cb_block_confirmed: int,
|
||||||
|
restore_height: int,
|
||||||
|
bid_sender: bool,
|
||||||
|
check_amount: bool = True,
|
||||||
):
|
):
|
||||||
dest_address = (
|
dest_address = (
|
||||||
self.pubkey_to_segwit_address(Kbs)
|
self.pubkey_to_segwit_address(Kbs)
|
||||||
|
|||||||
@@ -1029,10 +1029,11 @@ class PARTInterfaceBlind(PARTInterface):
|
|||||||
self,
|
self,
|
||||||
kbv,
|
kbv,
|
||||||
Kbs,
|
Kbs,
|
||||||
cb_swap_value,
|
cb_swap_value: int,
|
||||||
cb_block_confirmed,
|
cb_block_confirmed: int,
|
||||||
restore_height: int,
|
restore_height: int,
|
||||||
bid_sender: bool,
|
bid_sender: bool,
|
||||||
|
check_amount: bool = True,
|
||||||
):
|
):
|
||||||
Kbv = self.getPubkey(kbv)
|
Kbv = self.getPubkey(kbv)
|
||||||
sx_addr = self.formatStealthAddress(Kbv, Kbs)
|
sx_addr = self.formatStealthAddress(Kbv, Kbs)
|
||||||
@@ -1063,7 +1064,10 @@ class PARTInterfaceBlind(PARTInterface):
|
|||||||
) # Should not be possible
|
) # Should not be possible
|
||||||
ensure(tx["outputs"][0]["type"] == "blind", "Output is not anon")
|
ensure(tx["outputs"][0]["type"] == "blind", "Output is not anon")
|
||||||
|
|
||||||
if self.make_int(tx["outputs"][0]["amount"]) == cb_swap_value:
|
if (
|
||||||
|
self.make_int(tx["outputs"][0]["amount"]) == cb_swap_value
|
||||||
|
or check_amount is False
|
||||||
|
):
|
||||||
height = 0
|
height = 0
|
||||||
if tx["confirmations"] > 0:
|
if tx["confirmations"] > 0:
|
||||||
chain_height = self.rpc("getblockcount")
|
chain_height = self.rpc("getblockcount")
|
||||||
@@ -1285,7 +1289,14 @@ class PARTInterfaceAnon(PARTInterface):
|
|||||||
return bytes.fromhex(txid)
|
return bytes.fromhex(txid)
|
||||||
|
|
||||||
def findTxB(
|
def findTxB(
|
||||||
self, kbv, Kbs, cb_swap_value, cb_block_confirmed, restore_height, bid_sender
|
self,
|
||||||
|
kbv,
|
||||||
|
Kbs,
|
||||||
|
cb_swap_value,
|
||||||
|
cb_block_confirmed,
|
||||||
|
restore_height,
|
||||||
|
bid_sender,
|
||||||
|
check_amount: bool = True,
|
||||||
):
|
):
|
||||||
Kbv = self.getPubkey(kbv)
|
Kbv = self.getPubkey(kbv)
|
||||||
sx_addr = self.formatStealthAddress(Kbv, Kbs)
|
sx_addr = self.formatStealthAddress(Kbv, Kbs)
|
||||||
@@ -1317,7 +1328,10 @@ class PARTInterfaceAnon(PARTInterface):
|
|||||||
) # Should not be possible
|
) # Should not be possible
|
||||||
ensure(tx["outputs"][0]["type"] == "anon", "Output is not anon")
|
ensure(tx["outputs"][0]["type"] == "anon", "Output is not anon")
|
||||||
|
|
||||||
if self.make_int(tx["outputs"][0]["amount"]) == cb_swap_value:
|
if (
|
||||||
|
self.make_int(tx["outputs"][0]["amount"]) == cb_swap_value
|
||||||
|
or check_amount is False
|
||||||
|
):
|
||||||
height = 0
|
height = 0
|
||||||
if tx["confirmations"] > 0:
|
if tx["confirmations"] > 0:
|
||||||
chain_height = self.rpc("getblockcount")
|
chain_height = self.rpc("getblockcount")
|
||||||
|
|||||||
@@ -455,16 +455,24 @@ class XMRInterface(CoinInterface):
|
|||||||
params["priority"] = self._fee_priority
|
params["priority"] = self._fee_priority
|
||||||
rv = self.rpc_wallet("transfer", params)
|
rv = self.rpc_wallet("transfer", params)
|
||||||
self._log.info(
|
self._log.info(
|
||||||
"publishBLockTx %s to address_b58 %s",
|
"publishBLockTx {} to address_b58 {}".format(
|
||||||
self._log.id(rv["tx_hash"]),
|
self._log.id(rv["tx_hash"]),
|
||||||
self._log.addr(shared_addr),
|
self._log.addr(shared_addr),
|
||||||
)
|
)
|
||||||
|
)
|
||||||
tx_hash = bytes.fromhex(rv["tx_hash"])
|
tx_hash = bytes.fromhex(rv["tx_hash"])
|
||||||
|
|
||||||
return tx_hash
|
return tx_hash
|
||||||
|
|
||||||
def findTxB(
|
def findTxB(
|
||||||
self, kbv, Kbs, cb_swap_value, cb_block_confirmed, restore_height, bid_sender
|
self,
|
||||||
|
kbv,
|
||||||
|
Kbs,
|
||||||
|
cb_swap_value: int,
|
||||||
|
cb_block_confirmed: int,
|
||||||
|
restore_height: int,
|
||||||
|
bid_sender: bool,
|
||||||
|
check_amount: bool = True,
|
||||||
):
|
):
|
||||||
with self._mx_wallet:
|
with self._mx_wallet:
|
||||||
Kbv = self.getPubkey(kbv)
|
Kbv = self.getPubkey(kbv)
|
||||||
@@ -516,7 +524,7 @@ class XMRInterface(CoinInterface):
|
|||||||
)
|
)
|
||||||
rv = -1
|
rv = -1
|
||||||
continue
|
continue
|
||||||
if transfer["amount"] == cb_swap_value:
|
if transfer["amount"] == cb_swap_value or check_amount is False:
|
||||||
return {
|
return {
|
||||||
"txid": transfer["tx_hash"],
|
"txid": transfer["tx_hash"],
|
||||||
"amount": transfer["amount"],
|
"amount": transfer["amount"],
|
||||||
|
|||||||
@@ -476,9 +476,10 @@ def compare_bid_states(states, expect_states, exact_match: bool = True) -> bool:
|
|||||||
raise ValueError(f"Expected state {expect_states[i]}, found {s[1]}")
|
raise ValueError(f"Expected state {expect_states[i]}, found {s[1]}")
|
||||||
assert s[1] == expect_states[i]
|
assert s[1] == expect_states[i]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
logging.error(f"compare_bid_states failed: {e}")
|
||||||
logging.info("Expecting states: {}".format(json.dumps(expect_states, indent=4)))
|
logging.info("Expecting states: {}".format(json.dumps(expect_states, indent=4)))
|
||||||
logging.info("Have states: {}".format(json.dumps(states, indent=4)))
|
logging.info("Have states: {}".format(json.dumps(states, indent=4)))
|
||||||
raise e
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import time
|
|||||||
import traceback
|
import traceback
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from copy import deepcopy
|
||||||
|
|
||||||
import basicswap.config as cfg
|
import basicswap.config as cfg
|
||||||
from basicswap.db import (
|
from basicswap.db import (
|
||||||
Concepts,
|
Concepts,
|
||||||
@@ -1737,8 +1739,16 @@ class Test(BaseTest):
|
|||||||
offerer_states = read_json_api(1800, path)
|
offerer_states = read_json_api(1800, path)
|
||||||
bidder_states = read_json_api(1801, path)
|
bidder_states = read_json_api(1801, path)
|
||||||
|
|
||||||
|
states_bidder_alt = deepcopy(self.states_bidder[1])
|
||||||
|
states_bidder_alt[7] = "Bid Script pre-refund tx in chain"
|
||||||
|
states_bidder_alt[8] = "Bid Scriptless coin locked"
|
||||||
assert compare_bid_states(offerer_states, self.states_offerer[1]) is True
|
assert compare_bid_states(offerer_states, self.states_offerer[1]) is True
|
||||||
assert compare_bid_states(bidder_states, self.states_bidder[1]) is True
|
assert any(
|
||||||
|
[
|
||||||
|
compare_bid_states(bidder_states, self.states_bidder[1]),
|
||||||
|
compare_bid_states(bidder_states, states_bidder_alt),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
def test_05_btc_xmr(self):
|
def test_05_btc_xmr(self):
|
||||||
logging.info("---------- Test BTC to XMR")
|
logging.info("---------- Test BTC to XMR")
|
||||||
@@ -2103,7 +2113,7 @@ class Test(BaseTest):
|
|||||||
for i in range(5):
|
for i in range(5):
|
||||||
bid_ids.append(swap_clients[1].postBid(offer_id, min_bid))
|
bid_ids.append(swap_clients[1].postBid(offer_id, min_bid))
|
||||||
|
|
||||||
# Should fail > max concurrent
|
# Should (temporarily) fail > max concurrent
|
||||||
test_delay_event.wait(1.0)
|
test_delay_event.wait(1.0)
|
||||||
bid_id = swap_clients[1].postBid(offer_id, min_bid)
|
bid_id = swap_clients[1].postBid(offer_id, min_bid)
|
||||||
logging.info("Waiting for bid {} to fail.".format(bid_id.hex()))
|
logging.info("Waiting for bid {} to fail.".format(bid_id.hex()))
|
||||||
@@ -2113,6 +2123,7 @@ class Test(BaseTest):
|
|||||||
Concepts.BID,
|
Concepts.BID,
|
||||||
bid_id,
|
bid_id,
|
||||||
event_type=EventLogTypes.AUTOMATION_CONSTRAINT,
|
event_type=EventLogTypes.AUTOMATION_CONSTRAINT,
|
||||||
|
wait_for=120,
|
||||||
)
|
)
|
||||||
assert "Already have 5 bids to complete" in event.event_msg
|
assert "Already have 5 bids to complete" in event.event_msg
|
||||||
|
|
||||||
@@ -2130,9 +2141,11 @@ class Test(BaseTest):
|
|||||||
bid_id,
|
bid_id,
|
||||||
BidStates.SWAP_COMPLETED,
|
BidStates.SWAP_COMPLETED,
|
||||||
sent=True,
|
sent=True,
|
||||||
|
wait_for=40,
|
||||||
)
|
)
|
||||||
|
|
||||||
amt_bid = make_int(5, scale=8, r=1)
|
# Six bids of 1 should be active/completed
|
||||||
|
amt_bid = make_int(4, scale=8, r=1)
|
||||||
|
|
||||||
# Should fail > total value
|
# Should fail > total value
|
||||||
amt_bid += 1
|
amt_bid += 1
|
||||||
@@ -2143,6 +2156,7 @@ class Test(BaseTest):
|
|||||||
Concepts.BID,
|
Concepts.BID,
|
||||||
bid_id,
|
bid_id,
|
||||||
event_type=EventLogTypes.AUTOMATION_CONSTRAINT,
|
event_type=EventLogTypes.AUTOMATION_CONSTRAINT,
|
||||||
|
wait_for=40,
|
||||||
)
|
)
|
||||||
assert "Over remaining offer value" in event.event_msg
|
assert "Over remaining offer value" in event.event_msg
|
||||||
|
|
||||||
@@ -2162,6 +2176,7 @@ class Test(BaseTest):
|
|||||||
bid_id,
|
bid_id,
|
||||||
BidStates.SWAP_COMPLETED,
|
BidStates.SWAP_COMPLETED,
|
||||||
sent=True,
|
sent=True,
|
||||||
|
wait_for=40,
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_10_locked_refundtx(self):
|
def test_10_locked_refundtx(self):
|
||||||
@@ -2455,6 +2470,15 @@ class Test(BaseTest):
|
|||||||
logging.info("---------- Test PART to XMR leader recovers coin a lock tx")
|
logging.info("---------- Test PART to XMR leader recovers coin a lock tx")
|
||||||
swap_clients = self.swap_clients
|
swap_clients = self.swap_clients
|
||||||
|
|
||||||
|
# Fails in XMR 0.18.4
|
||||||
|
# "Transaction cannot have non-zero unlock time"
|
||||||
|
xmr_version = swap_clients[0].ci(Coins.XMR).getDaemonVersion()
|
||||||
|
if xmr_version >= 65564:
|
||||||
|
logging.warning(
|
||||||
|
"XMR versions >= 0.18.4, can't create txns with non-zero unlock time."
|
||||||
|
)
|
||||||
|
return True
|
||||||
|
|
||||||
amt_swap = make_int(random.uniform(0.1, 10.0), scale=8, r=1)
|
amt_swap = make_int(random.uniform(0.1, 10.0), scale=8, r=1)
|
||||||
rate_swap = make_int(random.uniform(2.0, 20.0), scale=12, r=1)
|
rate_swap = make_int(random.uniform(2.0, 20.0), scale=12, r=1)
|
||||||
offer_id = swap_clients[0].postOffer(
|
offer_id = swap_clients[0].postOffer(
|
||||||
@@ -2634,6 +2658,8 @@ class Test(BaseTest):
|
|||||||
logging.info("---------- Test PART to XMR B lock tx is lost")
|
logging.info("---------- Test PART to XMR B lock tx is lost")
|
||||||
swap_clients = self.swap_clients
|
swap_clients = self.swap_clients
|
||||||
|
|
||||||
|
# - B_LOCK_TX_MISSED_SEND: Send XMR tx without recording txid to DB. XMR amount reduced to prevent swap from continuing.
|
||||||
|
|
||||||
amt_swap = make_int(random.uniform(0.1, 10.0), scale=8, r=1)
|
amt_swap = make_int(random.uniform(0.1, 10.0), scale=8, r=1)
|
||||||
rate_swap = make_int(random.uniform(2.0, 20.0), scale=12, r=1)
|
rate_swap = make_int(random.uniform(2.0, 20.0), scale=12, r=1)
|
||||||
offer_id = swap_clients[0].postOffer(
|
offer_id = swap_clients[0].postOffer(
|
||||||
|
|||||||
Reference in New Issue
Block a user