Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sakia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
clients
python
sakia
Commits
4995a11c
Commit
4995a11c
authored
10 years ago
by
inso
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
https://github.com/Insoleet/ucoin-python-api
into dev
parents
8d4142b0
981c1f86
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/ucoin/wrappers/__init__.py
+1
-2
1 addition, 2 deletions
lib/ucoin/wrappers/__init__.py
lib/ucoin/wrappers/coins.py
+1
-1
1 addition, 1 deletion
lib/ucoin/wrappers/coins.py
lib/ucoin/wrappers/transactions.py
+7
-66
7 additions, 66 deletions
lib/ucoin/wrappers/transactions.py
with
9 additions
and
69 deletions
lib/ucoin/wrappers/__init__.py
+
1
−
2
View file @
4995a11c
...
@@ -18,8 +18,7 @@
...
@@ -18,8 +18,7 @@
#
#
import
logging
import
logging
from
..
import
pks
,
hdc
,
settings
from
..
import
pks
,
hdc
,
network
,
registry
,
settings
import
network
logger
=
logging
.
getLogger
(
"
wrappers
"
)
logger
=
logging
.
getLogger
(
"
wrappers
"
)
...
...
This diff is collapsed.
Click to expand it.
lib/ucoin/wrappers/coins.py
+
1
−
1
View file @
4995a11c
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
#
#
import
logging
import
logging
from
.
import
Wrapper
,
pks
,
ucg
,
hdc
,
settings
from
.
import
Wrapper
,
pks
,
network
,
hdc
,
settings
logger
=
logging
.
getLogger
(
"
coins
"
)
logger
=
logging
.
getLogger
(
"
coins
"
)
...
...
This diff is collapsed.
Click to expand it.
lib/ucoin/wrappers/transactions.py
+
7
−
66
View file @
4995a11c
...
@@ -17,8 +17,8 @@
...
@@ -17,8 +17,8 @@
# Caner Candan <caner@candan.fr>, http://caner.candan.fr
# Caner Candan <caner@candan.fr>, http://caner.candan.fr
#
#
import
hashlib
,
logging
import
hashlib
,
logging
,
re
from
.
import
Wrapper
,
pks
,
ucg
,
hdc
,
settings
from
.
import
Wrapper
,
pks
,
network
,
hdc
,
registry
,
settings
logger
=
logging
.
getLogger
(
"
transactions
"
)
logger
=
logging
.
getLogger
(
"
transactions
"
)
...
@@ -40,7 +40,7 @@ class Transaction(Wrapper):
...
@@ -40,7 +40,7 @@ class Transaction(Wrapper):
context_data
=
{}
context_data
=
{}
context_data
.
update
(
settings
)
context_data
.
update
(
settings
)
context_data
.
update
(
self
.
peering
if
self
.
peering
else
ucg
.
Peering
().
get
())
context_data
.
update
(
self
.
peering
if
self
.
peering
else
network
.
Peering
().
get
())
context_data
[
'
version
'
]
=
1
context_data
[
'
version
'
]
=
1
context_data
[
'
number
'
]
=
0
if
not
last_tx
else
last_tx
[
'
transaction
'
][
'
number
'
]
+
1
context_data
[
'
number
'
]
=
0
if
not
last_tx
else
last_tx
[
'
transaction
'
][
'
number
'
]
+
1
context_data
[
'
previousHash
'
]
=
hashlib
.
sha1
((
"
%(raw)s%(signature)s
"
%
last_tx
).
encode
(
'
ascii
'
)).
hexdigest
().
upper
()
if
last_tx
else
None
context_data
[
'
previousHash
'
]
=
hashlib
.
sha1
((
"
%(raw)s%(signature)s
"
%
last_tx
).
encode
(
'
ascii
'
)).
hexdigest
().
upper
()
if
last_tx
else
None
...
@@ -99,7 +99,7 @@ Comment:
...
@@ -99,7 +99,7 @@ Comment:
data
=
coin
.
split
(
'
:
'
)
data
=
coin
.
split
(
'
:
'
)
issuer
,
numbers
=
data
[
0
],
data
[
1
:]
issuer
,
numbers
=
data
[
0
],
data
[
1
:]
for
number
in
numbers
:
for
number
in
numbers
:
view
=
hdc
.
coins
.
V
iew
(
issuer
,
int
(
number
),
self
.
server
,
self
.
port
).
get
()
view
=
hdc
.
coins
.
v
iew
.
Owner
(
issuer
,
int
(
number
),
self
.
server
,
self
.
port
).
get
()
if
view
[
'
owner
'
]
!=
self
.
pgp_fingerprint
:
if
view
[
'
owner
'
]
!=
self
.
pgp_fingerprint
:
raise
ValueError
(
'
Trying to divide a coin you do not own (%s)
'
%
view
[
'
id
'
])
raise
ValueError
(
'
Trying to divide a coin you do not own (%s)
'
%
view
[
'
id
'
])
coins
.
append
(
view
)
coins
.
append
(
view
)
...
@@ -137,7 +137,7 @@ Coins:
...
@@ -137,7 +137,7 @@ Coins:
issuer
=
data
[
0
]
issuer
=
data
[
0
]
for
number
in
data
[
1
:]:
for
number
in
data
[
1
:]:
context_data
.
update
(
hdc
.
coins
.
V
iew
(
issuer
,
int
(
number
),
self
.
server
,
self
.
port
).
get
())
context_data
.
update
(
hdc
.
coins
.
v
iew
.
Owner
(
issuer
,
int
(
number
),
self
.
server
,
self
.
port
).
get
())
tx
+=
'
%(id)s, %(transaction)s
\n
'
%
context_data
tx
+=
'
%(id)s, %(transaction)s
\n
'
%
context_data
return
tx
return
tx
...
@@ -160,7 +160,7 @@ Coins:
...
@@ -160,7 +160,7 @@ Coins:
for
coin
in
self
.
coins
:
for
coin
in
self
.
coins
:
data
=
coin
.
split
(
'
-
'
)
data
=
coin
.
split
(
'
-
'
)
context_data
.
update
(
hdc
.
coins
.
V
iew
(
data
[
0
],
int
(
data
[
1
]),
self
.
server
,
self
.
port
).
get
())
context_data
.
update
(
hdc
.
coins
.
v
iew
.
Owner
(
data
[
0
],
int
(
data
[
1
]),
self
.
server
,
self
.
port
).
get
())
tx
+=
'
%(id)s, %(transaction)s
\n
'
%
context_data
tx
+=
'
%(id)s, %(transaction)s
\n
'
%
context_data
return
tx
return
tx
...
@@ -182,7 +182,7 @@ Coins:
...
@@ -182,7 +182,7 @@ Coins:
"""
%
context_data
"""
%
context_data
try
:
try
:
last_issuance
=
hdc
.
transactions
.
sender
.
issuance
.
Last
(
self
.
pgp_fingerprint
,
self
.
server
,
self
.
port
).
get
()
last_issuance
=
hdc
.
transactions
.
sender
.
Last
(
self
.
pgp_fingerprint
,
self
.
server
,
self
.
port
).
get
()
except
ValueError
:
except
ValueError
:
last_issuance
=
None
last_issuance
=
None
...
@@ -194,62 +194,3 @@ Coins:
...
@@ -194,62 +194,3 @@ Coins:
def
get_mono_message
(
self
,
context_data
,
tx
=
''
):
def
get_mono_message
(
self
,
context_data
,
tx
=
''
):
return
tx
return
tx
class
Issue
(
MonoTransaction
):
def
__init__
(
self
,
pgp_fingerprint
,
amendment
,
coins
,
message
=
''
,
keyid
=
None
,
server
=
None
,
port
=
None
):
super
().
__init__
(
'
ISSUANCE
'
,
pgp_fingerprint
,
message
,
keyid
=
keyid
,
server
=
server
,
port
=
port
)
self
.
amendment
=
amendment
self
.
coins
=
coins
def
get_mono_message
(
self
,
context_data
,
tx
=
''
):
context_data
[
'
amendment
'
]
=
self
.
amendment
for
idx
,
coin
in
enumerate
(
self
.
coins
):
context_data
[
'
idx
'
]
=
idx
+
context_data
[
'
previous_idx
'
]
context_data
[
'
base
'
],
context_data
[
'
power
'
]
=
[
int
(
x
)
for
x
in
coin
.
split
(
'
,
'
)]
tx
+=
'
%(fingerprint)s-%(idx)d-%(base)d-%(power)d-A-%(amendment)d
\n
'
%
context_data
return
tx
class
Fusion
(
MonoTransaction
):
def
__init__
(
self
,
pgp_fingerprint
,
coins
,
message
=
''
,
keyid
=
None
,
server
=
None
,
port
=
None
):
super
().
__init__
(
'
FUSION
'
,
pgp_fingerprint
,
message
,
keyid
=
keyid
,
server
=
server
,
port
=
port
)
self
.
coins
=
coins
def
get_mono_message
(
self
,
context_data
,
tx
=
''
):
coins
=
self
.
parse_coins
(
self
.
coins
)
self
.
check_coins_sum
(
self
.
get_coins_sum
(
coins
))
context_data
[
'
base
'
],
context_data
[
'
power
'
]
=
int
(
m
.
groups
()[
0
]),
len
(
m
.
groups
()[
1
])
tx
+=
'
%(fingerprint)s-%(previous_idx)d-%(base)d-%(power)d-F-%(number)d
\n
'
%
context_data
for
coin
in
coins
:
tx
+=
'
%(id)s, %(transaction)s
\n
'
%
coin
return
tx
class
Divide
(
MonoTransaction
):
def
__init__
(
self
,
pgp_fingerprint
,
old_coins
,
new_coins
,
message
=
''
,
keyid
=
None
,
server
=
None
,
port
=
None
):
super
().
__init__
(
'
DIVISION
'
,
pgp_fingerprint
,
message
,
keyid
=
keyid
,
server
=
server
,
port
=
port
)
self
.
old_coins
=
old_coins
self
.
new_coins
=
new_coins
def
get_mono_message
(
self
,
context_data
,
tx
=
''
):
old_coins
=
self
.
parse_coins
(
self
.
old_coins
)
old_coins_sum
=
self
.
get_coins_sum
(
old_coins
)
new_coins_sum
=
0
for
idx
,
coin
in
enumerate
(
self
.
new_coins
):
context_data
[
'
idx
'
]
=
idx
+
context_data
[
'
previous_idx
'
]
context_data
[
'
base
'
],
context_data
[
'
power
'
]
=
[
int
(
x
)
for
x
in
coin
.
split
(
'
,
'
)]
new_coins_sum
+=
context_data
[
'
base
'
]
*
10
**
context_data
[
'
power
'
]
tx
+=
'
%(fingerprint)s-%(idx)d-%(base)d-%(power)d-D-%(number)d
\n
'
%
context_data
if
old_coins_sum
!=
new_coins_sum
:
raise
ValueError
(
'
Amount of old coins (%d) is not equal to new coins (%d)
'
%
(
old_coins_sum
,
new_coins_sum
))
for
coin
in
old_coins
:
tx
+=
'
%(id)s, %(transaction)s
\n
'
%
coin
return
tx
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment