depolymerization

wire gateway for Bitcoin/Ethereum
Log | Files | Refs | Submodules | README | LICENSE

commit 7e7e391dd80ac43e49cd25998e46a6012b1767d4
parent c96993db49c23c56ad3120db51a59a398a50aa7f
Author: Antoine A <>
Date:   Wed,  9 Mar 2022 11:53:09 +0100

Improve documentation

Diffstat:
MREADME.md | 49++++++++++++++++++++++++++++++++-----------------
Mbtc-wire/README.md | 8++++----
Mcommon/src/currency.rs | 6+++---
Mdocs/presentation.tex | 14+++++++-------
Mdocs/taler-btc-full.conf | 2+-
Mdocs/taler-btc-min.conf | 2+-
Mdocs/taler-eth-full.conf | 2+-
Mdocs/taler-eth-min.conf | 2+-
Minstrumentation/README.md | 2+-
Muri-pack/README.md | 16+++++++---------
Mwire-gateway/README.md | 26++++++++------------------
11 files changed, 66 insertions(+), 63 deletions(-)

diff --git a/README.md b/README.md @@ -61,12 +61,27 @@ DB_URL = ___ `PAYTO` is to be added after wallet initialization. +### Currency + +Unlike Bitcoin or Ethereum, we differentiate currencies between networks. The +following currencies are supported: + +- Bitcoin currencies (btc-wire): + - BITCOINBTC for main network + - TESTBTC for test network + - DEVBTC for regtest network +- Ethereum currencies (eth-wire): + - ETHEREUMETH for main network + - TESTROPSTENETH for ropsten network + - DEV_ETH for dev network + ### btc-wire btc-wire will automatically read the bitcoin configuration file to connect to the RPC server. Two flags are mandatory: -- `txindex=1`: btc-wire need access to transaction not linked to the wire wallet +- `txindex=1`: btc-wire needs access to transactions not linked to the wire + wallet - `maxtxfee=?`: bitcoin transactions fees can exceed taler wire fees, putting your wire in bankruptcy. You must specify an acceptable transaction fee cap. @@ -109,8 +124,8 @@ AUTH_TOKEN = ### Process lifetime You may want to restart depolymerization processes regularly to improve -stability (ex. fix memory fragmentation). It is possible to configure lifetime -that trigger graceful shutdown every time a specific amount of work have been +stability (ex. fix memory fragmentation). It is possible to configure a lifetime +that triggers a graceful shutdown every time a specific amount of work has been done. ```ini @@ -123,10 +138,10 @@ WIRE_LIFETIME = 0 ### Stuck transaction -When a transaction is sent with a fee too small compared to other transaction, -it can take an unlimited amount of time for this transaction to be mined. It is -possible to replace this transaction with another transaction with more fees. -Depolymerizer can be configured to do this automatically: +When we send a transaction with a fee too small, it may not be confirmed in a +timely fashion. To unstuck those transactions, it is possible to replace them +with other transactions with more fees. Depolymerizer can be configured to do +this automatically: ```ini [depolymerizer-___] @@ -158,11 +173,11 @@ BUMP_DELAY = 0 2. Start geth 3. Start PostgreSQL 4. Choose account password -4. Initialize database `eth-wire initdb` -5. Initialize wallet `eth-wire initwallet` -6. Update configuration files with wallet info -7. Run wire-gateway `wire-gateway` -8. Run eth-wire `eth-wire` +5. Initialize database `eth-wire initdb` +6. Initialize wallet `eth-wire initwallet` +7. Update configuration files with wallet info +8. Run wire-gateway `wire-gateway` +9. Run eth-wire `eth-wire` ## NGINX TODO @@ -174,7 +189,7 @@ server { } ``` -or +or ``` server { @@ -186,11 +201,11 @@ server { ## Security -Depolymerizer only use encrypted wallet, and provide an easy way to create them. -However, it is the administrator responsibility to backup its wallet and +Depolymerizer only use an encrypted wallet and provide an easy way to create +them. It is the administrator's responsibility to back up its wallet and password. -Only the wire adapter need to have the password stored in its environnement. +Only the wire adapter need to have the password stored in its environment. ## Test @@ -205,7 +220,7 @@ The following binaries need to be in the local user PATH: You can use the [prepare](script/prepare.sh) script to downloads and extract blockchain binaries and find the path of the local postgres installation. -However taler binaries need to be compiled from source for now. +However, taler binaries need to be compiled from source for now. ``` make test diff --git a/btc-wire/README.md b/btc-wire/README.md @@ -10,15 +10,15 @@ addresses to encode the reserve public key as metadata into a common bitcoin transaction. A single segwit address can contain 20B of chosen data and the reserve pub key -is 32B. We use two fake adresses consisting of the two key half prepended with -the same random pattern, at the exception of the first bit with must be 0 for -the first half and 1 for the second one. You must then send a single transaction +is 32B. We use two fake addresses consisting of the two key halves prepended +with the same random pattern, except for the first bit which must be 0 for the +first half and 1 for the second one. You must then send a single transaction with the three addresses as recipients. Segwit addresses are encoded using a bitcoin specific format: [bech32](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki) -As a few lines of code can carry more meaning that many words, you can find a +As a few lines of code can carry more meaning than many words, you can find a [simple rust example](src/bin/segwit-demo.rs) in this project and run it with `make segwit_demo`. diff --git a/common/src/currency.rs b/common/src/currency.rs @@ -16,12 +16,12 @@ use std::str::FromStr; -pub const MAIN_ETH: &str = "ETHEREUMETH"; -pub const ROPSTEN_ETH: &str = "TESTROPSTENETH"; -pub const DEV_ETH: &str = "DEVETH"; pub const MAIN_BTC: &str = "BITCOINBTC"; pub const REGTEST_BTC: &str = "TESTBTC"; pub const TESTNET_BTC: &str = "DEVBTC"; +pub const MAIN_ETH: &str = "ETHEREUMETH"; +pub const ROPSTEN_ETH: &str = "TESTROPSTENETH"; +pub const DEV_ETH: &str = "DEVETH"; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Currency { diff --git a/docs/presentation.tex b/docs/presentation.tex @@ -155,9 +155,9 @@ \begin{frame}{Challenges} \begin{block}{Taler Metadata} \begin{itemize} - \item Metadata are required to link a wallet to credits and - allow merchant to link deposits to debits - \item Putting metadata in blockchain transactions can be tricky + \item Metadata are required to link a wallet to credits and + allow merchant to link deposits to debits + \item Putting metadata in blockchain transactions can be tricky \end{itemize} \end{block} \begin{block}{Blockchain based cryptocurrencies} @@ -233,8 +233,8 @@ \caption{Bitcoin average transaction fee over 6 months {\tiny (ychart)}} } \end{figure} - \only<1>{When we trigger a debit with a fee too small, it may no be - confirmed in timely fashion.} + \only<1>{When we trigger a debit with a fee too small, it may not be + confirmed in a timely fashion.} \only<2>{However, transaction fees are unpredictable.} \end{frame} @@ -483,8 +483,8 @@ \end{frame} \begin{frame}{Conclusion} - Blockchains can be used as a settlement layer for GNU Taler - with Depolymerizer. + Blockchains can be used as a settlement layer for GNU Taler + with Depolymerizer. \begin{itemize} \item [$-$] Trust exchange operator or auditors diff --git a/docs/taler-btc-full.conf b/docs/taler-btc-full.conf @@ -6,7 +6,7 @@ CURRENCY = BITCOINBTC BASE_URL = http://test.com [depolymerizer-bitcoin] -DB_URL = postgres://%2Fvar%2Frun%2Fpostgresql/btc-wire +DB_URL = postgres://%2Fvar%2Frun%2Fpostgresql/btc-wire?user=depolymerization PAYTO = payto://bitcoin/bc1qcr40fzphnh4mcwlv65kvdam4dxq977t2rn54qx AUTH_METHOD = basic AUTH_TOKEN = YWRtaW46cGFzc3dvcmQ= diff --git a/docs/taler-btc-min.conf b/docs/taler-btc-min.conf @@ -6,6 +6,6 @@ CURRENCY = BITCOINBTC BASE_URL = http://test.com [depolymerizer-bitcoin] -DB_URL = postgres://%2Fvar%2Frun%2Fpostgresql/btc-wire +DB_URL = postgres://%2Fvar%2Frun%2Fpostgresql/btc-wire?user=depolymerization PAYTO = payto://bitcoin/bc1qcr40fzphnh4mcwlv65kvdam4dxq977t2rn54qx AUTH_METHOD = none diff --git a/docs/taler-eth-full.conf b/docs/taler-eth-full.conf @@ -6,7 +6,7 @@ CURRENCY = ETHEREUMETH BASE_URL = http://test.com [depolymerizer-ethereum] -DB_URL = postgres://%2Fvar%2Frun%2Fpostgresql/eth-wire +DB_URL = postgres://%2Fvar%2Frun%2Fpostgresql/eth-wire?user=depolymerization PAYTO = payto://ethereum/425870d7b77ad5665ca982ff85c398222a70fe7c AUTH_METHOD = basic AUTH_TOKEN = YWRtaW46cGFzc3dvcmQ= diff --git a/docs/taler-eth-min.conf b/docs/taler-eth-min.conf @@ -6,6 +6,6 @@ CURRENCY = ETHEREUMETH BASE_URL = http://test.com [depolymerizer-ethereum] -DB_URL = postgres://%2Fvar%2Frun%2Fpostgresql/eth-wire +DB_URL = postgres://%2Fvar%2Frun%2Fpostgresql/eth-wire?user=depolymerization PAYTO = payto://ethereum/425870d7b77ad5665ca982ff85c398222a70fe7c AUTH_METHOD = none diff --git a/instrumentation/README.md b/instrumentation/README.md @@ -1,7 +1,7 @@ # Depolymerizer instrumentation test Unit tests running on a private development network are meant to test the good -behavior in case of extreme situation but do not attest our capacity to handle +behavior in case of extreme situations but do not attest our capacity to handle real network behavior. ## Install diff --git a/uri-pack/README.md b/uri-pack/README.md @@ -4,21 +4,20 @@ uri-pack is an efficient probabilistic binary encoding for URI ## Encoding -Most commonly used characters (a-z . / - %) are encoded using 5b, remaining -ascii characters are encoded using 11b. If more than half the characters in an -uri are encoded with 5b, the encoded size is smaller than a simple ascii -format. +Most commonly used characters (a-z . / - %) are encoded using 5b, remaining +ASCII characters are encoded using 11b. If more than half the characters in a +URI are encoded with 5b, the encoded size is smaller than a simple ASCII format. -On the majestic_million database, 98.77% of the domain name where smaller, -going from an average encoded size of 14B in ASCII to 10B using our format +On the majestic_million database, 98.77% of the domain name were smaller, going +from an average encoded size of 14B in ASCII to 10B using our format. ## Usage -``` rust +```rust use uri_pack::{pack_uri, unpack_uri}; let domain = "http://example.com/static_file/image.png"; let encoded = pack_uri(domain).unwrap(); let decoded = unpack_uri(&encoded).unwrap(); assert_eq!(domain, decoded); -``` -\ No newline at end of file +``` diff --git a/wire-gateway/README.md b/wire-gateway/README.md @@ -1,23 +1,12 @@ # wire-gateway -Rust server for [Taler Wire Gateway HTTP API](https://docs.taler.net/core/api-wire.html) - -## Install - -`cargo install --path wire-gateway` - -## Configuration - -``` ini -# taler.conf - wire-gateway config -[depolymerizer-___] -PORT = 8080 -UNIXPATH = -``` +Rust server for +[Taler Wire Gateway HTTP API](https://docs.taler.net/core/api-wire.html) ## Database schema -The server is wire implementation agnostic, it only require an postgres database with following schema: +The server is wire implementation agnostic, it only require an postgres database +with following schema: ```sql -- Key value state @@ -45,6 +34,8 @@ CREATE TABLE tx_out ( debit_acc TEXT NOT NULL, credit_acc TEXT NOT NULL, exchange_url TEXT NOT NULL, - request_uid BYTEA NOT NULL UNIQUE + request_uid BYTEA UNIQUE ); -``` -\ No newline at end of file +``` + +Implementation specific schema can be found in the [db](../db) directory.