Transactions

The class for creating transaction.

class pybgl.Transaction(raw_tx=None, format='decoded', version=1, lock_time=0, testnet=False, auto_commit=True, keep_raw_tx=False)[source]

The class for Transaction object

Parameters
  • raw_tx – (optional) raw transaction in bytes or HEX encoded string, if no raw transaction provided well be created new empty transaction template.

  • format – (optional) “raw” or “decoded” format. Raw format is mean that all transaction represented in bytes for best performance. Decoded transaction is represented in human readable format using base68, hex, bech32, asm and opcodes. By default “decoded” format using.

  • version – (optional) transaction version for new template, by default is 1.

  • lock_time – (optional) transaction lock time for new template, by default is 0.

  • testnet – (optional) flag for testnet network, by default is False.

  • auto_commit – (optional) boolean, by default is True.

  • keep_raw_tx – (optional) boolean, by default is False.

decode(testnet=None)[source]

change Transaction object representation to “decoded” human readable format

Parameters

testnet – (optional) flag for testnet network, by default is False.

encode()[source]

change Transaction object representation to “raw” bytes format, all human readable part will be stripped.

json()[source]

get json Transaction representation

serialize(segwit=True, hex=True)[source]

get serialized Transaction

Parameters
  • segwit – (optional) flag for segwit representation of serialized transaction, by default True.

  • hex – (optional) if set to True return HEX encoded string, by default is True.

Return str,bytes

serialized transaction in HEX or bytes.