Skip to content
Snippets Groups Projects
Commit 00bba5e6 authored by inso's avatar inso
Browse files

Fix publishing of certification and identity

parent e2c42f1a
Branches
Tags
No related merge requests found
...@@ -4,14 +4,15 @@ Created on 1 févr. 2014 ...@@ -4,14 +4,15 @@ Created on 1 févr. 2014
@author: inso @author: inso
""" """
from ucoinpy.documents import Membership, SelfCertification, Certification, Revokation, BlockUID from ucoinpy.documents import Membership, SelfCertification, Certification, Revokation, BlockUID, Block
from ucoinpy.key import SigningKey from ucoinpy.key import SigningKey
from ucoinpy.api import bma
from ucoinpy.api.bma import PROTOCOL_VERSION
import logging import logging
import time
import asyncio import asyncio
from pkg_resources import parse_version from pkg_resources import parse_version
from aiohttp.errors import ClientError
from PyQt5.QtCore import QObject, pyqtSignal from PyQt5.QtCore import QObject, pyqtSignal
from . import money from . import money
...@@ -20,9 +21,6 @@ from .community import Community ...@@ -20,9 +21,6 @@ from .community import Community
from .registry import LocalState from .registry import LocalState
from ..tools.exceptions import ContactAlreadyExists from ..tools.exceptions import ContactAlreadyExists
from .. import __version__ from .. import __version__
from ucoinpy.api import bma
from ucoinpy.api.bma import PROTOCOL_VERSION
from aiohttp.errors import ClientError
class Account(QObject): class Account(QObject):
...@@ -429,19 +427,20 @@ class Account(QObject): ...@@ -429,19 +427,20 @@ class Account(QObject):
:param str password: The account SigningKey password :param str password: The account SigningKey password
:param community: The community target of the self certification :param community: The community target of the self certification
""" """
block_data = await community.bma_access.simple_request(bma.blockchain.Current)
signed_raw = "{0}{1}\n".format(block_data['raw'], block_data['signature'])
block_uid = Block.from_signed_raw(signed_raw).blockUID
selfcert = SelfCertification(PROTOCOL_VERSION, selfcert = SelfCertification(PROTOCOL_VERSION,
community.currency, community.currency,
self.pubkey, self.pubkey,
int(time.time()),
self.name, self.name,
block_uid,
None) None)
key = SigningKey(self.salt, password) key = SigningKey(self.salt, password)
selfcert.sign([key]) selfcert.sign([key])
logging.debug("Key publish : {0}".format(selfcert.signed_raw())) logging.debug("Key publish : {0}".format(selfcert.signed_raw()))
responses = await community.bma_access.broadcast(bma.wot.Add, {}, {'pubkey': self.pubkey, responses = await community.bma_access.broadcast(bma.wot.Add, {}, {'identity': selfcert.signed_raw()})
'self_': selfcert.signed_raw(),
'other': {}})
result = (False, "") result = (False, "")
for r in responses: for r in responses:
if r.status == 200: if r.status == 200:
...@@ -463,7 +462,7 @@ class Account(QObject): ...@@ -463,7 +462,7 @@ class Account(QObject):
""" """
logging.debug("Send membership") logging.debug("Send membership")
blockUID = await community.blockUID() blockUID = community.network.current_blockUID
self_identity = await self._identities_registry.future_find(self.pubkey, community) self_identity = await self._identities_registry.future_find(self.pubkey, community)
selfcert = await self_identity.selfcert(community) selfcert = await self_identity.selfcert(community)
...@@ -494,7 +493,7 @@ class Account(QObject): ...@@ -494,7 +493,7 @@ class Account(QObject):
:param str pubkey: The certified identity pubkey :param str pubkey: The certified identity pubkey
""" """
logging.debug("Certdata") logging.debug("Certdata")
blockUID = await community.blockUID() blockUID = community.network.current_blockUID
identity = await self._identities_registry.future_find(pubkey, community) identity = await self._identities_registry.future_find(pubkey, community)
selfcert = await identity.selfcert(community) selfcert = await identity.selfcert(community)
if selfcert: if selfcert:
...@@ -506,11 +505,9 @@ class Account(QObject): ...@@ -506,11 +505,9 @@ class Account(QObject):
signed_cert = certification.signed_raw(selfcert) signed_cert = certification.signed_raw(selfcert)
logging.debug("Certification : {0}".format(signed_cert)) logging.debug("Certification : {0}".format(signed_cert))
data = {'pubkey': pubkey, data = {'cert': certification.signed_raw(selfcert)}
'self_': selfcert.signed_raw(),
'other': "{0}\n".format(certification.inline())}
logging.debug("Posted data : {0}".format(data)) logging.debug("Posted data : {0}".format(data))
responses = await community.bma_access.broadcast(bma.wot.Add, {}, data) responses = await community.bma_access.broadcast(bma.wot.Certify, {}, data)
result = (False, "") result = (False, "")
for r in responses: for r in responses:
if r.status == 200: if r.status == 200:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment