diff --git a/ucoinpy/documents/__init__.py b/ucoinpy/documents/__init__.py
index d0057d916ed98558dc74d2c1678b35ffb32895f0..0fe4cc12ddd034b516ba535eee18d8414a236cae 100644
--- a/ucoinpy/documents/__init__.py
+++ b/ucoinpy/documents/__init__.py
@@ -9,11 +9,8 @@ from ..key import Base58Encoder
class Document:
- def __init__(self, timestamp):
- self.timestamp = timestamp
-
- def ts(self):
- return "META:TS:{0}".format(self.timestamp)
+ def __init__(self, version):
+ self.version = version
def content(self):
return ""
diff --git a/ucoinpy/documents/block.py b/ucoinpy/documents/block.py
index 33d1e043f6a247aeab74a169d7921fc88aceddb1..c3fc78a82a51d300d7721f588d50034d7825c31f 100644
--- a/ucoinpy/documents/block.py
+++ b/ucoinpy/documents/block.py
@@ -75,7 +75,67 @@ BOTTOM_SIGNATURE
self.excluded = excluded
self.certifications = certifications
self.transactions = transactions
-
+
+ @classmethod
+ def from_raw(cls, raw):
+ #TODO : Parsing
+ lines = raw.splitlines(True)
+
+ n = 0
+ version_re = re.compile("Version: ([0-9]+)\n")
+ version = version_re.match(lines[n])
+ n = 1
+ currency_re = re.compile("Currency: ([0-9a-zA-Z_\-]+)\n"
+ currency = currency_re.match(lines[n])
+
+ n = 2
+ noonce_re = re.compile("Nonce: ([0-9]+)\n")
+ noonce = nonce_re.match(lines[n])
+
+ n = 3
+ number_re = re.compile("Number: ([0-9]+)\n")
+ number = number_re.match(lines[n])
+
+ n = 4
+ powmin_re = re.compile("PoWMin: ([0-9]+)\n")
+ powmin = powmin.match(lines[n])
+
+ n = 5
+ time_re = re.compile("Time: ([0-9]+)\n")
+ time = time.match(lines[n])
+
+ n = 6
+ mediantime_re = re.compile("MedianTime: ([0-9]+)\n")
+ mediantime = mediantime_re.match(line[n])
+
+ n = 7
+ ud_re = re.compile("UniversalDividend: ([0-9]+)\n")
+ ud = ud_re.match(line[n])
+
+ n = 8
+ issuer_re = re.compile("Issuer: ([1-9A-Za-z][^OIl]{43,45})\n")
+ issuer = issuer_re.match(line[n])
+
+ n = 9
+ previoushash_re = re.compile("PreviousHash: ([0-9a-fA-F]{5,40})\n")
+ prev_hash = previoushash_re.match(line[n])
+
+ n = 10
+ previousissuer_re = re.compile("PreviousIssuer: ([1-9A-Za-z][^OIl]{43,45})\n")
+ prev_issuer = previousissuer_re.match(line[n])
+
+ parameters = ""
+ members_count = ""
+ identities = ""
+ joiners = ""
+ actives = ""
+ leavers = ""
+ excluded = ""
+ certifications = ""
+ transactions = ""
+
+ return cls([])
+
def content(self):
doc = """
Version: {0}
diff --git a/ucoinpy/documents/certification.py b/ucoinpy/documents/certification.py
index ef0a82c80e8b2a8f1958b2d37bac27d5a4755117..fc8d9461afa2d5cc5c2de17745358c5f7efc4ada 100644
--- a/ucoinpy/documents/certification.py
+++ b/ucoinpy/documents/certification.py
@@ -13,12 +13,21 @@ class SelfCertification(Document):
def __init__(self, ts, identifier):
super(ts)
self.identifier = identifier
-
+ self.timestamp = timestamp
+
+ @classmethod
+ def from_raw(cls, raw):
+ #TODO : Parsing
+ return cls()
+
+ def ts(self):
+ return "META:TS:{0}".format(self.timestamp)
+
def uid(self):
return "UID:{0}".format(self.identifier)
def content(self):
- return "{0}\n{1}".format(self.uid(), self.timestamp())
+ return "{0}\n{1}".format(self.uid(), self.ts())
class Certification(Document):
@@ -33,8 +42,14 @@ class Certification(Document):
self.selfcert = selfcert
self.blockid = blockid
- def timestamp(self):
+
+ @classmethod
+ def from_raw(cls, raw):
+ #TODO : Parsing
+ return cls()
+
+ def ts(self):
return "META:TS:{0}".format(self.blockid)
def content(self):
- return "{0}\n{1}".format(self.selfcert.content(), self.timestamp())
+ return "{0}\n{1}".format(self.selfcert.content(), self.ts())
diff --git a/ucoinpy/documents/membership.py b/ucoinpy/documents/membership.py
index ae174521bd1bafa9efb0679104f2f28c64745c3c..05ddb7df53b4ccc23df7279a6fe05afbcf19ef23 100644
--- a/ucoinpy/documents/membership.py
+++ b/ucoinpy/documents/membership.py
@@ -32,6 +32,14 @@ class Membership(object):
self.userid = userid
self.cert_ts = cert_ts
+
+ @classmethod
+ def from_raw(cls, raw):
+ #TODO : Parsing
+ return cls()
+
+
+
def content(self):
return """
Version: {0}
diff --git a/ucoinpy/documents/peer.py b/ucoinpy/documents/peer.py
index 082c06ef5d2e7655872c8a75167f9051e8256fbb..d696665bd47f2c89689476f296e9e26a15ead25d 100644
--- a/ucoinpy/documents/peer.py
+++ b/ucoinpy/documents/peer.py
@@ -29,6 +29,11 @@ class Peer(Document):
self.pubkey = pubkey
self.blockid = blockid
self.endpoints = endpoints
+
+ @classmethod
+ def from_raw(cls, raw):
+ #TODO : Parsing
+ return cls()
def content(self):
doc = """
diff --git a/ucoinpy/documents/status.py b/ucoinpy/documents/status.py
index dd11ce1af153ef774793acf3ef9b5676f807a6ae..3913e0512d86bfa15dd88cb794975b7575fd99c2 100644
--- a/ucoinpy/documents/status.py
+++ b/ucoinpy/documents/status.py
@@ -29,6 +29,11 @@ class Status(Document):
self.sender = sender
self.recipient = recipient
+ @classmethod
+ def from_raw(cls, raw):
+ #TODO : Parsing
+ return cls()
+
def content(self):
return '''
Version: {0}
diff --git a/ucoinpy/documents/transaction.py b/ucoinpy/documents/transaction.py
index 10fa5d690c7f3f647792fd95f10ab620ea43cfe9..beaf476469305ad99bbc9f2edc88c06c3cdb49dd 100644
--- a/ucoinpy/documents/transaction.py
+++ b/ucoinpy/documents/transaction.py
@@ -37,6 +37,11 @@ SIGNATURES
self.outputs = outputs
self.comment = comment
+ @classmethod
+ def from_raw(cls, raw):
+ #TODO : Parsing
+ return cls()
+
def content(self):
doc = """
Version: {0}