Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
silkaj
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
silkaj
Commits
1d063d7f
Commit
1d063d7f
authored
6 years ago
by
Moul
Browse files
Options
Downloads
Patches
Plain Diff
[mod]
#72
: tx: use generic f() to generate tx outputs.
parent
39f9bb9c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
silkaj/tx.py
+19
-31
19 additions, 31 deletions
silkaj/tx.py
with
19 additions
and
31 deletions
silkaj/tx.py
+
19
−
31
View file @
1d063d7f
...
...
@@ -252,40 +252,11 @@ def generate_transaction_document(
listoutput
=
[]
# Outputs to receiver (if not himself)
for
outputAddress
in
outputAddresses
:
rest
=
AmountTransfered
unitbase
=
curentUnitBase
while
rest
>
0
:
outputAmount
=
truncBase
(
rest
,
unitbase
)
rest
-=
outputAmount
if
outputAmount
>
0
:
outputAmount
=
int
(
outputAmount
/
math
.
pow
(
10
,
unitbase
))
listoutput
.
append
(
str
(
outputAmount
)
+
"
:
"
+
str
(
unitbase
)
+
"
:SIG(
"
+
outputAddress
+
"
)
"
)
unitbase
=
unitbase
-
1
generate_output
(
listoutput
,
curentUnitBase
,
AmountTransfered
,
outputAddresses
)
# Outputs to himself
unitbase
=
curentUnitBase
rest
=
totalAmountInput
-
totalAmountTransfered
while
rest
>
0
:
outputAmount
=
truncBase
(
rest
,
unitbase
)
rest
-=
outputAmount
if
outputAmount
>
0
:
outputAmount
=
int
(
outputAmount
/
math
.
pow
(
10
,
unitbase
))
listoutput
.
append
(
str
(
outputAmount
)
+
"
:
"
+
str
(
unitbase
)
+
"
:SIG(
"
+
OutputbackChange
+
"
)
"
)
unitbase
=
unitbase
-
1
generate_output
(
listoutput
,
curentUnitBase
,
rest
,
OutputbackChange
)
# Generate transaction document
##############################
...
...
@@ -311,6 +282,23 @@ def generate_transaction_document(
return
transaction_document
def
generate_output
(
listoutput
,
unitbase
,
rest
,
recipient_address
):
while
rest
>
0
:
outputAmount
=
truncBase
(
rest
,
unitbase
)
rest
-=
outputAmount
if
outputAmount
>
0
:
outputAmount
=
int
(
outputAmount
/
math
.
pow
(
10
,
unitbase
))
listoutput
.
append
(
str
(
outputAmount
)
+
"
:
"
+
str
(
unitbase
)
+
"
:SIG(
"
+
recipient_address
+
"
)
"
)
unitbase
=
unitbase
-
1
def
get_list_input_for_transaction
(
pubkey
,
TXamount
,
allinput
=
False
):
listinput
,
amount
=
get_sources
(
pubkey
)
...
...
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