Documents classes :¶
Document¶
-
class
ucoinpy.documents.document.
Document
(version, currency, signatures)¶ The class Document handles documents.
-
__init__
(version, currency, signatures)¶ Constructor
Parameters: - version (int) – uCoin protocol version
- currency (str) – the document currency
- signatures –
-
sha_hash
¶ Return the property
-
sign
(keys)¶ Sign the current document. Warning : current signatures will be replaced with the new ones.
-
signed_raw
()¶ If keys are None, returns the raw + current signatures. If keys are present, returns the raw signed by these keys.
-
Block document¶
-
class
ucoinpy.documents.block.
Block
(version, currency, noonce, number, powmin, time, mediantime, ud, issuer, prev_hash, prev_issuer, parameters, members_count, identities, joiners, actives, leavers, excluded, certifications, transactions, signature)¶ - A document describing a Block.
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_SIGNATUREparam int version: ucoin protocol version param str currency: the block currency param int noonce: the noonce value of the block param int number: the number of the block param int powmin: the powmin value of this block param int time: the timestamp of this block param int ud: the dividend amount, or None if no dividend present in this block param str issuer: the pubkey of the issuer of the block param str prev_hash: the previous block hash param str prev_issuer: the previous block issuer param tuple parameters: the parameters of the currency. Should only be present in block 0. param int members_count: the number of members found in this block param list[ucoinpy.documents.SelfCertification] identities: the self certifications declared in this block param list[ucoinpy.documents.Membership] joiners: the joiners memberships via “IN” documents param list[ucoinpy.documents.Membership] actives: renewed memberships via “IN” documents param list[ucoinpy.documents.Membership] leavers: the leavers memberships via “OUT” documents param list[ucoinpy.documents.Membership] excluded: members excluded because of missing certifications param list[ucoinpy.documents.Membership] actives: renewed memberships via “IN” documents param list[ucoinpy.documents.Certification] certifications: certifications documents param list[ucoinpy.documents.Transaction] transactions: transactions documents -
classmethod
from_signed_raw
(raw)¶ Parameters: raw (str) – Returns: Return type:
-
raw
()¶ Get the Block in a raw format,
Returns: The Block as a string document. Return type: str
-
classmethod
Certifications document¶
-
class
ucoinpy.documents.certification.
Certification
(version, currency, pubkey_from, pubkey_to, blocknumber, blockhash, signature)¶ - A document describing a Certification.
..note:: This document is defined by the following format :
UID:IDENTIFIERMETA:TS:TIMESTAMPSIGNATUREMETA:TS:BLOCK_NUMBER-BLOCK_HASHCERTIFIER_SIGNATURE-
__init__
(version, currency, pubkey_from, pubkey_to, blocknumber, blockhash, signature)¶ Constructor
Parameters: - version (int) – ucoin protocol version
- currency (str) – the self certification currency target
- pubkey_from (str) – the pubkey which is certifying
- pubkey_to (str) – the pubkey which is certified
- blocknumber (int) – the block number of the certification
- blockhash (str) – the block hash of the certification
- signature (str) – the signature of the certification
-
classmethod
from_inline
(version, currency, blockhash, inline)¶ - Get a Certification from an inline format.
Note
An inline Certification is specified by the following format :
PUBKEY_FROM:PUBKEY_TO:BLOCK_NUMBER:SIGNATUREparam int version: uCoin protocol version. param str currency: The Certification currency target. param blockhash: The block number of the Certification. param str inline: The inline Certification. return: The inline Certification. rtype: Certification
-
inline
()¶ Get the Certification in an inline format, :return: The Certification as an inline string. :rtype: str
-
raw
(selfcert)¶ Get the Certification in a raw format, :return: The Certification as a string document. :rtype: str
-
sign
(selfcert, keys)¶ Sign the current document. Warning : Current signatures will be replaced with the new ones.
-
signed_raw
(selfcert)¶ If keys are None, returns the raw + current signatures. If keys are present, returns the raw signed by these keys.
Parameters: raw (str) – Returns: Return type:
-
-
class
ucoinpy.documents.certification.
Revocation
(version, currency, signature)¶ - A document describing a self-Revocation.
Note
This document is specified by the following format :
UID:IDENTIFIERMETA:TS:TIMESTAMPSIGNATUREMETA:REVOKECERTIFIER_SIGNATURE-
__init__
(version, currency, signature)¶ Constructor
Parameters: - version (int) – uCoin protocol version.
- currency (str) – The self-Revocation currency target.
- signature (str) – the signature of the self-Revocation.
-
raw
(selfcert)¶ Get the Self-Revocation in a raw format, :return: The self-Revocation as a string document. :rtype: str
-
sign
(selfcert, keys)¶ Sign the current document. Warning : Current signatures will be replaced with the new ones.
-
-
class
ucoinpy.documents.certification.
SelfCertification
(version, currency, pubkey, ts, uid, signature)¶ - A document describing a self-Certification.
Note
This document is specified by the following format :
UID:IDENTIFIERMETA:TS:TIMESTAMPSIGNATURE-
__init__
(version, currency, pubkey, ts, uid, signature)¶ Constructor of a SelfCertification
Parameters: - version (int) – ucoin protocol version
- currency (str) – the self certification currency target
- pubkey (str) – the pubkey which is self-certified
- ts (int) – the timestamp of the self-certification
- uid (str) – the uid which is self-certified
- signature (str) – the signature of the self-certification
-
classmethod
from_inline
(version, currency, inline)¶ - Creates a SelfCertification from an inline format.
Note
An inline self certification is specified by the following format :
PUBLIC_KEY:SIGNATURE:TIMESTAMP:USER_ID
param int version: ucoin protocol version param str currency: the self certification currency target param str inline: the inline self-certification return: the inline SelfCertification rtype: SelfCertification
-
inline
()¶ Get the SelfCertification in an inline format,
Returns: The self-Certification as an inline string. Return type: str
-
raw
()¶ Get the SelfCertification in a raw format,
Returns: The self-Certification as a string document. Return type: str
-
Membership document¶
Created on 2 déc. 2014
@author: inso
-
class
ucoinpy.documents.membership.
Membership
(version, currency, issuer, block_number, block_hash, membership_type, uid, cert_ts, signature)¶ - A document describing a Membership.
Note
A membership document is specified by the following format :
Version: VERSIONType: MembershipCurrency: CURRENCY_NAMEIssuer: ISSUERBlock: NUMBER-HASHMembership: MEMBERSHIP_TYPEUserID: USER_IDCertTS: CERTIFICATION_TS-
__init__
(version, currency, issuer, block_number, block_hash, membership_type, uid, cert_ts, signature)¶ Constructor
Parameters: - version (int) – The uCoin protocol version.
- currency (str) – The Membership currency target.
- issuer – The public key of the issuer.
- block_number –
- block_hash –
- membership_type – Membership message. Value is either IN or OUT to express wether a member wishes to opt-in or opt-out the community.
- uid – Identity to use for this public key.
- cert_ts – Identity’s certification date.
- signature (str) – The signature of the Membership document.
-
classmethod
from_inline
(version, currency, membership_type, inline)¶ Creates a Membership from an inline format.
Parameters: - version (int) – uCoin protocol version.
- currency (str) – The Membership currency target.
- membership_type – Membership message. Value is either IN or OUT to express wether a member wishes to opt-in or opt-out the community.
- inline (str) – The inline Membership.
Returns: The inline Membership.
Return type:
-
classmethod
from_signed_raw
(raw, signature=None)¶ Parameters: raw (str) – Returns: Return type:
-
inline
()¶ Get the Membership in an inline format, :return: The Membership as an inline string. :rtype: str
-
raw
()¶ Get the Membership in a raw format, :return: The Membership as a string document. :rtype: str
-
Peer document¶
-
class
ucoinpy.documents.peer.
BMAEndpoint
(server, ipv4, ipv6, port)¶ - Describing a BMAEndpoint
Note
This document is specified by the following format :
BASIC_MERKLED_API [DNS] [IPv4] [IPv6] [PORT]-
__init__
(server, ipv4, ipv6, port)¶ Constructor
Parameters: - server (str) – The URL of the node.
- ipv4 (str) – The IPV4 address of the node.
- ipv6 (str) – The IPV4 address of the node.
- port (int) – The port of the node.
-
conn_handler
()¶ Handles the connection’s informations.
-
classmethod
from_inline
(inline)¶ Get a BMAEndpoint from an inline format.
Parameters: inline (str) – The inline BMAEndpoint. Returns: The inline BMAEndpoint. Return type: BMAEndpoint
-
inline
()¶ Get the BMAEndpoint in an inline format,
Returns: The BMAEndpoint as an inline string. Return type: str
-
-
class
ucoinpy.documents.peer.
Endpoint
¶ - Describing EndPoints
Note
This document can be specified by this following format :
NAME_OF_THE_API [DNS] [IPv4] [IPv6] [PORT]
-
class
ucoinpy.documents.peer.
Peer
(version, currency, pubkey, blockid, endpoints, signature)¶ - Describing a Peer document.
Note
A peer document is specified by the following format :
Version: VERSIONType: PeerCurrency: CURRENCY_NAMEPublicKey: NODE_PUBLICKEYBlock: BLOCKEndpoints:END_POINT_1END_POINT_2END_POINT_3[...]-
__init__
(version, currency, pubkey, blockid, endpoints, signature)¶ Constructor
Parameters: - version (int) – The uCoin protocol version.
- currency (str) – The currency of the Peer document.
- pubkey (str) – The public key of the node.
- blockid (str) – Block number and hash. Value is used to target a blockchain and precise time reference.
- endpoints (str) – A Mulilines field containing a list of endpoints to interact with the node.
- signature (str) – The signature of the Peer document.
-
classmethod
from_signed_raw
(raw)¶ Parameters: raw (str) – Returns: Return type:
-
raw
()¶ Get the Peer document in a raw format,
Returns: The Peer document as a string document. Return type: str
-
-
class
ucoinpy.documents.peer.
UnknownEndpoint
(api, properties)¶ Describing an UnknownEndpoint
-
__init__
(api, properties)¶ Constructor
Parameters: - api – The API
- properties –
-
classmethod
from_inline
(inline)¶ Creates an UnknownEndpoint from an inline format.
Parameters: inline (str) – The inline UnknownEndpoint. Returns: The inline UnknownEndpoint. Return type: UnknownEndpoint
-
inline
()¶ Get the UnknownEndpoint in an inline format,
Returns: The UnknownEndpoint as an inline string. Return type: str
-
Status document¶
-
class
ucoinpy.documents.status.
Status
(version, currency, status, blockid, sender, recipient, signature)¶ - A document describing a Status.
Note
A Status document is specified by the following format :
Version: VERSIONType: StatusCurrency: CURRENCY_NAMEStatus: STATUSBlock: BLOCKFrom: SENDERTo: RECIPIENT-
__init__
(version, currency, status, blockid, sender, recipient, signature)¶ Constructor
Parameters: - version (int) – The uCoin protocol version.
- currency (str) – The Status currency target.
- status –
- blockid –
- sender –
- recipient –
- signature (str) – The signature of the Status document.
-
classmethod
from_signed_raw
(raw)¶ Parameters: raw (str) – Returns: Return type:
-
raw
()¶ Get the Status in a raw format, :return: The Status as a string document. :rtype: str
-
Transaction document¶
-
class
ucoinpy.documents.transaction.
InputSource
(index, source, number, txhash, amount)¶ - A Transaction INPUT
Note
Compact :
INDEX:SOURCE:FINGERPRINT:AMOUNT-
__init__
(index, source, number, txhash, amount)¶ Constructor
Parameters: - index –
- source –
- number –
- txhash –
- amount –
-
classmethod
from_bma
(bma_data)¶ Get an Input Transaction from the array BMA.
Parameters: bma_data (str) – An array containing the key “type”, the key “number”, the key “fingerprint”, and the key “amount”. Returns: The InputSource. Return type: InputSource
-
classmethod
from_inline
(inline)¶ Get an Input Transaction from an inline format.
Parameters: inline (str) – The inline Input Transaction. Returns: The inline InputSource. Return type: InputSource
-
inline
()¶ Get the Input Transaction in an inline format,
Returns: The InputSource as an inline string. Return type: str
-
-
class
ucoinpy.documents.transaction.
OutputSource
(pubkey, amount)¶ - A Transaction OUTPUT
Note
An Output Transaction is specified by the following format :
PUBLIC_KEY:AMOUNT-
__init__
(pubkey, amount)¶ Constructor
Parameters: - pubkey (str) –
- amount –
-
classmethod
from_inline
(inline)¶ Get an Output Transaction from an inline format.
Parameters: inline (str) – The inline Output Transaction. Returns: The inline OutputSource. Return type: OutputSource
-
inline
()¶ Get the Output Transaction in an inline format, :return: The OutputSource as an inline string. :rtype: str
-
-
class
ucoinpy.documents.transaction.
SimpleTransaction
(version, currency, issuer, single_input, outputs, comment, signature)¶ As Transaction class, but for only 1 issuer. ...
-
__init__
(version, currency, issuer, single_input, outputs, comment, signature)¶ Constructor
Parameters: - version (int) – The uCoin protocol version.
- currency (str) – The SimpleTransaction currency target.
- issuer (str) – A public key, followed by a sequential integer.
- single_input –
- outputs (list[ucoinpy.documents.transaction.Transaction]) – A list of public keys and amounts allowed to them.
- comment (str) – A comment to write on the SimpleTransaction.
- signature (str) – The signature of the SimpleTransaction.
-
-
class
ucoinpy.documents.transaction.
Transaction
(version, currency, issuers, inputs, outputs, comment, signatures)¶ - A document describing a Transaction.
Note
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...-
__init__
(version, currency, issuers, inputs, outputs, comment, signatures)¶ Constructor
Parameters: - version (int) – The uCoin protocol version.
- currency (str) – The Transaction currency target.
- issuers (list[ucoinpy.documents.transaction.Transaction]) – A list of public key, followed by a sequential integer.
- inputs (list[ucoinpy.documents.transaction.Transaction]) – A list linking Issuers (via INDEX) to coin sources.
- outputs (list[ucoinpy.documents.transaction.Transaction]) – A list of public keys and amounts allowed to them.
- comment (str) – A comment to write on the transaction
- signatures –
-
compact
()¶ - Get a Transaction in its compact format.
Note
A Compact Transaction document is specified by the following format :
TX:VERSION:NB_ISSUERS:NB_INPUTS:NB_OUTPUTS:HAS_COMMENTPUBLIC_KEY...INDEX:SOURCE:FINGERPRINT:AMOUNT...PUBLIC_KEY:AMOUNT...COMMENTSIGNATURE...
-
classmethod
from_compact
(currency, compact)¶ - Get a Transaction from a compact format.
Note
A Compact Transaction document is specified by the following format :
TX:VERSION:NB_ISSUERS:NB_INPUTS:NB_OUTPUTS:HAS_COMMENTPUBLIC_KEY...INDEX:SOURCE:FINGERPRINT:AMOUNT...PUBLIC_KEY:AMOUNT...COMMENTSIGNATURE...param str currency: The Transaction currency target. param str compact: The compact Transaction. return: The Transaction. rtype: Transaction
-
classmethod
from_signed_raw
(raw)¶ Parameters: raw (str) – Returns: Return type:
-
raw
()¶ Get the Transaction in a raw format,
Returns: The Transaction as a string document. Return type: str
-