duniterpy.documents.ws2p package

Submodules

duniterpy.documents.ws2p.heads module

class duniterpy.documents.ws2p.heads.API(private: str, public: str)

Bases: object

classmethod from_inline(inline: str)
private: str
public: str
re_inline = re.compile('WS2P(O[CT][SAM])?(I[CT])?')
class duniterpy.documents.ws2p.heads.Head(version: int)

Bases: object

classmethod from_inline(inline: str, signature: str)
re_inline = re.compile('HEAD:?(?:[0-9]+)?')
version: int
class duniterpy.documents.ws2p.heads.HeadV0(version: int, signature: str, api: duniterpy.documents.ws2p.heads.API, head: duniterpy.documents.ws2p.heads.Head, pubkey: str, block_id: duniterpy.documents.block_id.BlockID)

Bases: Head

api: API
block_id: BlockID
check_signature(pubkey: str) bool

Check if Head signature is from head pubkey

Parameters:

pubkey – Pubkey to check signature upon

Returns:

classmethod from_inline(inline: str, signature: str)
head: Head
inline() str
pubkey: str
re_inline = re.compile('^(WS2P(?:O[CT][SAM])?(?:I[CT])?):(HEAD:?(?:[0-9]+)?):((?![OIl])[1-9A-Za-z]{42,45}):([0-9]+-[0-9a-fA-F]{5,64})(?::)?(.*)')
re_signature = re.compile('[A-Za-z0-9+/]+(?:=|==)?')
signature: str
class duniterpy.documents.ws2p.heads.HeadV1(version: int, signature: str, api: duniterpy.documents.ws2p.heads.API, head: duniterpy.documents.ws2p.heads.Head, pubkey: str, block_id: duniterpy.documents.block_id.BlockID, ws2pid: str, software: str, software_version: str, pow_prefix: int)

Bases: HeadV0

classmethod from_inline(inline: str, signature: str)
inline() str
pow_prefix: int
re_inline = re.compile('([0-9a-f]{8}):([A-Za-z-_]+):([0-9]+[.][0-9]+[.][0-9]+[-\\w]*):([0-9]+)(?::)?(.*)')
software: str
software_version: str
ws2pid: str
class duniterpy.documents.ws2p.heads.HeadV2(version: int, signature: str, api: duniterpy.documents.ws2p.heads.API, head: duniterpy.documents.ws2p.heads.Head, pubkey: str, block_id: duniterpy.documents.block_id.BlockID, ws2pid: str, software: str, software_version: str, pow_prefix: int, free_member_room: int, free_mirror_room: int)

Bases: HeadV1

free_member_room: int
free_mirror_room: int
classmethod from_inline(inline: str, signature: str)
inline() str
re_inline = re.compile('([0-9]+):([0-9]+)(?::)?(.*)')

duniterpy.documents.ws2p.messages module

class duniterpy.documents.ws2p.messages.Ack(pubkey: str, challenge: str, signature: str | None = None, currency: str = 'g1')

Bases: HandshakeMessage

auth = 'ACK'
get_signed_json(signing_key: SigningKey) str

Return the signed message in json format

Parameters:

signing_key – Signing key instance

Returns:

class duniterpy.documents.ws2p.messages.Connect(pubkey: str, challenge: str | None = None, signature: str | None = None, currency: str = 'g1')

Bases: HandshakeMessage

auth = 'CONNECT'
class duniterpy.documents.ws2p.messages.DocumentMessage

Bases: object

BLOCK_TYPE_ID = 5
CERTIFICATION_TYPE_ID = 3
DOCUMENT_TYPE_NAMES = {0: 'peer', 1: 'transaction', 2: 'membership', 3: 'certification', 4: 'identity', 5: 'block'}
IDENTITY_TYPE_ID = 4
MEMBERSHIP_TYPE_ID = 2
PEER_TYPE_ID = 0
TRANSACTION_TYPE_ID = 1
get_json(document_type_id: int, document: str) str

Return the document message in json format

Parameters:
  • document_type_id – Id of the document type, use class properties

  • document – Raw or Inline Document to send

class duniterpy.documents.ws2p.messages.HandshakeMessage(pubkey: str, challenge: str | None = None, signature: str | None = None, currency: str = 'g1')

Bases: Document

auth = ''
get_signed_json(signing_key: SigningKey) str

Return the signed message in json format

Parameters:

signing_key – Signing key instance

Returns:

raw()

Return the document in raw format

Returns:

version = 2
class duniterpy.documents.ws2p.messages.Ok(pubkey: str, challenge: str, signature: str | None = None, currency: str = 'g1')

Bases: HandshakeMessage

auth = 'OK'
get_signed_json(signing_key: SigningKey) str

Return the signed message in json format

Parameters:

signing_key – Signing key instance

Returns:

Module contents