Skip to content
Snippets Groups Projects
Commit 0a374313 authored by inso's avatar inso
Browse files

Transctions lifecycle specifications

parent d7f78e1a
No related branches found
No related tags found
No related merge requests found
# Specifications
## Client-side concepts
### Account
* An account is a PGP Key
* An account can be a member of multiple communities
* An account own at least one wallet for each currency he owns
* An account can own multiple wallets of the same currency
* An account must declare the nodes he trusts to receive transactions
* An account must declare the nodes he uses to send transactions for a currency type
### Community
* A community uses one unique currency
* A community has members
* Each members of the community can issue currency following the rule defined in the community amendment
### Wallets
* Wallets can own only one type of currency
* Wallets value are the sum of the transactions received and sent that the user listed in this wallet
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>452</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">CuteCoin</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QFrame" name="actionsFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="walletsTab">
<attribute name="title">
<string>Wallets</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QListWidget" name="listWidget_2">
<item>
<property name="text">
<string>Main wallet (uCoins)</string>
</property>
</item>
<item>
<property name="text">
<string>Freecoins wallet (freeCoins)</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QListWidget" name="listWidget_3">
<item>
<property name="text">
<string>+10</string>
</property>
</item>
<item>
<property name="text">
<string>-100</string>
</property>
</item>
<item>
<property name="text">
<string>-30</string>
</property>
</item>
<item>
<property name="text">
<string>+300</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="transactionsTab">
<attribute name="title">
<string>Transactions</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Sent</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listWidget">
<item>
<property name="text">
<string>100 to Caner Candan (0x5D2662E0F300EBAD)</string>
</property>
</item>
<item>
<property name="text">
<string>30 to cgeek twicedd (0x399EB3415C237F93)</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Received</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listWidget_4">
<item>
<property name="text">
<string>10 from Caner Candan (0x5D2662E0F300EBAD)</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="communitiesTab">
<attribute name="title">
<string>Communities</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QTabWidget" name="tabWidget_2">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="ucoinTab">
<attribute name="title">
<string>Ucoin</string>
</attribute>
</widget>
<widget class="QWidget" name="freecoinTab">
<attribute name="title">
<string>FreeCoin</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Members</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listWidget_5">
<item>
<property name="text">
<string>Mister K</string>
</property>
</item>
<item>
<property name="text">
<string>Another guy</string>
</property>
</item>
<item>
<property name="text">
<string>Inso sonI</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Last issuance</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listWidget_6">
<item>
<property name="text">
<string>110 (27/12/2014)</string>
</property>
</item>
<item>
<property name="text">
<string>140 (27/01/2015)</string>
</property>
</item>
<item>
<property name="text">
<string>190 (27/02/2015)</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>452</width>
<height>20</height>
</rect>
</property>
<widget class="QMenu" name="menuTr_File">
<property name="title">
<string>Account</string>
</property>
<addaction name="actionChange_account"/>
<addaction name="actionManage_accounts"/>
<addaction name="actionConfigure_trustable_nodes"/>
</widget>
<widget class="QMenu" name="menuEdit">
<property name="title">
<string>Contacts</string>
</property>
<widget class="QMenu" name="menuCaner_Candan">
<property name="title">
<string>Caner Candan</string>
</property>
<addaction name="separator"/>
<addaction name="actionSend_a_message"/>
<addaction name="actionSend_money"/>
<addaction name="separator"/>
<addaction name="actionRemove_contact"/>
</widget>
<widget class="QMenu" name="menuCGeek">
<property name="title">
<string>cGeek</string>
</property>
<addaction name="actionSend_a_message_2"/>
<addaction name="actionSend_money_2"/>
<addaction name="separator"/>
<addaction name="actionRemove_contact_2"/>
</widget>
<addaction name="menuCaner_Candan"/>
<addaction name="menuCGeek"/>
<addaction name="separator"/>
<addaction name="actionAdd_a_contact"/>
</widget>
<addaction name="menuTr_File"/>
<addaction name="menuEdit"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="actionChange_account">
<property name="text">
<string>Change account</string>
</property>
</action>
<action name="actionManage_accounts">
<property name="text">
<string>Manage accounts</string>
</property>
</action>
<action name="actionConfigure_trustable_nodes">
<property name="text">
<string>Configure trustable nodes</string>
</property>
</action>
<action name="actionAdd_a_contact">
<property name="text">
<string>Add a contact</string>
</property>
</action>
<action name="actionSend_a_message">
<property name="text">
<string>Send a message</string>
</property>
</action>
<action name="actionSend_money">
<property name="text">
<string>Send money</string>
</property>
</action>
<action name="actionRemove_contact">
<property name="text">
<string>Remove contact</string>
</property>
</action>
<action name="actionSend_a_message_2">
<property name="text">
<string>Send a message</string>
</property>
</action>
<action name="actionSend_money_2">
<property name="text">
<string>Send money</string>
</property>
</action>
<action name="actionRemove_contact_2">
<property name="text">
<string>Remove contact</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>
doc/uml/models.png

