def publish_raw_tx(self, key_name, doc_root_hash): if (doc_root_hash == ''): ErrorNotification.new( 'ERROR. doc_root_hash is EMPTY. Aborting publish_raw_tx ') return already_published = Utxo.query(Utxo.doc_fk == doc_root_hash).fetch() if len(already_published) > 0: ErrorNotification.new( 'WARNING. doc_root_hash: ' + doc_root_hash + ' was already published. Aborting publish_raw_tx ') return unused_utxo = Utxo.get_doc() if not unused_utxo: ErrorNotification.new( 'ERROR. No bitcoins available to spend. doc_root_hash: ' + doc_root_hash) return unused_utxo.doc_fk = doc_root_hash txid, message = publish_data(binascii.unhexlify(doc_root_hash), unused_utxo) k = ndb.Key('DocRoot', key_name) doc_root = k.get() if (txid != None): doc_root.txid = txid doc_root.put() unused_utxo.date_bcast = test.utcnow() unused_utxo.put() else: ErrorNotification.new('ERROR. publish_data for doc_root_hash: ' + doc_root_hash + ' Message: ' + message)
def publish_raw_tx(self, key_name, doc_root_hash): if (doc_root_hash==''): ErrorNotification.new('ERROR. doc_root_hash is EMPTY. Aborting publish_raw_tx ') return already_published=Utxo.query(Utxo.doc_fk==doc_root_hash).fetch() if len(already_published)>0: ErrorNotification.new('WARNING. doc_root_hash: '+doc_root_hash+ ' was already published. Aborting publish_raw_tx ') return unused_utxo=Utxo.get_doc() if not unused_utxo: ErrorNotification.new('ERROR. No bitcoins available to spend. doc_root_hash: ' + doc_root_hash) return unused_utxo.doc_fk=doc_root_hash txid, message=publish_data(binascii.unhexlify(doc_root_hash), unused_utxo) k=ndb.Key('DocRoot', key_name) doc_root=k.get() if (txid!=None): doc_root.txid=txid doc_root.put() unused_utxo.date_bcast=test.utcnow() unused_utxo.put() else: ErrorNotification.new('ERROR. publish_data for doc_root_hash: '+doc_root_hash+' Message: '+message)
def blockchain_certify(self): if self.tx: return {"success": False, "error": "already certified"} txid, message = publish_data(self.digest.decode('hex')) if txid: self.tx = txid self.txstamp = datetime.datetime.now() LatestBlockchainDocuments.get_inst().add_document(self.digest) self.put() return {"success": txid is not None, "tx": txid, "message": message}
def blockchain_certify(self): if self.tx: return {"success" : False, "error": "already certified"} txid, message = publish_data(self.digest.decode('hex')) if txid: self.tx = txid self.txstamp = datetime.datetime.now() LatestBlockchainDocuments.get_inst().add_document(self.digest) self.put() return {"success" : txid is not None, "tx" : txid, "message" : message}
def handle(self): digest = self.request.get("d") doc = Document.get_doc(digest) if not doc or doc.tx: return {"success" : False, "error": "format"} # TODO: add check to prevent double timestamping txid, message = publish_data(doc.digest.decode('hex')) if txid: doc.tx = txid doc.txstamp = datetime.datetime.now() LatestBlockchainDocuments.get_inst().add_document(digest) doc.put() return {"success" : txid is not None, "tx" : txid, "message" : message}
def handle(self): digest = self.request.get("d") doc = Document.get_doc(digest) if not doc or doc.tx: return {"success": False, "error": "format"} # TODO: add check to prevent double timestamping txid, message = publish_data(doc.digest.decode('hex')) if txid: doc.tx = txid doc.txstamp = datetime.datetime.now() LatestBlockchainDocuments.get_inst().add_document(digest) doc.put() return {"success": txid is not None, "tx": txid, "message": message}