From 19542ef7512cc10b3e5a508bb457b0507bb7f88f Mon Sep 17 00:00:00 2001
From: Inso <insomniak.fr@gmail.com>
Date: Thu, 25 Dec 2014 19:41:44 +0100
Subject: [PATCH] Same parameters as ucoin-cli, but still cannot sign...

---
 lib/ucoinpy/api/bma/__init__.py        |  3 +++
 lib/ucoinpy/api/bma/wot/__init__.py    |  2 +-
 lib/ucoinpy/documents/certification.py |  2 +-
 src/cutecoin/core/account.py           | 14 ++++++++------
 src/cutecoin/core/community.py         |  1 -
 5 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/lib/ucoinpy/api/bma/__init__.py b/lib/ucoinpy/api/bma/__init__.py
index fbd95eaa..57e861a7 100644
--- a/lib/ucoinpy/api/bma/__init__.py
+++ b/lib/ucoinpy/api/bma/__init__.py
@@ -123,7 +123,10 @@ class API(object):
         Arguments:
         - `path`: the request path
         """
+        if 'self_' in kwargs.keys():
+            kwargs['self'] = kwargs.pop('self_')
 
+        logging.debug("POST : {0}".format(kwargs))
         response = requests.post(self.reverse_url(path), data=kwargs, headers=self.headers)
 
         if response.status_code != 200:
diff --git a/lib/ucoinpy/api/bma/wot/__init__.py b/lib/ucoinpy/api/bma/wot/__init__.py
index 3e1c694a..0de3bfc8 100644
--- a/lib/ucoinpy/api/bma/wot/__init__.py
+++ b/lib/ucoinpy/api/bma/wot/__init__.py
@@ -31,7 +31,7 @@ class Add(WOT):
 
     def __post__(self, **kwargs):
         assert 'pubkey' in kwargs
-        assert 'self' in kwargs
+        assert 'self_' in kwargs
         assert 'other' in kwargs
 
         return self.requests_post('/add', **kwargs).json()
diff --git a/lib/ucoinpy/documents/certification.py b/lib/ucoinpy/documents/certification.py
index 10a9cb5e..03898313 100644
--- a/lib/ucoinpy/documents/certification.py
+++ b/lib/ucoinpy/documents/certification.py
@@ -79,7 +79,7 @@ class Certification(Document):
 
     def raw(self, selfcert):
         return """{0}META:TS:{1}-{2}
-""".format(selfcert.signed_raw(), self.blockhash, self.blocknumber)
+""".format(selfcert.signed_raw(), self.blocknumber, self.blockhash)
 
     def signed_raw(self, selfcert):
         raw = self.raw(selfcert)
diff --git a/src/cutecoin/core/account.py b/src/cutecoin/core/account.py
index f36419a7..45c675ac 100644
--- a/src/cutecoin/core/account.py
+++ b/src/cutecoin/core/account.py
@@ -117,7 +117,7 @@ class Account(object):
 
         certification = Certification(PROTOCOL_VERSION, community.currency,
                                       self.pubkey, certified.pubkey,
-                                      block.number, block_hash, None)
+                                      block_hash, block.number, None)
 
         selfcert = certified.selfcert(community)
         raw_cert = certification.raw(selfcert)
@@ -125,15 +125,17 @@ class Account(object):
 
         key = SigningKey(self.salt, password)
         signing = base64.b64encode(key.signature(bytes(raw_cert, 'ascii')))
-        logging.debug("Signature : {0}".format(signing.decode("ascii")))
+        logging.debug("Raw certification {0}".format(raw_cert))
+        logging.debug("Signature of {0}".format(signing.decode("ascii")))
         certification.signatures = [signing.decode("ascii")]
         signed_cert = certification.signed_raw(selfcert)
         logging.debug("Certification : {0}".format(signed_cert))
 
-        community.post(bma.wot.Add, {},
-                       {'pubkey': certified.pubkey,
-                        'self': selfcert.signed_raw(),
-                        'others': certification.inline() + "\n"})
+        data = {'pubkey': certified.pubkey,
+                        'self_': selfcert.signed_raw(),
+                        'other': "{0}\n".format(certification.inline())}
+        logging.debug("Posted data : {0}".format(data))
+        community.post(bma.wot.Add, {}, data)
 
     def sources(self, community):
         sources = []
diff --git a/src/cutecoin/core/community.py b/src/cutecoin/core/community.py
index c060f1ad..5138b405 100644
--- a/src/cutecoin/core/community.py
+++ b/src/cutecoin/core/community.py
@@ -145,7 +145,6 @@ class Community(object):
             e = next(e for e in peer.endpoints if type(e) is BMAEndpoint)
             logging.debug("Trying to connect to : " + peer.pubkey)
             req = request(e.conn_handler(), **req_args)
-            logging.debug("{0}".format(post_args))
             req.post(**post_args)
 
     def jsonify_peers_list(self):
-- 
GitLab