BitPurseBot - a self-custody opensource Bitcoin wallet within Telegram.
-
You have yarn installed
-
You have bot registered via @BotFather
-
Clone this repository:
git clone https://github.com/DavisDmitry/BitPurseBot
-
Install dependencies
yarn
-
Copy
.env.example
as.env
cp .env.example .env
-
Make the app public available
yarn expose
-
Edit your
.env
(see Configuration). -
Build
yarn build
-
Set webhook url (replace
<VALUE>
with values from Configuration)curl -d "url=<PUBLIC_APP_URL>/api/bot&secret_token=<WEBHOOK_SECRET>" -X POST https://api.telegram.org/bot<BOT_TOKEN>/setWebhook
-
Run
yarn preview
Everything is configured using environment variables. All settings can be divided into two types:
- Static (build time)
- Dynamic (runtime)
PUBLIC_NET
: Bitcoin network (main
ortest
) - staticPUBLIC_BOT_USERNAME
: Username of your bot (without@
) - staticPUBLIC_APP_URL
: Base path of your mini app - staticmust start with
https://
BOT_TOKEN
: Token of your bot - dynamicYou can get it from @BotFather
WEBHOOK_SECRET
: Secret token for webhooks from Telegram Bot API - dynamicPB_URL
: PocketBase backend URL - dynamic, optional (set empty string if you don't need it)PB_EMAIL
: PocketBase admin email - dynamic, required ifPB_URL
provided (set empty string if you don't need it)PB_PASSWORD
: PocketBase admin password - dynamic, required ifPB_URL
provided (set empty string if you don't need it)
If you want to save bot users to a database, you can run the PocketBase backend. But this is not necessary, the bot will work without it.
-
Apply migrations (stored in
pb_migrations
)./pocketbase migrate
-
Start the web server
./pocketbase server
-
Go to PocketBase admin UI and setup admin account
-
Configure
PB_*
variables in your.env
BitPurseBot can be deployed like any other SvelteKit application. See SvelteKit documentation
WASM code for signing transactions has already been compiled (stored in static
). You can also compile it yourself if you have Zig installed
yarn build-zig
-
Scanning a QR-code:
src/routes/wallet/send/+page.svelte
-
Popups, closing confirmation
-
Dynamic theme changing:
src/routes/+layout.ts
-
Main button
-
Back button
-
Haptic feedback
Since I had a little time to develop, the functionality of BitPurseBot is quite limited at the moment.
-
BIP-44 and BIP-84 have been partially implemented. BitPurseBot creates a hierarchy of keys, but uses only one account and one key for incoming transactions and change (
m/84'/0'/0'/0/0
for mainnet,m/84'/1'/0'/0/0
for testnet) -
Only one address type can be created: Native SegWit (bech32)
-
Only one type of outgoing transactions is supported: P2WPKH (native SegWit)
-
The seed phrase cannot be imported and is generated randomly when the Mini App is first launched
-
The seed phrase is stored in localStorage (wallet's TON Space does the same, but has the ability to make a cloud backup)
Because of all this, the mainnet version has not yet been launched.