mirror of
https://github.com/basicswap/basicswap.git
synced 2026-06-10 04:51:41 +02:00
Merge pull request #491 from gerlofvanek/electrum_fixes_3
Verify initiate lock-tx amount.
This commit is contained in:
@@ -8454,6 +8454,18 @@ class BasicSwap(BaseApp, BSXNetwork, UIApp):
|
||||
)
|
||||
index = None
|
||||
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"]
|
||||
if "index" in found:
|
||||
index = found["index"]
|
||||
|
||||
@@ -322,6 +322,7 @@ class BCHInterface(BTCInterface):
|
||||
"depth": confirmations,
|
||||
"index": found_vout,
|
||||
"height": block_height,
|
||||
"value": self.make_int(txout["value"]),
|
||||
}
|
||||
|
||||
return rv
|
||||
|
||||
@@ -3006,6 +3006,8 @@ class BTCInterface(FeeValidator, Secp256k1Interface):
|
||||
if find_index:
|
||||
tx_obj = self.rpc("decoderawtransaction", [tx["hex"]])
|
||||
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:
|
||||
rv["txid"] = txid.hex()
|
||||
@@ -3063,6 +3065,7 @@ class BTCInterface(FeeValidator, Secp256k1Interface):
|
||||
for idx, txout in enumerate(tx.vout):
|
||||
if txout.scriptPubKey == dest_script:
|
||||
rv["index"] = idx
|
||||
rv["value"] = txout.nValue
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
@@ -3124,6 +3127,7 @@ class BTCInterface(FeeValidator, Secp256k1Interface):
|
||||
for idx, txout in enumerate(tx.vout):
|
||||
if txout.scriptPubKey == dest_script:
|
||||
rv["index"] = idx
|
||||
rv["value"] = txout.nValue
|
||||
break
|
||||
except Exception as e:
|
||||
self._log.debug(
|
||||
|
||||
@@ -940,6 +940,7 @@ class DCRInterface(FeeValidator, Secp256k1Interface):
|
||||
"depth": confirmations,
|
||||
"index": found_vout,
|
||||
"height": block_height,
|
||||
"value": self.make_int(txout["value"]),
|
||||
}
|
||||
|
||||
return rv
|
||||
|
||||
@@ -276,6 +276,8 @@ class FIROInterface(BTCInterface):
|
||||
if find_index:
|
||||
tx_obj = self.rpc("decoderawtransaction", [tx["hex"]])
|
||||
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:
|
||||
rv["txid"] = txid.hex()
|
||||
|
||||
@@ -614,6 +614,8 @@ class NAVInterface(BTCInterface):
|
||||
if find_index:
|
||||
tx_obj = self.rpc("decoderawtransaction", [tx["hex"]])
|
||||
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:
|
||||
rv["txid"] = txid.hex()
|
||||
|
||||
Reference in New Issue
Block a user