Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Bitcoin Telegram Bot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
s2191814
Bitcoin Telegram Bot
Merge requests
!2
Draft: initial user flow for creating a wallet
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Draft: initial user flow for creating a wallet
2-implement_all_user_flows
into
main
Overview
0
Commits
15
Pipelines
0
Changes
8
Merged
Janssen, D.D. (Dylan, Student M-CS)
requested to merge
2-implement_all_user_flows
into
main
2 years ago
Overview
0
Commits
15
Pipelines
0
Changes
4
Expand
0
0
Merge request reports
Compare
version 4
version 10
21b050f4
2 years ago
version 9
f73478e6
2 years ago
version 8
bfd7caaf
2 years ago
version 7
3f8c69f2
2 years ago
version 6
36de0216
2 years ago
version 5
7c250728
2 years ago
version 4
3284b37e
2 years ago
version 3
57d53bce
2 years ago
version 2
23a9380b
2 years ago
version 1
e0427c56
2 years ago
main (base)
and
version 7
latest version
c078ae8e
15 commits,
2 years ago
version 10
21b050f4
14 commits,
2 years ago
version 9
f73478e6
13 commits,
2 years ago
version 8
bfd7caaf
12 commits,
2 years ago
version 7
3f8c69f2
11 commits,
2 years ago
version 6
36de0216
10 commits,
2 years ago
version 5
7c250728
9 commits,
2 years ago
version 4
3284b37e
8 commits,
2 years ago
version 3
57d53bce
7 commits,
2 years ago
version 2
23a9380b
6 commits,
2 years ago
version 1
e0427c56
1 commit,
2 years ago
Show latest version
4 files
+
115
−
41
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
commands.py
+
42
−
14
Options
import
os
from
bitcoinlib.keys
import
HDKey
from
telegram
import
Update
from
telegram.ext
import
CallbackContext
from
bitcoinlib.wallets
import
Wallet
from
util
import
DBManager
from
commands.general
import
start
,
back
from
commands.transaction
import
transaction_address
,
transaction_amount
,
transaction_fee
,
send_a_transaction
,
show_sign_transaction
from
commands.wallet
import
enter_co_signers
,
minimum_co_signers
,
name_wallet
,
wallet_options
,
create_wallet
,
choose_wallet
from
database
import
AppUser
dbmanager
=
DBManager
()
def
callback_handler
(
update
:
Update
,
context
:
CallbackContext
):
query
=
update
.
callback_query
.
data
try
:
f
=
COMMANDS
[
query
]
f
(
update
,
context
)
except
KeyError
:
# Current state does not have a message handler, so do nothing
# Try the message handler, to go to state function
message_handler
(
update
,
context
)
pass
def
start
(
update
:
Update
,
context
:
CallbackContext
):
context
.
bot
.
send_message
(
chat_id
=
update
.
effective_chat
.
id
,
text
=
"
I
'
m a bot, please talk to me!
"
)
def
message_handler
(
update
:
Update
,
context
:
CallbackContext
):
telegram_user
=
update
.
effective_user
user
,
created
=
AppUser
.
get_or_create
(
telegram_id
=
telegram_user
.
id
,
nickname
=
telegram_user
.
full_name
)
state_user
=
user
.
state_id
.
id
HANDLERS
=
{
2
:
enter_co_signers
,
3
:
minimum_co_signers
,
4
:
name_wallet
,
5
:
wallet_options
,
7
:
transaction_address
,
8
:
transaction_amount
,
9
:
transaction_fee
}
try
:
f
=
HANDLERS
[
state_user
]
f
(
update
,
context
,
user
)
except
KeyError
:
# Current state does not have a message handler, so do nothing
pass
def
create_wallet
(
update
:
Update
,
context
:
CallbackContext
):
key
=
HDKey
(
network
=
os
.
getenv
(
"
BTC_NETWORK
"
))
print
(
dbmanager
.
db_uri
)
wallet
=
Wallet
.
create
(
'
MyWallet1
'
,
keys
=
[
key
],
network
=
os
.
getenv
(
"
BTC_NETWORK
"
),
db_uri
=
dbmanager
.
db_uri
)
print
(
wallet
)
context
.
bot
.
send_message
(
chat_id
=
update
.
effective_chat
.
id
,
text
=
"
Wallet is created
"
)
COMMANDS
=
{
"
start
"
:
start
,
"
create_a_wallet
"
:
create_wallet
,
"
send_a_transaction
"
:
send_a_transaction
,
"
back
"
:
back
,
"
choose_wallet
"
:
choose_wallet
,
"
sign_transaction
"
:
show_sign_transaction
}
Loading