Bitcoin-ABC/ElectrumABC

error when building a proof with a unconfirmed coin with an unconfirmed parent

PiRK opened this issue · 1 comments

PiRK commented
Traceback (most recent call last):
  File "/home/pierre/dev/ElectrumABC/electroncash_gui/qt/avalanche_dialogs.py", line 240, in _on_generate_clicked
    proof = self._build()
  File "/home/pierre/dev/ElectrumABC/electroncash_gui/qt/avalanche_dialogs.py", line 291, in _build
    proofbuilder.add_utxo(
  File "/home/pierre/dev/ElectrumABC/electroncash/avalanche/proof.py", line 246, in add_utxo
    stake = Stake(utxo, amount, height, privkey.get_pubkey(), is_coinbase)
  File "/home/pierre/dev/ElectrumABC/electroncash/avalanche/proof.py", line 69, in __init__
    self.stake_id = UInt256(sha256d(self.serialize()))
  File "/home/pierre/dev/ElectrumABC/electroncash/avalanche/proof.py", line 78, in serialize
    + struct.pack("qI", self.amount, height_ser)
struct.error: argument out of range

PiRK commented

The Stake serialization require the block height. This is 0 for unconfirmed transactions and -1 for unconfirmed transactions with unconfirmed parents, which causes the error as we try to serialize -1 as an unsigned int.

This highlights an underlying issue that we should not be able to create a proof with unconfirmed coins.