mirror of
https://github.com/basicswap/basicswap.git
synced 2026-06-08 12:11:41 +02:00
Fix: PIVX/Firo bug and test_pivx.py
This commit is contained in:
@@ -1083,8 +1083,8 @@ class BTCInterface(Secp256k1Interface):
|
||||
return self.encode_p2wsh(script)
|
||||
|
||||
def getDestForAddress(self, address: str) -> bytes:
|
||||
bech32_prefix = self.chainparams_network()["hrp"]
|
||||
if address.startswith(bech32_prefix + "1"):
|
||||
bech32_prefix: str | None = self.chainparams_network().get("hrp", None)
|
||||
if bech32_prefix and address.startswith(bech32_prefix + "1"):
|
||||
_, witprog = segwit_addr.decode(bech32_prefix, address)
|
||||
return CScript([OP_0, bytes(witprog)])
|
||||
|
||||
|
||||
@@ -361,7 +361,7 @@ class FIROInterface(BTCInterface):
|
||||
)
|
||||
return pay_fee
|
||||
|
||||
def signTxWithKey(self, tx: bytes, key: bytes) -> bytes:
|
||||
def signTxWithKey(self, tx: bytes, key: bytes, prev_amount=None) -> bytes:
|
||||
key_wif = self.encodeKey(key)
|
||||
rv = self.rpc(
|
||||
"signrawtransaction",
|
||||
|
||||
@@ -12,7 +12,7 @@ from .btc import BTCInterface
|
||||
from basicswap.rpc import make_rpc_func
|
||||
from basicswap.chainparams import Coins
|
||||
from basicswap.util.address import decodeAddress
|
||||
from .contrib.pivx_test_framework.messages import CBlock, ToHex, FromHex, CTransaction
|
||||
from .contrib.pivx_test_framework.messages import CTransaction
|
||||
from basicswap.contrib.test_framework.script import (
|
||||
CScript,
|
||||
OP_DUP,
|
||||
@@ -100,29 +100,13 @@ class PIVXInterface(BTCInterface):
|
||||
return decodeAddress(address)[1:]
|
||||
|
||||
def getBlockWithTxns(self, block_hash):
|
||||
# TODO: Bypass decoderawtransaction and getblockheader
|
||||
block = self.rpc("getblock", [block_hash, False])
|
||||
block_header = self.rpc("getblockheader", [block_hash])
|
||||
decoded_block = CBlock()
|
||||
decoded_block = FromHex(decoded_block, block)
|
||||
|
||||
block = self.rpc("getblock", [block_hash, True])
|
||||
tx_rv = []
|
||||
for tx in decoded_block.vtx:
|
||||
tx_dec = self.rpc("decoderawtransaction", [ToHex(tx)])
|
||||
for txid_str in block["tx"]:
|
||||
tx_dec = self.rpc("getrawtransaction", [txid_str, True])
|
||||
tx_rv.append(tx_dec)
|
||||
|
||||
block_rv = {
|
||||
"hash": block_hash,
|
||||
"previousblockhash": block_header["previousblockhash"],
|
||||
"tx": tx_rv,
|
||||
"confirmations": block_header["confirmations"],
|
||||
"height": block_header["height"],
|
||||
"time": block_header["time"],
|
||||
"version": block_header["version"],
|
||||
"merkleroot": block_header["merkleroot"],
|
||||
}
|
||||
|
||||
return block_rv
|
||||
block["tx"] = tx_rv
|
||||
return block
|
||||
|
||||
def withdrawCoin(self, value, addr_to, subfee):
|
||||
params = [addr_to, value, "", "", subfee]
|
||||
@@ -150,7 +134,7 @@ class PIVXInterface(BTCInterface):
|
||||
)
|
||||
return pay_fee
|
||||
|
||||
def signTxWithKey(self, tx: bytes, key: bytes) -> bytes:
|
||||
def signTxWithKey(self, tx: bytes, key: bytes, prev_amount=None) -> bytes:
|
||||
key_wif = self.encodeKey(key)
|
||||
rv = self.rpc(
|
||||
"signrawtransaction",
|
||||
|
||||
Reference in New Issue
Block a user