add docs layout
This commit is contained in:
parent
82526be32d
commit
ffdab7689a
0
docs/.nojekyll
Normal file
0
docs/.nojekyll
Normal file
84
docs/README.md
Normal file
84
docs/README.md
Normal file
@ -0,0 +1,84 @@
|
||||
# Overview
|
||||
|
||||
`embit` is designed to run both on full Python 3 or with [MicroPython](https://micropython.org/) on embedded devices. It uses [libsecp256k1](https://github.com/bitcoin-core/secp256k1) maintained by [Bitcoin Core](https://bitcoincore.org/) team for elliptic curve operations, and everything else is implemented in python.
|
||||
|
||||
## Supported features:
|
||||
|
||||
- [BIP-39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki), [BIP-32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) key derivation (API docs: [bip39](./api/bip39.md), [bip32](./api/bip32.md))
|
||||
- parsing and signing [PSBT](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki) transactions - both version 1 and 2 ([API docs](./api/psbt.md))
|
||||
- signing with custom SIGHASH flags
|
||||
- Descriptors and miniscript support ([API docs](./api/descriptor.md))
|
||||
- SLIP-39 Shamir Secret Sharing scheme (experimental, [API docs](./api/slip39.md))
|
||||
- Liquid network support (experimental, [API docs](./api/liquid/README.md))
|
||||
- Taproot support (in progress, experimental)
|
||||
|
||||
## Installation
|
||||
|
||||
Python:
|
||||
```sh
|
||||
pip3 install embit
|
||||
```
|
||||
|
||||
Micropython: requires custom build with C bindings to hashlib and secp256k1. Docs TBD, see examples for now: [stm32](https://github.com/diybitcoinhardware/f469-disco), [RiscV](https://github.com/stepansnigirev/MaixPy), [esp32](https://github.com/stepansnigirev/esp32_embit)
|
||||
|
||||
## Basic usage
|
||||
|
||||
This script generates bip39 recovery phrase, converts it to the root key, derives native segwit xpub, prints first 5 receiving addresses, parses PSBT transaction and signs it.
|
||||
|
||||
We use `hexlify` and `%s` formatting to keep it compatible with MicroPython, if you use Python3 you can use `.hex()` and f-strings.
|
||||
|
||||
For more details check out the [API docs](./api/README.md)
|
||||
|
||||
```python
|
||||
from embit import bip32, bip39
|
||||
from embit.psbt import PSBT
|
||||
from embit.descriptor import Descriptor
|
||||
from binascii import hexlify
|
||||
|
||||
# Generate mnemonic from 16 bytes of entropy (use real entropy here!):
|
||||
mnemonic = bip39.mnemonic_from_bytes(b"128 bits is fine")
|
||||
# >>> couple mushroom amount shadow nuclear define like common call crew fortune slice
|
||||
|
||||
# Generate root privkey, password can be omitted if you don't want it
|
||||
seed = bip39.mnemonic_to_seed(mnemonic, password="my bip39 password")
|
||||
root = bip32.HDKey.from_seed(seed)
|
||||
|
||||
# Derive and convert to pubkey
|
||||
xpub = root.derive("m/84h/0h/0h").to_public()
|
||||
|
||||
# Generate native segwit descriptors.
|
||||
# You can use {0,1} for combined receive and change descriptors
|
||||
desc = Descriptor.from_string("wpkh([%s/84h/0h/0h]%s/{0,1}/*)" % (hexlify(root.my_fingerprint).decode(), xpub))
|
||||
|
||||
# Print first 5 addresses
|
||||
for i in range(5):
|
||||
print(desc.derive(i).address())
|
||||
|
||||
# parse base64-encoded PSBT transaction
|
||||
psbt = PSBT.from_string("cHNidP8BAHECAAAAAaW9Cd1X07XEcA/D0XmE5dwI2AEQr4aTTTwBqopD1mxAAAAAAAD9////AvJJXQUAAAAAFgAUUa2Cs4u5XOmDFhwNxl/szK5L9beAlpgAAAAAABYAFCwSoUTerJLG437IpfbWF8DgWx6kAAAAAAABAHECAAAAATVenbXof59P6l5N+BxpXQytbyWp29JfJDyT+OwohRWKAAAAAAD+////AgDh9QUAAAAAFgAUgmkBPePxvl4jTWsuNNnypKngm824IKMwAAAAABYAFOiPQIZGLU3UZ8JugMpHcCwxmUK2zQEAAAEBHwDh9QUAAAAAFgAUgmkBPePxvl4jTWsuNNnypKngm80iBgPHS/KrcrFXnxQ0/kvZeBkmEsQGjBLEc5JRUjzP9yVXVhhnwyp0VAAAgAAAAIAAAACAAAAAAAAAAAAAIgIC9jzRiRyPDoZ5F2xMV/QfW6qma/6i0PtyELYn8YR5PjsYZ8MqdFQAAIAAAACAAAAAgAEAAAAAAAAAAAA=")
|
||||
|
||||
# only print outputs that are not change
|
||||
for out in psbt.outputs:
|
||||
if not desc.owns(out):
|
||||
print("Send %d to %s" % (out.value, out.script_pubkey.address()))
|
||||
# print fee
|
||||
print("fee: %d" % psbt.fee())
|
||||
|
||||
# sign psbt and print it
|
||||
psbt.sign_with(root)
|
||||
print(psbt)
|
||||
|
||||
```
|
||||
|
||||
## Projects using embit
|
||||
|
||||
### Hardware wallets
|
||||
|
||||
- [Specter-DIY](https://github.com/cryptoadvance/specter-diy) - airgapped hardware wallet on STM32F469NI-Discovery board (STM32)
|
||||
- [SeedSigner](https://github.com/SeedSigner/seedsigner) - airgapped hardware wallet on Raspberry Pi Zero
|
||||
- [krux](https://github.com/jreesun/krux) - airgapped hardware wallet on M5StickV developer board (RiscV)
|
||||
|
||||
### Software wallets
|
||||
|
||||
- [Specter-Desktop](https://github.com/cryptoadvance/specter-desktop)
|
||||
- [LNBits](https://github.com/lnbits/lnbits/tree/master/lnbits/extensions/watchonly) watch only extension
|
||||
6
docs/_sidebar.md
Normal file
6
docs/_sidebar.md
Normal file
@ -0,0 +1,6 @@
|
||||
<!-- docs/_sidebar.md -->
|
||||
|
||||
* [Overview](/README.md)
|
||||
* [Tutorial](/tutorial/README.md)
|
||||
* [API docs](/api/README.md)
|
||||
* [Recepies](/recepies/README.md)
|
||||
32
docs/api/README.md
Normal file
32
docs/api/README.md
Normal file
@ -0,0 +1,32 @@
|
||||
# Overview
|
||||
|
||||
Library is splitted into modules, list of modules sorted by topic:
|
||||
|
||||
**Keys:**
|
||||
|
||||
- [ec](./ec.md) - individual elliptic curve keys (`PrivateKey`, `PublicKey`) and signatures (`Signature`, `SchnorrSig`)
|
||||
- [bip39](./bip39.md) - helper functions for mnemonics
|
||||
- [bip32](./bip32.md) - extended private and public keys (`HDKey`)
|
||||
|
||||
**Scripts:**
|
||||
|
||||
- [script](./script.md) - basic bitcoin scripts (`Script`) and helper functions
|
||||
- [descriptor](./descriptor/README.md) - descriptors (`Descriptor`) and miniscript functions
|
||||
|
||||
**Transactions:**
|
||||
|
||||
- [transaction](./transaction.md) - raw transactions (`Transaction`)
|
||||
- [psbt](./psbt.md) - psbt transactions (`PSBT`)
|
||||
- [psbtview](./psbtview.md) - RAM-optimized pbst transaction for embedded devices, doesn't read the whole transaction to memory but only gets the part you need right now (`PSBTView`)
|
||||
|
||||
**Helpers:**
|
||||
|
||||
- [networks](./networks.md) - constants for different Bitcoin networks
|
||||
- [base58](./base58.md) encoding - used for WIFs and legacy addresses
|
||||
- [bech32](./bech32.md) encoding - used for segwit and taproot addresses
|
||||
- [compact](./compact.md) - often used for serializations
|
||||
- [hashes](./hashes.md) - common bitcoin hash functions like `tagged_hash`, `double_sha256` etc
|
||||
|
||||
**Extensions / experimental:**
|
||||
- [liquid](./liquid/README.md) - support for confidential assets, liquid transactions, blinded descriptors and psets (elements version of psbt)
|
||||
- [slip39](./slip39.md) - shamir secret sharing scheme
|
||||
20
docs/api/_sidebar.md
Normal file
20
docs/api/_sidebar.md
Normal file
@ -0,0 +1,20 @@
|
||||
<!-- docs/api/_sidebar.md -->
|
||||
|
||||
- [Overview](/README.md)
|
||||
- [Tutorial](/tutorial/README.md)
|
||||
- [API docs](/api/README.md)
|
||||
- [ec](/api/ec.md)
|
||||
- [bip39](/api/bip39.md)
|
||||
- [bip32](/api/bip32.md)
|
||||
- [descriptor](/api/descriptor/README.md)
|
||||
- [script](/api/script.md)
|
||||
- [transaction](/api/transaction.md)
|
||||
- [psbt](/api/psbt.md)
|
||||
- [psbtview](/api/psbtview.md)
|
||||
- [base58](/api/base58.md)
|
||||
- [bech32](/api/bech32.md)
|
||||
- [compact](/api/compact.md)
|
||||
- [hashes](/api/hashes.md)
|
||||
- [liquid](/api/liquid/README.md)
|
||||
- [slip39](/api/slip39.md)
|
||||
- [Recepies](/recepies/README.md)
|
||||
1
docs/api/base58.md
Normal file
1
docs/api/base58.md
Normal file
@ -0,0 +1 @@
|
||||
# Base58 encoding
|
||||
1
docs/api/bech32.md
Normal file
1
docs/api/bech32.md
Normal file
@ -0,0 +1 @@
|
||||
# Bech32 encoding
|
||||
1
docs/api/bip32.md
Normal file
1
docs/api/bip32.md
Normal file
@ -0,0 +1 @@
|
||||
# BIP-32 key derivation
|
||||
1
docs/api/bip39.md
Normal file
1
docs/api/bip39.md
Normal file
@ -0,0 +1 @@
|
||||
# BIP-39 mnemonics
|
||||
1
docs/api/compact.md
Normal file
1
docs/api/compact.md
Normal file
@ -0,0 +1 @@
|
||||
# Compact (varint)
|
||||
1
docs/api/descriptor/README.md
Normal file
1
docs/api/descriptor/README.md
Normal file
@ -0,0 +1 @@
|
||||
# Descriptors and miniscript
|
||||
1
docs/api/ec.md
Normal file
1
docs/api/ec.md
Normal file
@ -0,0 +1 @@
|
||||
# Ellictic curve keys and signatures
|
||||
1
docs/api/hashes.md
Normal file
1
docs/api/hashes.md
Normal file
@ -0,0 +1 @@
|
||||
# Hash functions
|
||||
1
docs/api/liquid/README.md
Normal file
1
docs/api/liquid/README.md
Normal file
@ -0,0 +1 @@
|
||||
# Liquid network
|
||||
1
docs/api/psbt.md
Normal file
1
docs/api/psbt.md
Normal file
@ -0,0 +1 @@
|
||||
# PSBT transactions
|
||||
1
docs/api/psbtview.md
Normal file
1
docs/api/psbtview.md
Normal file
@ -0,0 +1 @@
|
||||
# PSBTView - RAM-efficient PSBT class
|
||||
1
docs/api/script.md
Normal file
1
docs/api/script.md
Normal file
@ -0,0 +1 @@
|
||||
# Scripts
|
||||
1
docs/api/slip39.md
Normal file
1
docs/api/slip39.md
Normal file
@ -0,0 +1 @@
|
||||
# Shamir Secret Sharing scheme
|
||||
1
docs/api/transaction.md
Normal file
1
docs/api/transaction.md
Normal file
@ -0,0 +1 @@
|
||||
# Transactions
|
||||
34
docs/index.html
Normal file
34
docs/index.html
Normal file
@ -0,0 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>embit - Bitcoin library for Python3 and MicroPython</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||
<meta name="description" content="Description">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/lib/themes/vue.css">
|
||||
<style type="text/css">
|
||||
:root {
|
||||
--base-font-size: 14px;
|
||||
--theme-color : #4a90e2;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script>
|
||||
window.$docsify = {
|
||||
name: 'embit',
|
||||
repo: 'https://github.com/diybitcoinhardware/embit',
|
||||
loadSidebar: true,
|
||||
subMaxLevel: 2,
|
||||
auto2top: true,
|
||||
relativePath: true,
|
||||
}
|
||||
</script>
|
||||
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-bash.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-python.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/npm/docsify-copy-code"></script>
|
||||
</body>
|
||||
</html>
|
||||
1
docs/recepies/README.md
Normal file
1
docs/recepies/README.md
Normal file
@ -0,0 +1 @@
|
||||
# Recepies
|
||||
1
docs/tutorial/README.md
Normal file
1
docs/tutorial/README.md
Normal file
@ -0,0 +1 @@
|
||||
# Tutorial
|
||||
Loading…
Reference in New Issue
Block a user