Verify initiate lock-tx amount.

This commit is contained in:
gerlofvanek
2026-06-08 22:47:23 +02:00
parent d16e658a66
commit 4ac0321acb
6 changed files with 22 additions and 0 deletions
+12
View File
@@ -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"]
+1
View File
@@ -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
+4
View File
@@ -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(
+1
View File
@@ -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
+2
View File
@@ -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()
+2
View File
@@ -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()