bbclib.libs.bbclib_utils module¶
Copyright (c) 2018 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.
-
bbclib.libs.bbclib_utils.
add_event_asset
(transaction, event_idx, asset_group_id, user_id, asset_body=None, asset_file=None)[source]¶ Utility to add BBcEvent object with BBcAsset in the transaction
-
bbclib.libs.bbclib_utils.
add_pointer_in_relation
(relation, ref_transaction_id=None, ref_asset_id=None)[source]¶ Utility to add BBcRelation object with BBcPointer in the BBcRelation object
-
bbclib.libs.bbclib_utils.
add_reference_to_transaction
(transaction, asset_group_id, ref_transaction_obj, event_index_in_ref)[source]¶ Utility to add BBcReference object in the transaction
Returns: Return type: BBcReference
-
bbclib.libs.bbclib_utils.
add_relation_asset
(transaction, relation_idx, asset_group_id, user_id, asset_body=None, asset_file=None)[source]¶ Utility to add BBcRelation object with BBcAsset in the transaction
-
bbclib.libs.bbclib_utils.
add_relation_pointer
(transaction, relation_idx, ref_transaction_id=None, ref_asset_id=None)[source]¶ Utility to add BBcRelation object with BBcPointer in the transaction
-
bbclib.libs.bbclib_utils.
convert_id_to_string
(data, bytelen=32)[source]¶ Convert binary data to hex string
-
bbclib.libs.bbclib_utils.
convert_idstring_to_bytes
(datastr, bytelen=32)[source]¶ Convert hex string to binary data
-
bbclib.libs.bbclib_utils.
deep_copy_with_key_stringify
(u, d=None)[source]¶ Utility for updating nested dictionary
-
bbclib.libs.bbclib_utils.
get_new_id
(seed_str=None, include_timestamp=True)[source]¶ Return 256-bit binary data
Parameters: - seed_str (str) – seed string that is hashed by SHA256
- include_timestamp (bool) – if True, timestamp (current time) is appended to the seed string
Returns: 256-bit binary
Return type: bytes
-
bbclib.libs.bbclib_utils.
get_random_id
()[source]¶ Return 256-bit binary data
Returns: 256-bit random binary Return type: bytes
-
bbclib.libs.bbclib_utils.
make_relation_with_asset
(asset_group_id, user_id, asset_body=None, asset_file=None)[source]¶ Utility to make BBcRelation object
-
bbclib.libs.bbclib_utils.
make_transaction
(event_num=0, relation_num=0, witness=False, id_length=32)[source]¶ Utility to make transaction object
Parameters: - event_num (int) – the number of BBcEvent object to include in the transaction
- relation_num (int) – the number of BBcRelation object to include in the transaction
- witness (bool) – If true, BBcWitness object is included in the transaction
- id_length (int) – If <32, IDs will be truncated (this params is for the backward compatibility)
Returns: Return type:
-
bbclib.libs.bbclib_utils.
validate_transaction_object
(txobj, asset_files=None)[source]¶ Validate transaction and its asset
Parameters: - txobj (BBcTransaction) – target transaction object
- asset_files (dict) – dictionary containing the asset file contents
Returns: True if valid tuple: list of valid assets tuple: list of invalid assets
Return type: bool
-
bbclib.libs.bbclib_utils.
verify_using_cross_ref
(domain_id, transaction_id, transaction_base_digest, cross_ref_data, sigdata)[source]¶ Confirm the existence of the transaction using cross_ref
Parameters: - domain_id (bytes) – target domain_id
- transaction_id (bytes) – target transaction_id of which existence you want to confirm
- transaction_base_digest (bytes) – digest obtained from the outer domain
- cross_ref_data (bytes) – packed BBcCrossRef object
- sigdata (bytes) – packed signature
Returns: True if valid
Return type: bool