diff --git a/ucoin.py b/ucoin.py index 85d57afef62d0c83372bbfdc509ede58d9c3d9d8..ca58844c152dd1e39031ae8d8252f21dd5f1af5a 100755 --- a/ucoin.py +++ b/ucoin.py @@ -19,20 +19,20 @@ from parser import Parser from pprint import pprint -import api +import ucoin URL = 'http://mycurrency.candan.fr:8081' AUTH = False def action_peering(): - pprint(api.ucg.Peering().get()) + pprint(ucoin.ucg.Peering().get()) def action_amendments(): - for am in api.hdc.amendments.List().get(): + for am in ucoin.hdc.amendments.List().get(): print(am['number']) def action_transactions(): - for tx in api.hdc.transactions.All().get(): + for tx in ucoin.hdc.transactions.All().get(): print(tx['hash']) if __name__ == '__main__': diff --git a/api/__init__.py b/ucoin/__init__.py similarity index 100% rename from api/__init__.py rename to ucoin/__init__.py diff --git a/api/hdc/__init__.py b/ucoin/hdc/__init__.py similarity index 100% rename from api/hdc/__init__.py rename to ucoin/hdc/__init__.py diff --git a/api/hdc/amendments.py b/ucoin/hdc/amendments.py similarity index 100% rename from api/hdc/amendments.py rename to ucoin/hdc/amendments.py diff --git a/api/hdc/transactions.py b/ucoin/hdc/transactions.py similarity index 100% rename from api/hdc/transactions.py rename to ucoin/hdc/transactions.py diff --git a/api/pks/__init__.py b/ucoin/pks/__init__.py similarity index 100% rename from api/pks/__init__.py rename to ucoin/pks/__init__.py diff --git a/api/ucg/__init__.py b/ucoin/ucg/__init__.py similarity index 65% rename from api/ucg/__init__.py rename to ucoin/ucg/__init__.py index 96c61e41fa1719d7d0cbdb399c58a4c8b780b9b5..b051e8665beb4c5aac6cd75f53f529bba84f8806 100644 --- a/api/ucg/__init__.py +++ b/ucoin/ucg/__init__.py @@ -34,4 +34,28 @@ class Peering(UCG): def get(self): return self.requests_get('/peering').json() +class THT(UCG): + """GET/POST THT entries.""" + + def __init__(self, pgp_fingerprint=None): + """ + Use the pgp fingerprint parameter in order to fit the result. + + Arguments: + - `pgp_fingerprint`: pgp fingerprint to use as a filter + """ + + super().__init__() + + self.pgp_fingerprint = pgp_fingerprint + + def get(self): + if not self.pgp_fingerprint: + return self.merkle_easy_parser('/tht').json() + + return self.merkle_easy_parser('/tht/%s' % self.pgp_fingerprint).json() + + def post(self): + pass + from . import peering diff --git a/api/ucg/peering/__init__.py b/ucoin/ucg/peering/__init__.py similarity index 84% rename from api/ucg/peering/__init__.py rename to ucoin/ucg/peering/__init__.py index 8a34fabb84a8d2e7b5a531164ee158e5e56cfed8..e3fde2227a2afde6c444f59b8ef701291ad5e2b3 100644 --- a/api/ucg/peering/__init__.py +++ b/ucoin/ucg/peering/__init__.py @@ -49,4 +49,16 @@ class Peers(Base): def post(self): pass +class Forward(Base): + """POST a UCG forward document to this node in order to be sent back incoming transactions.""" + + def post(self): + pass + +class Status(Base): + """POST a UCG status document to this node in order notify of its status.""" + + def post(self): + pass + from . import peers diff --git a/api/ucg/peering/peers.py b/ucoin/ucg/peering/peers.py similarity index 100% rename from api/ucg/peering/peers.py rename to ucoin/ucg/peering/peers.py