diff --git a/README.md b/README.md index 500b61f0c122670dbae7c9e4838b3fd062cae81f..404988ebc454b5c36d161b160cc4bfacc35535aa 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,6 @@ Qt Client for [Ucoin](http://www.ucoin.io) project. * Multi-wallets * Contacts messaging * User-friendly coins transfer - * On-the-fly and automatic coins fusion and divisions for transactions - * Coins issuance policies : minimal space, minimal changes * Community membership management via a voting interface ## Current state @@ -27,7 +25,6 @@ Qt Client for [Ucoin](http://www.ucoin.io) project. ### Todo * Joining a community, publishing keys * Multiple wallets management - * Cutecoin keyring ### How to install * __git clone --recursive https://github.com/Insoleet/cutecoin.git__ diff --git a/lib/ucoin/wrappers/__init__.py b/lib/ucoin/wrappers/__init__.py deleted file mode 100644 index 31fc5405939b9f841b63108ed4e22225896d1795..0000000000000000000000000000000000000000 --- a/lib/ucoin/wrappers/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python3 -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -# Authors: -# Caner Candan <caner@candan.fr>, http://caner.candan.fr -# - -import logging -from .. import pks, hdc, network, registry, settings - -logger = logging.getLogger("wrappers") - -class Wrapper: - def __init__(self, server=None, port=None): - self.server = server - self.port = port - - def __call__(self): - pass - -from . import transactions, coins diff --git a/lib/ucoin/wrappers/coins.py b/lib/ucoin/wrappers/coins.py deleted file mode 100644 index c292b3cca8756190d1ca42abdb8c3739ccaf2eae..0000000000000000000000000000000000000000 --- a/lib/ucoin/wrappers/coins.py +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env python3 -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -# Authors: -# Caner Candan <caner@candan.fr>, http://caner.candan.fr -# - -import logging -from . import Wrapper, pks, network, hdc, settings - -logger = logging.getLogger("coins") - -class Coins(Wrapper): - def __init__(self, pgp_fingerprint, server=None, port=None): - super().__init__(server, port) - - self.pgp_fingerprint = pgp_fingerprint - -class Get(Coins): - def __init__(self, pgp_fingerprint, values, server=None, port=None): - super().__init__(pgp_fingerprint, server, port) - - self.values = values - - def __call__(self): - __list = hdc.coins.List(self.pgp_fingerprint, self.server, self.port).get() - coins = {} - for c in __list['coins']: - for id in c['ids']: - n,b,p,t,i = id.split('-') - amount = int(b) * 10**int(p) - if amount not in coins: coins[amount] = [] - coins[amount].append({'issuer': c['issuer'], 'number': int(n), 'base': int(b), 'power': int(p), 'type': t, 'type_number': int(i), 'amount': amount}) - - issuers = {} - for v in self.values: - if v in coins and coins[v]: - c = coins[v].pop() - issuers[c['issuer']] = issuers.get(c['issuer']) or [] - issuers[c['issuer']].append(c) - else: - raise ValueError('You do not have enough coins of value (%d)' % v) - - res = '' - for i, issuer in enumerate(issuers): - if i > 0: res += ',' - res += issuer - for c in issuers[issuer]: - res += ':%(number)d' % c - - return res - -class List(Coins): - def __init__(self, pgp_fingerprint, limit=None, server=None, port=None): - super().__init__(pgp_fingerprint, server, port) - - self.limit = limit - - def __call__(self): - __list = hdc.coins.List(self.pgp_fingerprint, self.server, self.port).get() - coins = [] - __sum = 0 - - for c in __list['coins']: - for id in c['ids']: - n,b,p,t,i = id.split('-') - amount = int(b) * 10**int(p) - __dict = {'issuer': c['issuer'], 'number': int(n), 'base': int(b), 'power': int(p), 'type': t, 'type_number': int(i), 'amount': amount} - - if not self.limit or self.limit >= amount: - coins.append(__dict) - __sum += amount - - return __sum, coins diff --git a/lib/ucoin/wrappers/transactions.py b/lib/ucoin/wrappers/transactions.py deleted file mode 100644 index 6452852dbf63fc0bc679e7cd043ee0ed2bef25c7..0000000000000000000000000000000000000000 --- a/lib/ucoin/wrappers/transactions.py +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/env python3 -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -# Authors: -# Caner Candan <caner@candan.fr>, http://caner.candan.fr -# - -import hashlib, logging, re -from . import Wrapper, pks, network, hdc, registry, settings - -logger = logging.getLogger("transactions") - - -class Transaction(Wrapper): - def __init__(self, pgp_fingerprint, recipient, coins, message='', keyid=None, peering=None, server=None, port=None): - super().__init__(server, port) - self.keyid = keyid - self.pgp_fingerprint = pgp_fingerprint - self.message = message - self.error = None - self.peering = peering - self.recipient = recipient - self.coins = coins - self.coins.sort() - - def __call__(self): - tx = self.get_message() - txs = settings['gpg'].sign(tx, keyid=self.keyid, detach=True) - return {'transaction':tx, 'signature':txs} - - def get_context_data(self): - return {} - - def get_message(self): - try: - last_tx = hdc.transactions.sender.Last(count=1, pgp_fingerprint=self.pgp_fingerprint, - server=self.server, port=self.port).get() - last_tx = last_tx['transactions'][0] - last_tx = hdc.transactions.sender.View(self.pgp_fingerprint, tx_number=last_tx['number'], - server=self.server, port=self.port).get() - except ValueError: - last_tx = None - - if last_tx: - previous_hash = hashlib.sha1(("%s%s" % (last_tx['raw'], last_tx['transaction']['signature'])).encode('ascii')).hexdigest().upper() - else: - previous_hash = None - - context_data = {} - context_data.update(settings) - context_data.update(self.peering if self.peering else network.Peering(server=self.server, port=self.port).get()) - context_data['version'] = 1 - context_data['number'] = 0 if not last_tx else last_tx['transaction']['number']+1 - context_data['previousHash'] = previous_hash - context_data['message'] = self.message - context_data['fingerprint'] = self.pgp_fingerprint - context_data['recipient'] = self.recipient - context_data.update(self.get_context_data()) - - tx = """\ -Version: %(version)d -Currency: %(currency)s -Sender: %(fingerprint)s -Number: %(number)d -""" % context_data - - if last_tx: tx += "PreviousHash: %(previousHash)s\n" % context_data - - - tx += """\ -Recipient: %(recipient)s -Coins: -""" % context_data - - for coin in self.coins: - tx += '%s' % coin - ownership = hdc.coins.view.Owner(coin, self.server, self.port).get() - if 'transaction' in ownership: - tx += ':%(transaction)s\n' % ownership - else: - tx += "\n" - - tx += """\ -Comment: -%(message)s""" % context_data - - tx = tx.replace("\n", "\r\n") - return tx - - def get_error(self): - return self.error