38.7 KiB

@startuml
#TODO: Rework UML with all informations gathered lately
class Account {
pgpkey
}
Account --> "0..*" Community : is a member of
Account --> "0..*" Node : trusts
Account --> "0..*" Node : send transactions with
Account --> "*" Transaction : send
Account --> "*" Transaction : receive
Account --> "0..*" Wallet : owns
class Community {
}
Community "1" -- "1" Currency : uses
Community "1" --> "1..*" Node : known nodes
class Node {
address
port
auth
}
Node --> "1" Community
class Transaction {
value
currency
sender
receiver
}
class Wallet {
currency
coins
}
@enduml
doc/uml/tx_lifecycle.png

22 KiB

@startuml
[*] --> To_send
To_send --> Awaiting : Broadcasted at B
Awaiting --> Validated : Registered in [B; B+15]
Awaiting --> Canceled : Not registered in [B; B+15]
Canceled --> To_send : Send back order
Canceled --> Dropped : Drop order
@enduml
\ No newline at end of file
......@@ -19,14 +19,15 @@ class Cache():
self.wallet = wallet
self.tx_sent = []
self.awaiting_tx = []
self.tx_awaiting = []
self.tx_received = []
self.tx_to_send = []
self.available_sources = []
def load_from_json(self, data):
self.tx_received = []
self.tx_sent = []
self.awaiting_tx = []
self.tx_awaiting = []
logging.debug(data)
data_received = data['received']
......@@ -39,7 +40,7 @@ class Cache():
data_awaiting = data['awaiting']
for s in data_awaiting:
self.awaiting_tx.append((r['block'], Transaction.from_signed_raw(s['raw'])))
self.tx_awaiting.append((r['block'], Transaction.from_signed_raw(s['raw'])))
if 'sources' in data:
data_sources = data['sources']
......@@ -58,7 +59,7 @@ class Cache():
data_sent.append({'block': r[0], 'raw': s[1].signed_raw()})
data_awaiting = []
for s in self.awaiting_tx:
for s in self.tx_awaiting:
data_awaiting.append({'block': r[0], 'raw': s[1].signed_raw()})
data_sources = []
......@@ -76,7 +77,7 @@ class Cache():
return self.tx_sent
def awaiting(self, community):
return self.awaiting_tx
return self.tx_awaiting
def latest_received(self, community):
return self.tx_received
......@@ -117,7 +118,7 @@ class Cache():
if len(in_inputs) > 0:
# remove from waiting transactions list the one which were
# validated in the blockchain
self.awaiting_tx = [awaiting[1] for awaiting in self.awaiting_tx
self.tx_awaiting = [awaiting[1] for awaiting in self.tx_awaiting
if awaiting[1].compact() != tx.compact()]
self.tx_sent.append((block_number, tx))
......@@ -262,7 +263,7 @@ class Wallet(object):
community.broadcast(bma.tx.Process,
post_args={'transaction': tx.signed_raw()})
block_number = community.current_blockid()['number']
self.caches[community.currency].awaiting_tx.append((block_number, tx))
self.caches[community.currency].tx_awaiting.append((block_number, tx))
except:
raise
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment