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
GitLab 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
70531a3b
Commit
70531a3b
authored
8 years ago
by
inso
Browse files
Options
Downloads
Patches
Plain Diff
Fix owner of sources sent (
#553
)
parent
7cb55cf7
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sakia/data/processors/sources.py
+3
-2
3 additions, 2 deletions
src/sakia/data/processors/sources.py
src/sakia/services/documents.py
+4
-3
4 additions, 3 deletions
src/sakia/services/documents.py
with
7 additions
and
5 deletions
src/sakia/data/processors/sources.py
+
3
−
2
View file @
70531a3b
...
@@ -62,12 +62,13 @@ class SourcesProcessor:
...
@@ -62,12 +62,13 @@ class SourcesProcessor:
sources
=
self
.
_repo
.
get_all
(
currency
=
currency
,
pubkey
=
pubkey
)
sources
=
self
.
_repo
.
get_all
(
currency
=
currency
,
pubkey
=
pubkey
)
return
sum
([
s
.
amount
*
(
10
**
s
.
base
)
for
s
in
sources
])
return
sum
([
s
.
amount
*
(
10
**
s
.
base
)
for
s
in
sources
])
def
available
(
self
,
currency
):
def
available
(
self
,
currency
,
pubkey
):
""""
""""
:param str currency: the currency of the sources
:param str currency: the currency of the sources
:param str pubkey: the owner of the sources
:rtype: list[sakia.data.entities.Source]
:rtype: list[sakia.data.entities.Source]
"""
"""
return
self
.
_repo
.
get_all
(
currency
=
currency
)
return
self
.
_repo
.
get_all
(
currency
=
currency
,
pubkey
=
pubkey
)
def
consume
(
self
,
sources
):
def
consume
(
self
,
sources
):
"""
"""
...
...
This diff is collapsed.
Click to expand it.
src/sakia/services/documents.py
+
4
−
3
View file @
70531a3b
...
@@ -212,12 +212,13 @@ class DocumentsService:
...
@@ -212,12 +212,13 @@ class DocumentsService:
document
.
sign
(
self_cert
,
[
key
])
document
.
sign
(
self_cert
,
[
key
])
return
document
.
signed_raw
(
self_cert
)
return
document
.
signed_raw
(
self_cert
)
def
tx_sources
(
self
,
amount
,
amount_base
,
currency
):
def
tx_sources
(
self
,
amount
,
amount_base
,
currency
,
pubkey
):
"""
"""
Get inputs to generate a transaction with a given amount of money
Get inputs to generate a transaction with a given amount of money
:param int amount: The amount target value
:param int amount: The amount target value
:param int amount_base: The amount base target value
:param int amount_base: The amount base target value
:param str currency: The community target of the transaction
:param str currency: The community target of the transaction
:param str pubkey: The pubkey owning the sources
:return: The list of inputs to use in the transaction document
:return: The list of inputs to use in the transaction document
"""
"""
...
@@ -234,7 +235,7 @@ class DocumentsService:
...
@@ -234,7 +235,7 @@ class DocumentsService:
return
i
return
i
amount
,
amount_base
=
reduce_base
(
amount
,
amount_base
)
amount
,
amount_base
=
reduce_base
(
amount
,
amount_base
)
available_sources
=
self
.
_sources_processor
.
available
(
currency
)
available_sources
=
self
.
_sources_processor
.
available
(
currency
,
pubkey
)
if
available_sources
:
if
available_sources
:
current_base
=
max
([
src
.
base
for
src
in
available_sources
])
current_base
=
max
([
src
.
base
for
src
in
available_sources
])
value
=
0
value
=
0
...
@@ -335,7 +336,7 @@ class DocumentsService:
...
@@ -335,7 +336,7 @@ class DocumentsService:
:return: the transaction document
:return: the transaction document
:rtype: duniterpy.documents.Transaction
:rtype: duniterpy.documents.Transaction
"""
"""
result
=
self
.
tx_sources
(
int
(
amount
),
amount_base
,
currency
)
result
=
self
.
tx_sources
(
int
(
amount
),
amount_base
,
currency
,
issuer
)
sources
=
result
[
0
]
sources
=
result
[
0
]
computed_outputs
=
result
[
1
]
computed_outputs
=
result
[
1
]
overheads
=
result
[
2
]
overheads
=
result
[
2
]
...
...
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