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
5a40e408
Commit
5a40e408
authored
4 years ago
by
Moul
Browse files
Options
Downloads
Patches
Plain Diff
[mod]
#328
: cert/tx: Import top-level Click module
parent
352bc49f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
silkaj/cert.py
+5
-5
5 additions, 5 deletions
silkaj/cert.py
silkaj/tx.py
+20
-12
20 additions, 12 deletions
silkaj/tx.py
with
25 additions
and
17 deletions
silkaj/cert.py
+
5
−
5
View file @
5a40e408
...
@@ -16,7 +16,7 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
...
@@ -16,7 +16,7 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
"""
"""
import
sys
import
sys
from
click
import
command
,
argument
,
echo
,
confirm
import
click
from
time
import
time
from
time
import
time
from
tabulate
import
tabulate
from
tabulate
import
tabulate
from
duniterpy.api
import
bma
from
duniterpy.api
import
bma
...
@@ -33,8 +33,8 @@ from silkaj.constants import SUCCESS_EXIT_STATUS
...
@@ -33,8 +33,8 @@ from silkaj.constants import SUCCESS_EXIT_STATUS
from
silkaj.crypto_tools
import
is_pubkey_and_check
from
silkaj.crypto_tools
import
is_pubkey_and_check
@command
(
"
cert
"
,
help
=
"
Send certification
"
)
@
click.
command
(
"
cert
"
,
help
=
"
Send certification
"
)
@argument
(
"
uid_pubkey_to_certify
"
)
@
click.
argument
(
"
uid_pubkey_to_certify
"
)
@coroutine
@coroutine
async
def
send_certification
(
uid_pubkey_to_certify
):
async
def
send_certification
(
uid_pubkey_to_certify
):
client
=
ClientInstance
().
client
client
=
ClientInstance
().
client
...
@@ -144,7 +144,7 @@ async def certification_confirmation(
...
@@ -144,7 +144,7 @@ async def certification_confirmation(
cert_begins
=
convert_time
(
time
(),
"
date
"
)
cert_begins
=
convert_time
(
time
(),
"
date
"
)
cert_ends
=
convert_time
(
time
()
+
params
[
"
sigValidity
"
],
"
date
"
)
cert_ends
=
convert_time
(
time
()
+
params
[
"
sigValidity
"
],
"
date
"
)
cert
.
append
([
"
Valid
"
,
cert_begins
,
"
—>
"
,
cert_ends
])
cert
.
append
([
"
Valid
"
,
cert_begins
,
"
—>
"
,
cert_ends
])
echo
(
tabulate
(
cert
,
tablefmt
=
"
fancy_grid
"
))
click
.
echo
(
tabulate
(
cert
,
tablefmt
=
"
fancy_grid
"
))
if
not
confirm
(
"
Do you confirm sending this certification?
"
):
if
not
click
.
confirm
(
"
Do you confirm sending this certification?
"
):
await
client
.
close
()
await
client
.
close
()
sys
.
exit
(
SUCCESS_EXIT_STATUS
)
sys
.
exit
(
SUCCESS_EXIT_STATUS
)
This diff is collapsed.
Click to expand it.
silkaj/tx.py
+
20
−
12
View file @
5a40e408
...
@@ -19,7 +19,7 @@ from re import compile, search
...
@@ -19,7 +19,7 @@ from re import compile, search
import
math
import
math
from
asyncio
import
sleep
from
asyncio
import
sleep
from
tabulate
import
tabulate
from
tabulate
import
tabulate
from
click
import
command
,
option
,
FloatRange
import
click
from
silkaj
import
cli_tools
from
silkaj
import
cli_tools
from
silkaj
import
network_tools
as
nt
from
silkaj
import
network_tools
as
nt
...
@@ -44,37 +44,37 @@ from duniterpy.documents.transaction import OutputSource, Unlock, SIGParameter
...
@@ -44,37 +44,37 @@ from duniterpy.documents.transaction import OutputSource, Unlock, SIGParameter
MAX_COMMENT_LENGTH
=
255
MAX_COMMENT_LENGTH
=
255
@command
(
"
tx
"
,
help
=
"
Send transaction
"
)
@
click.
command
(
"
tx
"
,
help
=
"
Send transaction
"
)
@option
(
@
click.
option
(
"
amounts
"
,
"
amounts
"
,
"
--amount
"
,
"
--amount
"
,
"
-a
"
,
"
-a
"
,
multiple
=
True
,
multiple
=
True
,
type
=
FloatRange
(
MINIMAL_ABSOLUTE_TX_AMOUNT
),
type
=
click
.
FloatRange
(
MINIMAL_ABSOLUTE_TX_AMOUNT
),
help
=
"
Quantitative amount(s):
\n
-a <amount>
\n
Minimum amount is {0}
"
.
format
(
help
=
"
Quantitative amount(s):
\n
-a <amount>
\n
Minimum amount is {0}
"
.
format
(
MINIMAL_ABSOLUTE_TX_AMOUNT
MINIMAL_ABSOLUTE_TX_AMOUNT
),
),
cls
=
cli_tools
.
MutuallyExclusiveOption
,
cls
=
cli_tools
.
MutuallyExclusiveOption
,
mutually_exclusive
=
[
"
amountsud
"
,
"
allsources
"
],
mutually_exclusive
=
[
"
amountsud
"
,
"
allsources
"
],
)
)
@option
(
@
click.
option
(
"
amountsud
"
,
"
amountsud
"
,
"
--amountUD
"
,
"
--amountUD
"
,
"
-d
"
,
"
-d
"
,
multiple
=
True
,
multiple
=
True
,
type
=
FloatRange
(
MINIMAL_RELATIVE_TX_AMOUNT
),
type
=
click
.
FloatRange
(
MINIMAL_RELATIVE_TX_AMOUNT
),
help
=
f
"
Relative amount(s):
\n
-d <amount_UD>
\n
Minimum amount is
{
MINIMAL_RELATIVE_TX_AMOUNT
}
"
,
help
=
f
"
Relative amount(s):
\n
-d <amount_UD>
\n
Minimum amount is
{
MINIMAL_RELATIVE_TX_AMOUNT
}
"
,
cls
=
cli_tools
.
MutuallyExclusiveOption
,
cls
=
cli_tools
.
MutuallyExclusiveOption
,
mutually_exclusive
=
[
"
amounts
"
,
"
allsources
"
],
mutually_exclusive
=
[
"
amounts
"
,
"
allsources
"
],
)
)
@option
(
@
click.
option
(
"
--allSources
"
,
"
--allSources
"
,
is_flag
=
True
,
is_flag
=
True
,
help
=
"
Send all sources to one recipient
"
,
help
=
"
Send all sources to one recipient
"
,
cls
=
cli_tools
.
MutuallyExclusiveOption
,
cls
=
cli_tools
.
MutuallyExclusiveOption
,
mutually_exclusive
=
[
"
amounts
"
,
"
amountsud
"
],
mutually_exclusive
=
[
"
amounts
"
,
"
amountsud
"
],
)
)
@option
(
@
click.
option
(
"
recipients
"
,
"
recipients
"
,
"
--recipient
"
,
"
--recipient
"
,
"
-r
"
,
"
-r
"
,
...
@@ -85,15 +85,23 @@ Sending to many recipients is possible:\n\
...
@@ -85,15 +85,23 @@ Sending to many recipients is possible:\n\
* With one amount, all will receive the amount
\n\
* With one amount, all will receive the amount
\n\
* With many amounts (one per recipient)
"
,
* With many amounts (one per recipient)
"
,
)
)
@option
(
"
--comment
"
,
"
-c
"
,
default
=
""
,
help
=
"
Comment
"
)
@
click.
option
(
"
--comment
"
,
"
-c
"
,
default
=
""
,
help
=
"
Comment
"
)
@option
(
@
click.
option
(
"
--outputBackChange
"
,
"
--outputBackChange
"
,
help
=
"
Pubkey recipient to send the rest of the transaction: <pubkey[:checksum]>
"
,
help
=
"
Pubkey recipient to send the rest of the transaction: <pubkey[:checksum]>
"
,
)
)
@option
(
"
--yes
"
,
"
-y
"
,
is_flag
=
True
,
help
=
"
Assume yes. Do not prompt confirmation
"
)
@click.option
(
"
--yes
"
,
"
-y
"
,
is_flag
=
True
,
help
=
"
Assume yes. Do not prompt confirmation
"
)
@tools.coroutine
@tools.coroutine
async
def
send_transaction
(
async
def
send_transaction
(
amounts
,
amountsud
,
allsources
,
recipients
,
comment
,
outputbackchange
,
yes
amounts
,
amountsud
,
allsources
,
recipients
,
comment
,
outputbackchange
,
yes
,
):
):
"""
"""
Main function
Main function
...
...
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