duniterpy.documents package¶
Subpackages¶
Submodules¶
duniterpy.documents.block module¶
-
class
duniterpy.documents.block.Block(version: int, currency: str, number: int, powmin: int, time: int, mediantime: int, ud: Union[int, NoneType], unit_base: int, issuer: str, issuers_frame: int, issuers_frame_var: int, different_issuers_count: int, prev_hash: Union[str, NoneType], prev_issuer: Union[str, NoneType], parameters: Union[typing.Sequence[str], NoneType], members_count: int, identities: List[duniterpy.documents.identity.Identity], joiners: List[duniterpy.documents.membership.Membership], actives: List[duniterpy.documents.membership.Membership], leavers: List[duniterpy.documents.membership.Membership], revokations: List[duniterpy.documents.revocation.Revocation], excluded: List[str], certifications: List[duniterpy.documents.certification.Certification], transactions: List[duniterpy.documents.transaction.Transaction], inner_hash: str, noonce: int, signature: str)¶ Bases:
duniterpy.documents.document.DocumentThe class Block handles Block documents.
Note
A block document is specified by the following format :
Version: VERSIONType: BlockCurrency: CURRENCYNonce: NONCENumber: BLOCK_NUMBERPoWMin: NUMBER_OF_ZEROSTime: GENERATED_ONMedianTime: MEDIAN_DATEUniversalDividend: DIVIDEND_AMOUNTIssuer: ISSUER_KEYPreviousHash: PREVIOUS_HASHPreviousIssuer: PREVIOUS_ISSUER_KEYParameters: PARAMETERSMembersCount: WOT_MEM_COUNTIdentities:PUBLIC_KEY:SIGNATURE:TIMESTAMP:USER_ID…Joiners:PUBLIC_KEY:SIGNATURE:NUMBER:HASH:TIMESTAMP:USER_ID…Actives:PUBLIC_KEY:SIGNATURE:NUMBER:HASH:TIMESTAMP:USER_ID…Leavers:PUBLIC_KEY:SIGNATURE:NUMBER:HASH:TIMESTAMP:USER_ID…Excluded:PUBLIC_KEY…Certifications:PUBKEY_FROM:PUBKEY_TO:BLOCK_NUMBER:SIGNATURE…Transactions:COMPACT_TRANSACTION…BOTTOM_SIGNATURE-
blockUID¶
-
computed_inner_hash() → str¶
-
fields_parsers= {'Actives': re.compile('Actives:\n'), 'Certifications': re.compile('Certifications:\n'), 'Currency': re.compile('Currency: ([^\n]+)\n'), 'DifferentIssuersCount': re.compile('DifferentIssuersCount: ([0-9]+)\n'), 'Excluded': re.compile('Excluded:\n'), 'Identities': re.compile('Identities:\n'), 'InnerHash': re.compile('InnerHash: ([0-9a-fA-F]{5,64})\n'), 'Issuer': re.compile('Issuer: ((?![OIl])[1-9A-Za-z]{42,45})\n'), 'IssuersFrame': re.compile('IssuersFrame: ([0-9]+)\n'), 'IssuersFrameVar': re.compile('IssuersFrameVar: (0|-?[1-9]\\d{0,18})\n'), 'Joiners': re.compile('Joiners:\n'), 'Leavers': re.compile('Leavers:\n'), 'MedianTime': re.compile('MedianTime: ([0-9]+)\n'), 'MembersCount': re.compile('MembersCount: ([0-9]+)\n'), 'Noonce': re.compile('Nonce: ([0-9]+)\n'), 'Number': re.compile('Number: ([0-9]+)\n'), 'Parameters': re.compile('Parameters: ([0-9]+\\.[0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+\\.[0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+\\.[0-9]+)\n'), 'PoWMin': re.compile('PoWMin: ([0-9]+)\n'), 'PreviousHash': re.compile('PreviousHash: ([0-9a-fA-F]{5,64})\n'), 'PreviousIssuer': re.compile('PreviousIssuer: ((?![OIl])[1-9A-Za-z]{42,45})\n'), 'Revoked': re.compile('Revoked:\n'), 'Signature': re.compile('([A-Za-z0-9+/]+(?:=|==)?)\n'), 'Time': re.compile('Time: ([0-9]+)\n'), 'Transactions': re.compile('Transactions:\n'), 'Type': re.compile('Type: (Block)\n'), 'UD': re.compile('UniversalDividend: ([0-9]+)\n'), 'UnitBase': re.compile('UnitBase: ([0-9]+)\n'), 'Version': re.compile('Version: ([0-9]+)\n')}¶
-
classmethod
from_signed_raw(signed_raw: str) → BlockType¶
-
proof_of_work() → str¶
-
raw() → str¶ Returns the raw document in string format
-
re_actives= re.compile('Actives:\n')¶
-
re_certifications= re.compile('Certifications:\n')¶
-
re_different_issuers_count= re.compile('DifferentIssuersCount: ([0-9]+)\n')¶
-
re_excluded= re.compile('Excluded:\n')¶
-
re_exclusion= re.compile('((?![OIl])[1-9A-Za-z]{42,45})\n')¶
-
re_hash= re.compile('InnerHash: ([0-9a-fA-F]{5,64})\n')¶
-
re_identities= re.compile('Identities:\n')¶
-
re_issuer= re.compile('Issuer: ((?![OIl])[1-9A-Za-z]{42,45})\n')¶
-
re_issuers_frame= re.compile('IssuersFrame: ([0-9]+)\n')¶
-
re_issuers_frame_var= re.compile('IssuersFrameVar: (0|-?[1-9]\\d{0,18})\n')¶
-
re_joiners= re.compile('Joiners:\n')¶
-
re_leavers= re.compile('Leavers:\n')¶
-
re_mediantime= re.compile('MedianTime: ([0-9]+)\n')¶
-
re_memberscount= re.compile('MembersCount: ([0-9]+)\n')¶
-
re_noonce= re.compile('Nonce: ([0-9]+)\n')¶
-
re_number= re.compile('Number: ([0-9]+)\n')¶
-
re_parameters= re.compile('Parameters: ([0-9]+\\.[0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+\\.[0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+\\.[0-9]+)\n')¶
-
re_parameters_v10= re.compile('Parameters: ([0-9]+\\.[0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+\\.[0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+\\.[0-9]+):([0-9]+)¶
-
re_powmin= re.compile('PoWMin: ([0-9]+)\n')¶
-
re_previoushash= re.compile('PreviousHash: ([0-9a-fA-F]{5,64})\n')¶
-
re_previousissuer= re.compile('PreviousIssuer: ((?![OIl])[1-9A-Za-z]{42,45})\n')¶
-
re_revoked= re.compile('Revoked:\n')¶
-
re_time= re.compile('Time: ([0-9]+)\n')¶
-
re_transactions= re.compile('Transactions:\n')¶
-
re_type= re.compile('Type: (Block)\n')¶
-
re_unitbase= re.compile('UnitBase: ([0-9]+)\n')¶
-
re_universaldividend= re.compile('UniversalDividend: ([0-9]+)\n')¶
-
sign(keys)¶ Sign the current document. Warning : current signatures will be replaced with the new ones.
-
duniterpy.documents.block_uid module¶
-
class
duniterpy.documents.block_uid.BlockUID(number: int, sha_hash: str)¶ Bases:
objectA simple block id
-
classmethod
empty() → BlockUIDType¶
-
classmethod
from_str(blockid: str) → BlockUIDType¶ Parameters: blockid – The block id
-
re_block_uid= re.compile('([0-9]+)-([0-9a-fA-F]{5,64})')¶
-
re_hash= re.compile('([0-9a-fA-F]{5,64})')¶
-
classmethod
-
duniterpy.documents.block_uid.block_uid(value: Union[str, duniterpy.documents.block_uid.BlockUID, NoneType]) → duniterpy.documents.block_uid.BlockUID¶ Convert value to BlockUID instance
Parameters: value – Value to convert Returns:
duniterpy.documents.certification module¶
-
class
duniterpy.documents.certification.Certification(version: int, currency: str, pubkey_from: str, identity: Union[duniterpy.documents.identity.Identity, str], timestamp: duniterpy.documents.block_uid.BlockUID, signature: str)¶ Bases:
duniterpy.documents.document.DocumentA document describing a certification.
-
fields_parsers= {'CertTimestamp': re.compile('CertTimestamp: ([0-9]+-[0-9a-fA-F]{5,64})\n'), 'Currency': re.compile('Currency: ([^\n]+)\n'), 'IdtyIssuer': re.compile('IdtyIssuer: ((?![OIl])[1-9A-Za-z]{42,45})\n'), 'IdtySignature': re.compile('IdtySignature: ([A-Za-z0-9+/]+(?:=|==)?)\n'), 'IdtyTimestamp': re.compile('IdtyTimestamp: ([0-9]+-[0-9a-fA-F]{5,64})\n'), 'IdtyUniqueID': re.compile('IdtyUniqueID: ([A-Za-z0-9_-]{2,100})\n'), 'Issuer': re.compile('Issuer: ((?![OIl])[1-9A-Za-z]{42,45})\n'), 'Signature': re.compile('([A-Za-z0-9+/]+(?:=|==)?)\n'), 'Type': re.compile('Type: (Certification)'), 'Version': re.compile('Version: ([0-9]+)\n')}¶
-
classmethod
from_inline(version: int, currency: str, blockhash: Union[str, NoneType], inline: str) → CertificationType¶ Return Certification instance from inline document
Only self.pubkey_to is populated. You must populate self.identity with an Identity instance to use raw/sign/signed_raw methods
Parameters: - version – Version of document
- currency – Name of the currency
- blockhash – Hash of the block
- inline – Inline document
Returns:
-
classmethod
from_signed_raw(signed_raw: str) → CertificationType¶ Return Certification instance from signed raw document
Parameters: signed_raw – Signed raw document Returns:
-
inline() → str¶ Return inline document string
Returns:
-
raw() → str¶ Return a raw document of the certification
-
re_cert_timestamp= re.compile('CertTimestamp: ([0-9]+-[0-9a-fA-F]{5,64})\n')¶
-
re_idty_issuer= re.compile('IdtyIssuer: ((?![OIl])[1-9A-Za-z]{42,45})\n')¶
-
re_idty_signature= re.compile('IdtySignature: ([A-Za-z0-9+/]+(?:=|==)?)\n')¶
-
re_idty_timestamp= re.compile('IdtyTimestamp: ([0-9]+-[0-9a-fA-F]{5,64})\n')¶
-
re_idty_unique_id= re.compile('IdtyUniqueID: ([A-Za-z0-9_-]{2,100})\n')¶
-
re_inline= re.compile('((?![OIl])[1-9A-Za-z]{42,45}):((?![OIl])[1-9A-Za-z]{42,45}):([0-9]+):([A-Za-z0-9+/]+(?:=|==)?)\n')¶
-
re_issuer= re.compile('Issuer: ((?![OIl])[1-9A-Za-z]{42,45})\n')¶
-
re_timestamp= re.compile('META:TS:([0-9]+-[0-9a-fA-F]{5,64})\n')¶
-
re_type= re.compile('Type: (Certification)')¶
-
sign(keys: list) → None¶ Sign the current document with the keys for the certified Identity given
Warning : current signatures will be replaced with the new ones.
Parameters: keys – List of libnacl key instances
-
signed_raw() → str¶ Return signed raw document of the certification for the certified Identity instance
Returns:
-
duniterpy.documents.crc_pubkey module¶
-
class
duniterpy.documents.crc_pubkey.CRCPubkey(pubkey: str, crc: str)¶ Bases:
objectClass to implement a crc on a pubkey
-
classmethod
from_pubkey(pubkey: str) → CRCPubkeyType¶ Return CRCPubkey instance from public key string
Parameters: pubkey – Public key Returns:
-
classmethod
from_str(crc_pubkey: str) → CRCPubkeyType¶ Return CRCPubkey instance from CRC public key string
Parameters: crc_pubkey – CRC public key Returns:
-
is_valid() → bool¶ Return True if CRC is valid :return:
-
re_crc_pubkey= re.compile('((?![OIl])[1-9A-Za-z]{42,45}):([A-Za-z0-9]{3})')¶
-
classmethod
duniterpy.documents.document module¶
-
class
duniterpy.documents.document.Document(version: int, currency: str, signatures: List[str])¶ Bases:
object-
fields_parsers= {'Currency': re.compile('Currency: ([^\n]+)\n'), 'Signature': re.compile('([A-Za-z0-9+/]+(?:=|==)?)\n'), 'Version': re.compile('Version: ([0-9]+)\n')}¶
-
classmethod
parse_field(field_name: str, line: str) → Any¶ Parse a document field with regular expression and return the value
Parameters: - field_name – Name of the field
- line – Line string to parse
Returns:
-
raw() → str¶ Returns the raw document in string format
-
re_currency= re.compile('Currency: ([^\n]+)\n')¶
-
re_signature= re.compile('([A-Za-z0-9+/]+(?:=|==)?)\n')¶
-
re_version= re.compile('Version: ([0-9]+)\n')¶
-
sha_hash¶ Return uppercase hex sha256 hash from signed raw document
Returns:
-
sign(keys: list) → None¶ Sign the current document.
Warning : current signatures will be replaced with the new ones.
Parameters: keys – List of libnacl keys instance
-
signed_raw() → str¶ If keys are None, returns the raw + current signatures If keys are present, returns the raw signed by these keys :return:
-
-
exception
duniterpy.documents.document.MalformedDocumentError(field_name: str)¶ Bases:
ExceptionMalformed document exception
duniterpy.documents.identity module¶
-
class
duniterpy.documents.identity.Identity(version: int, currency: str, pubkey: str, uid: str, ts: duniterpy.documents.block_uid.BlockUID, signature: Union[str, NoneType])¶ Bases:
duniterpy.documents.document.DocumentA document describing a self certification.
-
fields_parsers= {'Currency': re.compile('Currency: ([^\n]+)\n'), 'Issuer': re.compile('Issuer: ((?![OIl])[1-9A-Za-z]{42,45})\n'), 'Signature': re.compile('([A-Za-z0-9+/]+(?:=|==)?)\n'), 'Timestamp': re.compile('Timestamp: ([0-9]+-[0-9a-fA-F]{5,64})\n'), 'Type': re.compile('Type: (Identity)'), 'UniqueID': re.compile('UniqueID: ([A-Za-z0-9_-]{2,100})\n'), 'Version': re.compile('Version: ([0-9]+)\n')}¶
-
classmethod
from_inline(version: int, currency: str, inline: str) → IdentityType¶ Return Identity instance from inline Identity string :param version: Document version number :param currency: Name of the currency :param inline: Inline string of the Identity :return:
-
classmethod
from_signed_raw(signed_raw: str) → IdentityType¶ Return Identity instance from a signed_raw string :param signed_raw: Signed raw document :return:
-
inline() → str¶ Return an inline string of the Identity :return:
-
raw() → str¶ Return a raw document of the Identity :return:
-
re_inline= re.compile('((?![OIl])[1-9A-Za-z]{42,45}):([A-Za-z0-9+/]+(?:=|==)?):([0-9]+-[0-9a-fA-F]{5,64}):([^\n]+)\n')¶
-
re_issuer= re.compile('Issuer: ((?![OIl])[1-9A-Za-z]{42,45})\n')¶
-
re_meta_ts= re.compile('META:TS:([0-9]+-[0-9a-fA-F]{5,64})\n')¶
-
re_timestamp= re.compile('Timestamp: ([0-9]+-[0-9a-fA-F]{5,64})\n')¶
-
re_type= re.compile('Type: (Identity)')¶
-
re_uid= re.compile('UID:([^\n]+)\n')¶
-
re_unique_id= re.compile('UniqueID: ([A-Za-z0-9_-]{2,100})\n')¶
-
duniterpy.documents.membership module¶
Created on 2 déc. 2014
@author: inso
-
class
duniterpy.documents.membership.Membership(version: int, currency: str, issuer: str, membership_ts: duniterpy.documents.block_uid.BlockUID, membership_type: str, uid: str, identity_ts: duniterpy.documents.block_uid.BlockUID, signature: str)¶ Bases:
duniterpy.documents.document.DocumentNote
A membership document is specified by the following format :
Version: VERSIONType: MembershipCurrency: CURRENCY_NAMEIssuer: ISSUERBlock: NUMBER-HASHMembership: MEMBERSHIP_TYPEUserID: USER_IDCertTS: CERTIFICATION_TS-
fields_parsers= {'Block': re.compile('Block: ([0-9]+-[0-9a-fA-F]{5,64})\n'), 'CertTS': re.compile('CertTS: ([0-9]+-[0-9a-fA-F]{5,64})\n'), 'Currency': re.compile('Currency: ([^\n]+)\n'), 'Issuer': re.compile('Issuer: ((?![OIl])[1-9A-Za-z]{42,45})\n'), 'Membership': re.compile('Membership: (IN|OUT)'), 'Signature': re.compile('([A-Za-z0-9+/]+(?:=|==)?)\n'), 'Type': re.compile('Type: (Membership)'), 'UserID': re.compile('UserID: ([^\n]+)\n'), 'Version': re.compile('Version: ([0-9]+)\n')}¶
-
classmethod
from_inline(version: int, currency: str, membership_type: str, inline: str) → MembershipType¶ Return Membership instance from inline format
Parameters: - version – Version of the document
- currency – Name of the currency
- membership_type – “IN” or “OUT” to enter or exit membership
- inline – Inline string format
Returns:
-
classmethod
from_signed_raw(signed_raw: str) → MembershipType¶ Return Membership instance from signed raw format
Parameters: signed_raw – Signed raw format string Returns:
-
inline() → str¶ Return inline string format of the Membership instance :return:
-
raw() → str¶ Return signed raw format string of the Membership instance
Returns:
-
re_block= re.compile('Block: ([0-9]+-[0-9a-fA-F]{5,64})\n')¶
-
re_certts= re.compile('CertTS: ([0-9]+-[0-9a-fA-F]{5,64})\n')¶
-
re_inline= re.compile('((?![OIl])[1-9A-Za-z]{42,45}):([A-Za-z0-9+/]+(?:=|==)?):([0-9]+-[0-9a-fA-F]{5,64}):([0-9]+-[0-9a-fA-F]{5,64}):([^\n]+)\n')¶
-
re_issuer= re.compile('Issuer: ((?![OIl])[1-9A-Za-z]{42,45})\n')¶
-
re_membership_type= re.compile('Membership: (IN|OUT)')¶
-
re_type= re.compile('Type: (Membership)')¶
-
re_userid= re.compile('UserID: ([^\n]+)\n')¶
-
duniterpy.documents.peer module¶
-
class
duniterpy.documents.peer.Peer(version: int, currency: str, pubkey: str, block_uid: duniterpy.documents.block_uid.BlockUID, endpoints: List[duniterpy.api.endpoint.Endpoint], signature: str)¶ Bases:
duniterpy.documents.document.DocumentNote
A peer document is specified by the following format :
Version: VERSIONType: PeerCurrency: CURRENCY_NAMEPublicKey: NODE_PUBLICKEYBlock: BLOCKEndpoints:END_POINT_1END_POINT_2END_POINT_3[…]-
fields_parsers= {'Block': re.compile('Block: ([0-9]+-[0-9a-fA-F]{5,64})\n'), 'Currency': re.compile('Currency: ([^\n]+)\n'), 'Endpoints': re.compile('(Endpoints:)\n'), 'Pubkey': re.compile('PublicKey: ((?![OIl])[1-9A-Za-z]{42,45})\n'), 'Signature': re.compile('([A-Za-z0-9+/]+(?:=|==)?)\n'), 'Type': re.compile('Type: (Peer)'), 'Version': re.compile('Version: ([0-9]+)\n')}¶
-
classmethod
from_signed_raw(raw: str) → PeerType¶ Return a Peer instance from a signed raw format string
Parameters: raw – Signed raw format string Returns:
-
raw() → str¶ Return a raw format string of the Peer document
Returns:
-
re_block= re.compile('Block: ([0-9]+-[0-9a-fA-F]{5,64})\n')¶
-
re_endpoints= re.compile('(Endpoints:)\n')¶
-
re_pubkey= re.compile('PublicKey: ((?![OIl])[1-9A-Za-z]{42,45})\n')¶
-
re_type= re.compile('Type: (Peer)')¶
-
duniterpy.documents.revocation module¶
-
class
duniterpy.documents.revocation.Revocation(version: int, currency: str, identity: Union[duniterpy.documents.identity.Identity, str], signature: str)¶ Bases:
duniterpy.documents.document.DocumentA document describing a self-revocation.
-
static
extract_self_cert(signed_raw: str) → duniterpy.documents.identity.Identity¶ Return self-certified Identity instance from the signed raw Revocation document
Parameters: signed_raw – Signed raw document string Returns:
-
fields_parsers= {'Currency': re.compile('Currency: ([^\n]+)\n'), 'IdtySignature': re.compile('IdtySignature: ([A-Za-z0-9+/]+(?:=|==)?)\n'), 'IdtyTimestamp': re.compile('IdtyTimestamp: ([0-9]+-[0-9a-fA-F]{5,64})\n'), 'IdtyUniqueID': re.compile('IdtyUniqueID: ([^\n]+)\n'), 'Issuer': re.compile('Issuer: ((?![OIl])[1-9A-Za-z]{42,45})\n'), 'Signature': re.compile('([A-Za-z0-9+/]+(?:=|==)?)\n'), 'Type': re.compile('Type: (Revocation)'), 'Version': re.compile('Version: ([0-9]+)\n')}¶
-
classmethod
from_inline(version: int, currency: str, inline: str) → RevocationType¶ Return Revocation document instance from inline string
Only self.pubkey is populated. You must populate self.identity with an Identity instance to use raw/sign/signed_raw methods
Parameters: - version – Version number
- currency – Name of the currency
- inline – Inline document
Returns:
-
classmethod
from_signed_raw(signed_raw: str) → RevocationType¶ Return Revocation document instance from a signed raw string
Parameters: signed_raw – raw document file in duniter format Returns:
-
inline() → str¶ Return inline document string
Returns:
-
raw() → str¶ Return Revocation raw document string
Returns:
-
re_idtysignature= re.compile('IdtySignature: ([A-Za-z0-9+/]+(?:=|==)?)\n')¶
-
re_inline= re.compile('((?![OIl])[1-9A-Za-z]{42,45}):([A-Za-z0-9+/]+(?:=|==)?)\n')¶
-
re_issuer= re.compile('Issuer: ((?![OIl])[1-9A-Za-z]{42,45})\n')¶
-
re_timestamp= re.compile('IdtyTimestamp: ([0-9]+-[0-9a-fA-F]{5,64})\n')¶
-
re_type= re.compile('Type: (Revocation)')¶
-
re_uniqueid= re.compile('IdtyUniqueID: ([^\n]+)\n')¶
-
sign(keys: list) → None¶ Sign the current document. Warning : current signatures will be replaced with the new ones.
Parameters: keys – List of libnacl key instances Returns:
-
signed_raw() → str¶ Return Revocation signed raw document string
Returns:
-
static
duniterpy.documents.transaction module¶
-
class
duniterpy.documents.transaction.InputSource(amount: int, base: int, source: str, origin_id: str, index: int)¶ Bases:
objectA Transaction INPUTNote
Compact : INDEX:SOURCE:FINGERPRINT:AMOUNT
-
classmethod
from_inline(tx_version: int, inline: str) → InputSourceType¶ Return Transaction instance from inline string format
Parameters: - tx_version – Version number of the document
- inline – Inline string format
Returns:
-
inline(tx_version: int) → str¶ Return an inline string format of the document
Parameters: tx_version – Version number of the document Returns:
-
re_inline= re.compile('(?:(?:(D):((?![OIl])[1-9A-Za-z]{42,45}):([0-9]+))|(?:(T):([0-9a-fA-F]{5,64}):([0-9]+)))\n')¶
-
re_inline_v3= re.compile('([0-9]+):([0-9]+):(?:(?:(D):((?![OIl])[1-9A-Za-z]{42,45}):([0-9]+))|(?:(T):([0-9a-fA-F]{5,64}):([0-9]+)))\n')¶
-
classmethod
-
class
duniterpy.documents.transaction.OutputSource(amount: int, base: int, condition: str)¶ Bases:
objectA Transaction OUTPUT
-
static
condition_from_text(text) → duniterpy.grammars.output.Condition¶ Return a Condition instance with PEG grammar from text
Parameters: text – PEG parsable string Returns:
-
classmethod
from_inline(inline: str) → OutputSourceType¶ Return OutputSource instance from inline string format
Parameters: inline – Inline string format Returns:
-
inline() → str¶ Return an inline string format of the document
Returns:
-
re_inline= re.compile('([0-9]+):([0-9]+):(.*)\n')¶
-
static
-
class
duniterpy.documents.transaction.SIGParameter(index: int)¶ Bases:
objectA Transaction UNLOCK SIG parameter
-
classmethod
from_parameter(parameter: str) → Union[~SIGParameterType, NoneType]¶ Return a SIGParameter instance from an index parameter
Parameters: parameter – Index parameter Returns:
-
re_sig= re.compile('SIG\\(([0-9]+)\\)')¶
-
classmethod
-
class
duniterpy.documents.transaction.SimpleTransaction(version: int, currency: str, blockstamp: duniterpy.documents.block_uid.BlockUID, locktime: int, issuer: str, single_input: duniterpy.documents.transaction.InputSource, unlocks: List[duniterpy.documents.transaction.Unlock], outputs: List[duniterpy.documents.transaction.OutputSource], comment: str, signature: str)¶ Bases:
duniterpy.documents.transaction.TransactionAs transaction class, but for only one issuer. …
-
static
is_simple(tx: duniterpy.documents.transaction.Transaction) → bool¶ Filter a transaction and checks if it is a basic one A simple transaction is a tx which has only one issuer and two outputs maximum. The unlocks must be done with simple “SIG” functions, and the outputs must be simple SIG conditions.
Parameters: tx – the transaction to check Returns: True if a simple transaction
-
static
-
class
duniterpy.documents.transaction.Transaction(version: int, currency: str, blockstamp: Union[duniterpy.documents.block_uid.BlockUID, NoneType], locktime: int, issuers: List[str], inputs: List[duniterpy.documents.transaction.InputSource], unlocks: List[duniterpy.documents.transaction.Unlock], outputs: List[duniterpy.documents.transaction.OutputSource], comment: str, signatures: List[str])¶ Bases:
duniterpy.documents.document.DocumentNote
A transaction document is specified by the following format :
Document format :Version: VERSIONType: TransactionCurrency: CURRENCY_NAMEIssuers:PUBLIC_KEY…Inputs:INDEX:SOURCE:NUMBER:FINGERPRINT:AMOUNT…Outputs:PUBLIC_KEY:AMOUNT…Comment: COMMENT…Compact format :TX:VERSION:NB_ISSUERS:NB_INPUTS:NB_OUTPUTS:HAS_COMMENTPUBLIC_KEY:INDEX…INDEX:SOURCE:FINGERPRINT:AMOUNT…PUBLIC_KEY:AMOUNT…COMMENTSIGNATURE…-
compact() → str¶ Return a transaction in its compact format from the instance
Returns:
-
fields_parsers= {'Blockstamp': re.compile('Blockstamp: ([0-9]+-[0-9a-fA-F]{5,64})\n'), 'Comment': re.compile('Comment: ([^\n]*)\n'), 'Compact comment': re.compile('([^\n]+)\n'), 'CompactBlockstamp': re.compile('([0-9]+-[0-9a-fA-F]{5,64})\n'), 'Currency': re.compile('Currency: ([^\n]+)\n'), 'Inputs': re.compile('Inputs:\n'), 'Issuers': re.compile('Issuers:\n'), 'Locktime': re.compile('Locktime: ([0-9]+)\n'), 'Outputs': re.compile('Outputs:\n'), 'Pubkey': re.compile('((?![OIl])[1-9A-Za-z]{42,45})\n'), 'Signature': re.compile('([A-Za-z0-9+/]+(?:=|==)?)\n'), 'TX': re.compile('TX:([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([01]):([0-9]+)\n'), 'Type': re.compile('Type: (Transaction)\n'), 'Unlocks': re.compile('Unlocks:\n'), 'Version': re.compile('Version: ([0-9]+)\n')}¶
-
classmethod
from_bma_history(currency: str, tx_data: Dict) → TransactionType¶ Get the transaction instance from json
Parameters: - currency – the currency of the tx
- tx_data – json data of the transaction
Returns:
-
classmethod
from_compact(currency: str, compact: str) → TransactionType¶ Return Transaction instance from compact string format
Parameters: - currency – Name of the currency
- compact – Compact format string
Returns:
-
classmethod
from_signed_raw(raw: str) → TransactionType¶ Return a Transaction instance from a raw string format
Parameters: raw – Raw string format Returns:
-
raw() → str¶ Return raw string format from the instance
Returns:
-
re_blockstamp= re.compile('Blockstamp: ([0-9]+-[0-9a-fA-F]{5,64})\n')¶
-
re_comment= re.compile('Comment: ([^\n]*)\n')¶
-
re_compact_blockstamp= re.compile('([0-9]+-[0-9a-fA-F]{5,64})\n')¶
-
re_compact_comment= re.compile('([^\n]+)\n')¶
-
re_header= re.compile('TX:([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([01]):([0-9]+)\n')¶
-
re_inputs= re.compile('Inputs:\n')¶
-
re_issuers= re.compile('Issuers:\n')¶
-
re_locktime= re.compile('Locktime: ([0-9]+)\n')¶
-
re_outputs= re.compile('Outputs:\n')¶
-
re_pubkey= re.compile('((?![OIl])[1-9A-Za-z]{42,45})\n')¶
-
re_type= re.compile('Type: (Transaction)\n')¶
-
re_unlocks= re.compile('Unlocks:\n')¶
-
-
class
duniterpy.documents.transaction.Unlock(index: int, parameters: List[Union[duniterpy.documents.transaction.SIGParameter, duniterpy.documents.transaction.XHXParameter]])¶ Bases:
objectA Transaction UNLOCK
-
classmethod
from_inline(inline: str) → UnlockType¶ Return an Unlock instance from inline string format
Parameters: inline – Inline string format Returns:
-
inline() → str¶ Return inline string format of the instance
Returns:
-
re_inline= re.compile('([0-9]+):((?:SIG\\([0-9]+\\)|XHX\\([0-9]+\\)|\\s)+)\n')¶
-
classmethod
-
class
duniterpy.documents.transaction.UnlockParameter¶ Bases:
object-
compute()¶
-
classmethod
from_parameter(parameter: str) → Union[duniterpy.documents.transaction.SIGParameter, duniterpy.documents.transaction.XHXParameter, NoneType]¶ Return UnlockParameter instance from parameter string
Parameters: parameter – Parameter string Returns:
-
-
class
duniterpy.documents.transaction.XHXParameter(integer: int)¶ Bases:
objectA Transaction UNLOCK XHX parameter
-
compute()¶
-
classmethod
from_parameter(parameter: str) → Union[~XHXParameterType, NoneType]¶ Return a XHXParameter instance from an index parameter
Parameters: parameter – Index parameter Returns:
-
re_xhx= re.compile('XHX\\(([0-9]+)\\)')¶
-
-
duniterpy.documents.transaction.reduce_base(amount: int, base: int) → tuple¶ Compute the reduced base of the given parameters
Parameters: - amount – the amount value
- base – current base value
Returns: tuple containing computed (amount, base)