Transaction

class hodl.block.Transaction.Transaction[source]

Class for transaction. To create new transaction, use: tnx=Transaction() tnx.gen(parameters)

classmethod from_json(s)[source]

Decodes transacion from str using JSON

Parameters:s (str) – Transaction’s str representation got by str(tnx)
Returns:transaction
Return type:Transaction
is_valid(bch)[source]

Returns validness of transaction. Checks: is sign valid are all money spent

Parameters:bch (Blockchain) – blockchain
Returns:Transaction validness
Return type:bool
spent(bch, exc=())[source]

Checks if money from transaction are spent

Parameters:
  • bch – Blockchain
  • exc – txs to exclude
Returns:

Is transaction used by other transaction

update()[source]

Update hash

hodl.block.Transaction.is_tnx_money_valid(self, bch)[source]

Validate tnx

Parameters:
  • self – Transaction
  • bch – Blockchain
Returns:

validness(bool)

hodl.block.Transaction.rm_dubl_from_outs(outs, outns)[source]

Remove dublicated addresses from tnx’s outs

Parameters:
  • outs – list, tnx.outs
  • outns – list, tnx.outns
Returns:

clean outs: list, clean outns: list

hodl.block.Transaction.sign_tnx(self, sign, privkey, t)[source]

Sign tnx with privkey or use existing sign

Parameters:
  • self – tnx
  • sign – existing sign or ‘signing’
  • privkey – private key or nothing
  • t – existing timestamp if privkey is ‘signing’ or something else
Returns:

sign (str)