mirror of
https://github.com/basicswap/basicswap.git
synced 2026-03-19 16:27:22 +01:00
Replace sqlalchemy with manbearpigSQL
This commit is contained in:
@@ -612,11 +612,11 @@ class BCHInterface(BTCInterface):
|
||||
prevout_script: bytes,
|
||||
prevout_value: int,
|
||||
) -> bool:
|
||||
# simple ecdsa signature verification
|
||||
# Simple ecdsa signature verification
|
||||
return self.verifyDataSig(tx_bytes, sig, K)
|
||||
|
||||
def verifyDataSig(self, data: bytes, sig: bytes, K: bytes) -> bool:
|
||||
# simple ecdsa signature verification
|
||||
# Simple ecdsa signature verification
|
||||
pubkey = PublicKey(K)
|
||||
return pubkey.verify(sig, sha256(data), hasher=None)
|
||||
|
||||
@@ -637,7 +637,7 @@ class BCHInterface(BTCInterface):
|
||||
return signature, mining_fee, out_1, out_2, public_key, timelock
|
||||
|
||||
def extractScriptLockScriptValues(self, script_bytes):
|
||||
# see BCHInterface.genScriptLockTxScript for reference
|
||||
# See BCHInterface.genScriptLockTxScript for reference
|
||||
|
||||
o = 0
|
||||
|
||||
@@ -1071,6 +1071,9 @@ class BCHInterface(BTCInterface):
|
||||
)
|
||||
return out_1
|
||||
|
||||
def lockNonSegwitPrevouts(self) -> None:
|
||||
pass
|
||||
|
||||
def createMercyTx(
|
||||
self,
|
||||
refund_swipe_tx_bytes: bytes,
|
||||
|
||||
@@ -1158,7 +1158,8 @@ class BTCInterface(Secp256k1Interface):
|
||||
|
||||
def fundTx(self, tx: bytes, feerate) -> bytes:
|
||||
feerate_str = self.format_amount(feerate)
|
||||
# TODO: unlock unspents if bid cancelled
|
||||
# TODO: Unlock unspents if bid cancelled
|
||||
# TODO: Manually select only segwit prevouts
|
||||
options = {
|
||||
"lockUnspents": True,
|
||||
"feeRate": feerate_str,
|
||||
@@ -1166,6 +1167,27 @@ class BTCInterface(Secp256k1Interface):
|
||||
rv = self.rpc_wallet("fundrawtransaction", [tx.hex(), options])
|
||||
return bytes.fromhex(rv["hex"])
|
||||
|
||||
def lockNonSegwitPrevouts(self) -> None:
|
||||
# For tests
|
||||
unspent = self.rpc_wallet("listunspent")
|
||||
|
||||
to_lock = []
|
||||
for u in unspent:
|
||||
if u.get("spendable", False) is False:
|
||||
continue
|
||||
if "desc" in u:
|
||||
desc = u["desc"]
|
||||
if self.use_p2shp2wsh():
|
||||
if not desc.startswith("sh(wpkh"):
|
||||
to_lock.append({"txid": u["txid"], "vout": u["vout"]})
|
||||
else:
|
||||
if not desc.startswith("wpkh"):
|
||||
to_lock.append({"txid": u["txid"], "vout": u["vout"]})
|
||||
|
||||
if len(to_lock) > 0:
|
||||
self._log.debug(f"Locking {len(to_lock)} non segwit prevouts")
|
||||
self.rpc_wallet("lockunspent", [False, to_lock])
|
||||
|
||||
def listInputs(self, tx_bytes: bytes):
|
||||
tx = self.loadTx(tx_bytes)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user