from bitcoin.core import x, b2x

from hashmal_lib.core import chainparams
from hashmal_lib.core.transaction import Transaction
from hashmal_lib import gui_utils

from hashmal_plugins.decred_tools.hashmal_decred import (
    DecredPreset,
    dcr_header_fields,
    dcr_tx_fields,
    dcr_prevout_fields,
    dcr_txin_fields,
    dcr_txout_fields,
)

chainparams.add_preset(DecredPreset)


class TransactionTest(unittest.TestCase):
    def setUp(self):
        super(TransactionTest, self).setUp()
        chainparams.set_to_preset("Decred")

    def test_transaction_deserialization_and_serialization(self):
        # Transaction from Decred unit test.
        raw_tx = x(
            "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff00ffffffff0200f2052a01000000abab434104d64bdfd09eb1c5fe295abdeb1dca4281be988e2da0b6c1c6a59dc226c28624e18175e851c96b973d81b01cc31f047834bc06d6d6edf620d184241a6aed8b63a6ac00e1f50500000000bcbc434104d64bdfd09eb1c5fe295abdeb1dca4281be988e2da0b6c1c6a59dc226c28624e18175e851c96b973d81b01cc31f047834bc06d6d6edf620d184241a6aed8b63a6ac00000000000000000112121212121212121515151534343434070431dc001b0162"
        )
        tx = Transaction.deserialize(raw_tx)

        self.assertEqual(1, tx.nVersion)
Exemplo n.º 2
0
 def add_params_preset(self, preset):
     try:
         chainparams.add_preset(preset)
     except Exception as e:
         self.error(str(e))
Exemplo n.º 3
0
 def add_params_preset(self, preset):
     try:
         chainparams.add_preset(preset)
     except Exception as e:
         self.error(str(e))