bbclib.libs.bbclib_transaction module

Copyright (c) 2017 beyond-blockchain.org.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class bbclib.libs.bbclib_transaction.BBcTransaction(version=1, unpack=None, id_length=None)[source]

Bases: object

Transaction object

WITH_WIRE = False
add(event=None, reference=None, relation=None, witness=None, cross_ref=None)[source]

Add parts

add_signature(user_id=None, signature=None)[source]

Add signature in the reserved space

Parameters:
  • user_id (bytes) – user_id of the signature owner
  • signature (BBcSignature) – signature
Returns:

True if successful

Return type:

bool

digest()[source]

Calculate the digest

The digest corresponds to the transaction_id of this object

Returns:transaction_id (or digest)
Return type:bytes
get_sig_index(user_id)[source]

Reserve a space for signature for the specified user_id

Parameters:user_id (bytes) – user_id whose signature will be added to the signature part
Returns:position (index) in the signature part
Return type:int
pack(for_id=False)[source]

Pack the whole parts

set_sig_index(user_id, idx)[source]

Map a user_id with the index of signature list

Parameters:
  • user_id (bytes) – user_id whose signature will be added to the signature part
  • idx (int) – index number
sign(key_type=2, private_key=None, public_key=None, keypair=None, no_pubkey=False)[source]

Sign the transaction

Parameters:
  • key_type (int) – Type of encryption key’s curve
  • private_key (bytes) –
  • public_key (bytes) –
  • keypair (KeyPair) – keypair or set of private_key and public_key needs to be given
  • no_pubkey (bool) – If True, public key is not contained in the BBcSignature object (needs to be given externally when verification)
Returns:

Return type:

BBcSignature

unpack(data)[source]

Unpack into this object

Parameters:data (bytes) – packed binary data
Returns:True if successful
Return type:bool