mirror of
https://github.com/basicswap/basicswap.git
synced 2026-06-10 13:01:41 +02:00
Verify initiate lock-tx amount.
This commit is contained in:
@@ -8454,6 +8454,18 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
|||||||
)
|
)
|
||||||
index = None
|
index = None
|
||||||
if found:
|
if found:
|
||||||
|
if (
|
||||||
|
"value" in found
|
||||||
|
and found["value"] is not None
|
||||||
|
and found["value"] != int(bid.amount)
|
||||||
|
):
|
||||||
|
self.setBidError(
|
||||||
|
bid,
|
||||||
|
"Incorrect output amount in initiate txn {}: {} != {}.".format(
|
||||||
|
initiate_txnid_hex, found["value"], int(bid.amount)
|
||||||
|
),
|
||||||
|
)
|
||||||
|
return True
|
||||||
bid.initiate_tx.conf = found["depth"]
|
bid.initiate_tx.conf = found["depth"]
|
||||||
if "index" in found:
|
if "index" in found:
|
||||||
index = found["index"]
|
index = found["index"]
|
||||||
|
|||||||
@@ -322,6 +322,7 @@ class BCHInterface(BTCInterface):
|
|||||||
"depth": confirmations,
|
"depth": confirmations,
|
||||||
"index": found_vout,
|
"index": found_vout,
|
||||||
"height": block_height,
|
"height": block_height,
|
||||||
|
"value": self.make_int(txout["value"]),
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv
|
return rv
|
||||||
|
|||||||
@@ -3006,6 +3006,8 @@ class BTCInterface(FeeValidator, Secp256k1Interface):
|
|||||||
if find_index:
|
if find_index:
|
||||||
tx_obj = self.rpc("decoderawtransaction", [tx["hex"]])
|
tx_obj = self.rpc("decoderawtransaction", [tx["hex"]])
|
||||||
rv["index"] = find_vout_for_address_from_txobj(tx_obj, dest_address)
|
rv["index"] = find_vout_for_address_from_txobj(tx_obj, dest_address)
|
||||||
|
if rv["index"] is not None and rv["index"] >= 0:
|
||||||
|
rv["value"] = self.make_int(tx_obj["vout"][rv["index"]]["value"])
|
||||||
|
|
||||||
if return_txid:
|
if return_txid:
|
||||||
rv["txid"] = txid.hex()
|
rv["txid"] = txid.hex()
|
||||||
@@ -3063,6 +3065,7 @@ class BTCInterface(FeeValidator, Secp256k1Interface):
|
|||||||
for idx, txout in enumerate(tx.vout):
|
for idx, txout in enumerate(tx.vout):
|
||||||
if txout.scriptPubKey == dest_script:
|
if txout.scriptPubKey == dest_script:
|
||||||
rv["index"] = idx
|
rv["index"] = idx
|
||||||
|
rv["value"] = txout.nValue
|
||||||
break
|
break
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
@@ -3124,6 +3127,7 @@ class BTCInterface(FeeValidator, Secp256k1Interface):
|
|||||||
for idx, txout in enumerate(tx.vout):
|
for idx, txout in enumerate(tx.vout):
|
||||||
if txout.scriptPubKey == dest_script:
|
if txout.scriptPubKey == dest_script:
|
||||||
rv["index"] = idx
|
rv["index"] = idx
|
||||||
|
rv["value"] = txout.nValue
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._log.debug(
|
self._log.debug(
|
||||||
|
|||||||
@@ -940,6 +940,7 @@ class DCRInterface(FeeValidator, Secp256k1Interface):
|
|||||||
"depth": confirmations,
|
"depth": confirmations,
|
||||||
"index": found_vout,
|
"index": found_vout,
|
||||||
"height": block_height,
|
"height": block_height,
|
||||||
|
"value": self.make_int(txout["value"]),
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv
|
return rv
|
||||||
|
|||||||
@@ -276,6 +276,8 @@ class FIROInterface(BTCInterface):
|
|||||||
if find_index:
|
if find_index:
|
||||||
tx_obj = self.rpc("decoderawtransaction", [tx["hex"]])
|
tx_obj = self.rpc("decoderawtransaction", [tx["hex"]])
|
||||||
rv["index"] = find_vout_for_address_from_txobj(tx_obj, dest_address)
|
rv["index"] = find_vout_for_address_from_txobj(tx_obj, dest_address)
|
||||||
|
if rv["index"] is not None and rv["index"] >= 0:
|
||||||
|
rv["value"] = self.make_int(tx_obj["vout"][rv["index"]]["value"])
|
||||||
|
|
||||||
if return_txid:
|
if return_txid:
|
||||||
rv["txid"] = txid.hex()
|
rv["txid"] = txid.hex()
|
||||||
|
|||||||
@@ -614,6 +614,8 @@ class NAVInterface(BTCInterface):
|
|||||||
if find_index:
|
if find_index:
|
||||||
tx_obj = self.rpc("decoderawtransaction", [tx["hex"]])
|
tx_obj = self.rpc("decoderawtransaction", [tx["hex"]])
|
||||||
rv["index"] = find_vout_for_address_from_txobj(tx_obj, dest_address)
|
rv["index"] = find_vout_for_address_from_txobj(tx_obj, dest_address)
|
||||||
|
if rv["index"] is not None and rv["index"] >= 0:
|
||||||
|
rv["value"] = self.make_int(tx_obj["vout"][rv["index"]]["value"])
|
||||||
|
|
||||||
if return_txid:
|
if return_txid:
|
||||||
rv["txid"] = txid.hex()
|
rv["txid"] = txid.hex()
|
||||||
|
|||||||
Reference in New Issue
Block a user