mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-13 12:33:25 +02:00
Compare commits
32 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6af6126c39 | ||
|
|
7fdb9d996c | ||
|
|
bfc746ce0d | ||
|
|
90c0b93a90 | ||
|
|
0181eafe74 | ||
|
|
7c67145f61 | ||
|
|
a92ad92042 | ||
|
|
a024057f1b | ||
|
|
93da9c0c97 | ||
|
|
e805751bdc | ||
|
|
2cabb8197a | ||
|
|
e66377a3c9 | ||
|
|
6ff3f3c4c9 | ||
|
|
aef32d9417 | ||
|
|
2d55668af0 | ||
|
|
afd3af091a | ||
|
|
a8ebf8e9e9 | ||
|
|
cb0598cbe5 | ||
|
|
163837a7bc | ||
|
|
0c0ce30006 | ||
|
|
9e1ec67381 | ||
|
|
be90a06973 | ||
|
|
ed360ff3d1 | ||
|
|
80155f1fb7 | ||
|
|
a2eec82e28 | ||
|
|
348353cd43 | ||
|
|
1dd94e58cf | ||
|
|
5231850d13 | ||
|
|
c09ab3f209 | ||
|
|
ad779182d7 | ||
|
|
28acf6f4fc | ||
|
|
098daa08bf |
58 changed files with 810 additions and 19482 deletions
|
|
@ -18,9 +18,7 @@ RUN pip install --upgrade pip
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy the source code.
|
# Copy the source code.
|
||||||
COPY squeaknode ./squeaknode
|
COPY . .
|
||||||
COPY proto ./proto
|
|
||||||
COPY LICENSE MANIFEST.in README.md requirements.txt setup.cfg setup.py ./
|
|
||||||
|
|
||||||
RUN pip install .[postgres]
|
RUN pip install .[postgres]
|
||||||
|
|
||||||
|
|
|
||||||
18
README.md
18
README.md
|
|
@ -33,16 +33,16 @@ The protocol is defined [here](https://github.com/yzernik/squeak/blob/master/doc
|
||||||
* a Tor SOCKS5 proxy (you can open Tor Browser and run it in the background)
|
* a Tor SOCKS5 proxy (you can open Tor Browser and run it in the background)
|
||||||
|
|
||||||
### Step 1. Create the configuration
|
### Step 1. Create the configuration
|
||||||
> Update the **config.ini** file and fill in the relevant sections to connect to your Bitcoin node and LND node:
|
> Create a **config.ini** file and fill in the relevant sections to connect to your Bitcoin node and LND node:
|
||||||
|
|
||||||
```
|
```
|
||||||
[node]
|
[node]
|
||||||
network=mainnet
|
network=mainnet
|
||||||
|
|
||||||
[lnd]
|
[lightning]
|
||||||
host=localhost
|
backend=lnd
|
||||||
tls_cert_path=~/.lnd/tls.cert
|
lnd_tls_cert_path=~/.lnd/tls.cert
|
||||||
macaroon_path=~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon
|
lnd_macaroon_path=~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon
|
||||||
|
|
||||||
[bitcoin]
|
[bitcoin]
|
||||||
rpc_host=localhost
|
rpc_host=localhost
|
||||||
|
|
@ -60,6 +60,14 @@ username=devuser
|
||||||
password=devpass
|
password=devpass
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you want to use [c-lightning](https://github.com/ElementsProject/lightning) as the Lightning Network node backend instead of [LND](https://github.com/lightningnetwork/lnd), replace the `lightning` section with the following:
|
||||||
|
|
||||||
|
```
|
||||||
|
[lightning]
|
||||||
|
backend=clightning
|
||||||
|
clightning_rpc_file=~/.lightning/lightning-rpc
|
||||||
|
```
|
||||||
|
|
||||||
Add any other [configs](docs/configuration.md) that you need.
|
Add any other [configs](docs/configuration.md) that you need.
|
||||||
|
|
||||||
### Step 2. Install squeaknode:
|
### Step 2. Install squeaknode:
|
||||||
|
|
|
||||||
20
clightning-config.ini
Normal file
20
clightning-config.ini
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
[node]
|
||||||
|
network=testnet
|
||||||
|
|
||||||
|
[lightning]
|
||||||
|
backend=clightning
|
||||||
|
|
||||||
|
[bitcoin]
|
||||||
|
rpc_host=localhost
|
||||||
|
rpc_port=18332
|
||||||
|
rpc_user=devuser
|
||||||
|
rpc_pass=devpass
|
||||||
|
|
||||||
|
[tor]
|
||||||
|
proxy_ip=localhost
|
||||||
|
proxy_port=9150
|
||||||
|
|
||||||
|
[webadmin]
|
||||||
|
enabled=true
|
||||||
|
username=devuser
|
||||||
|
password=devpass
|
||||||
29
config-other.ini
Normal file
29
config-other.ini
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
[node]
|
||||||
|
network=testnet
|
||||||
|
sqk_dir_path=/home/yzernik/.sqk-other
|
||||||
|
|
||||||
|
[lightning]
|
||||||
|
external_host=localhost
|
||||||
|
lnd_rpc_host=localhost
|
||||||
|
lnd_rpc_port=10003
|
||||||
|
lnd_tls_cert_path=/home/yzernik/.polar/networks/1/volumes/lnd/alice/tls.cert
|
||||||
|
lnd_macaroon_path=/home/yzernik/.polar/networks/1/volumes/lnd/alice/data/chain/bitcoin/regtest/admin.macaroon
|
||||||
|
|
||||||
|
[bitcoin]
|
||||||
|
rpc_host=localhost
|
||||||
|
rpc_port=18445
|
||||||
|
rpc_user=polaruser
|
||||||
|
rpc_pass=polarpass
|
||||||
|
|
||||||
|
[tor]
|
||||||
|
proxy_ip=localhost
|
||||||
|
proxy_port=9150
|
||||||
|
|
||||||
|
[webadmin]
|
||||||
|
enabled=true
|
||||||
|
username=devuser
|
||||||
|
password=devpass
|
||||||
|
port=12995
|
||||||
|
|
||||||
|
[server]
|
||||||
|
port=18558
|
||||||
17
config.ini
17
config.ini
|
|
@ -1,17 +1,18 @@
|
||||||
[node]
|
[node]
|
||||||
network=testnet
|
network=testnet
|
||||||
|
|
||||||
[lnd]
|
[lightning]
|
||||||
host=localhost
|
external_host=localhost
|
||||||
tls_cert_path=~/.lnd/tls.cert
|
lnd_rpc_host=localhost
|
||||||
macaroon_path=~/.lnd/data/chain/bitcoin/testnet/admin.macaroon
|
lnd_rpc_port=10004
|
||||||
|
lnd_tls_cert_path=/home/yzernik/.polar/networks/1/volumes/lnd/bob/tls.cert
|
||||||
|
lnd_macaroon_path=/home/yzernik/.polar/networks/1/volumes/lnd/bob/data/chain/bitcoin/regtest/admin.macaroon
|
||||||
|
|
||||||
[bitcoin]
|
[bitcoin]
|
||||||
rpc_host=localhost
|
rpc_host=localhost
|
||||||
rpc_port=18332
|
rpc_port=18445
|
||||||
rpc_user=devuser
|
rpc_user=polaruser
|
||||||
rpc_pass=devpass
|
rpc_pass=polarpass
|
||||||
zeromq_hashblock_port=28334
|
|
||||||
|
|
||||||
[tor]
|
[tor]
|
||||||
proxy_ip=localhost
|
proxy_ip=localhost
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
FROM golang:1.12-alpine as builder
|
FROM golang:1.18-alpine as builder
|
||||||
|
|
||||||
MAINTAINER Olaoluwa Osuntokun <laolu@lightning.network>
|
MAINTAINER Olaoluwa Osuntokun <laolu@lightning.network>
|
||||||
|
|
||||||
|
|
|
||||||
25
docker/config-clightning.ini
Normal file
25
docker/config-clightning.ini
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
[node]
|
||||||
|
network=testnet
|
||||||
|
|
||||||
|
[lightning]
|
||||||
|
backend=clightning
|
||||||
|
external_host=clightning_server
|
||||||
|
external_port=19735
|
||||||
|
|
||||||
|
[clightning]
|
||||||
|
enabled=true
|
||||||
|
|
||||||
|
[bitcoin]
|
||||||
|
rpc_host=bitcoin-core
|
||||||
|
rpc_port=18332
|
||||||
|
rpc_user=devuser
|
||||||
|
rpc_pass=devpass
|
||||||
|
|
||||||
|
[tor]
|
||||||
|
proxy_ip=tor-node
|
||||||
|
proxy_port=9050
|
||||||
|
|
||||||
|
[webadmin]
|
||||||
|
enabled=true
|
||||||
|
username=devuser
|
||||||
|
password=devpass
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
[node]
|
[node]
|
||||||
network=testnet
|
network=testnet
|
||||||
|
|
||||||
[lnd]
|
[lightning]
|
||||||
host=lnd
|
lnd_rpc_host=lnd
|
||||||
tls_cert_path=~/.lnd/tls.cert
|
external_host=lnd
|
||||||
macaroon_path=~/.lnd/data/chain/bitcoin/testnet/admin.macaroon
|
lnd_tls_cert_path=~/.lnd/tls.cert
|
||||||
|
lnd_macaroon_path=~/.lnd/data/chain/bitcoin/testnet/admin.macaroon
|
||||||
|
|
||||||
[bitcoin]
|
[bitcoin]
|
||||||
rpc_host=bitcoin-core
|
rpc_host=bitcoin-core
|
||||||
rpc_port=18332
|
rpc_port=18332
|
||||||
rpc_user=devuser
|
rpc_user=devuser
|
||||||
rpc_pass=devpass
|
rpc_pass=devpass
|
||||||
zeromq_hashblock_port=28334
|
|
||||||
|
|
||||||
[tor]
|
[tor]
|
||||||
proxy_ip=tor-node
|
proxy_ip=tor-node
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,16 @@ services:
|
||||||
environment:
|
environment:
|
||||||
- NETWORK=mainnet
|
- NETWORK=mainnet
|
||||||
|
|
||||||
|
clightning_client:
|
||||||
|
command:
|
||||||
|
- --bitcoin-rpcconnect=bitcoin-core
|
||||||
|
- --bitcoin-rpcuser=devuser
|
||||||
|
- --bitcoin-rpcpassword=devpass
|
||||||
|
- --network=mainnet
|
||||||
|
- --plugin-dir=/usr/libexec/c-lightning/plugins
|
||||||
|
- --alias=myitestnode
|
||||||
|
- --log-level=debug
|
||||||
|
|
||||||
# squeaknode:
|
# squeaknode:
|
||||||
# environment:
|
# environment:
|
||||||
# - NETWORK=mainnet
|
# - NETWORK=mainnet
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,32 @@ services:
|
||||||
-zmqpubhashblock=tcp://0.0.0.0:28334
|
-zmqpubhashblock=tcp://0.0.0.0:28334
|
||||||
-zmqpubhashtx=tcp://0.0.0.0:28334
|
-zmqpubhashtx=tcp://0.0.0.0:28334
|
||||||
|
|
||||||
|
clightning_client:
|
||||||
|
command:
|
||||||
|
- --bitcoin-rpcconnect=bitcoin-core
|
||||||
|
- --bitcoin-rpcuser=devuser
|
||||||
|
- --bitcoin-rpcpassword=devpass
|
||||||
|
- --network=testnet
|
||||||
|
- --plugin-dir=/usr/libexec/c-lightning/plugins
|
||||||
|
- --alias=myclientningclient
|
||||||
|
- --log-level=debug
|
||||||
|
- --rpc-file=/root/.lightning/lightning-rpc
|
||||||
|
- --rpc-file-mode=0777
|
||||||
|
- --proxy=tor-node:9050
|
||||||
|
|
||||||
|
clightning_server:
|
||||||
|
command:
|
||||||
|
- --bitcoin-rpcconnect=bitcoin-core
|
||||||
|
- --bitcoin-rpcuser=devuser
|
||||||
|
- --bitcoin-rpcpassword=devpass
|
||||||
|
- --network=testnet
|
||||||
|
- --plugin-dir=/usr/libexec/c-lightning/plugins
|
||||||
|
- --alias=myclientningserver
|
||||||
|
- --log-level=debug
|
||||||
|
- --rpc-file=/root/.lightning/lightning-rpc
|
||||||
|
- --rpc-file-mode=0777
|
||||||
|
- --proxy=tor-node:9050
|
||||||
|
|
||||||
# squeaknode:
|
# squeaknode:
|
||||||
# environment:
|
# environment:
|
||||||
# - NETWORK=testnet
|
# - NETWORK=testnet
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ services:
|
||||||
image: ruimarinho/bitcoin-core:0.21.1
|
image: ruimarinho/bitcoin-core:0.21.1
|
||||||
container_name: bitcoin-core
|
container_name: bitcoin-core
|
||||||
volumes:
|
volumes:
|
||||||
- ~/.bitcoin:/home/bitcoin/.bitcoin
|
- bitcoin:/home/bitcoin/.bitcoin
|
||||||
ports:
|
ports:
|
||||||
- 8332:8332
|
- 8332:8332
|
||||||
- 18332:18332
|
- 18332:18332
|
||||||
|
|
@ -25,7 +25,7 @@ services:
|
||||||
depends_on:
|
depends_on:
|
||||||
- "tor-node"
|
- "tor-node"
|
||||||
volumes:
|
volumes:
|
||||||
- ~/.lnd:/root/.lnd
|
- lnd_client_dir:/root/.lnd
|
||||||
- tor-dir:/var/lib/tor
|
- tor-dir:/var/lib/tor
|
||||||
ports:
|
ports:
|
||||||
- 10009:10009
|
- 10009:10009
|
||||||
|
|
@ -57,6 +57,45 @@ services:
|
||||||
- net.ipv6.conf.all.disable_ipv6=0
|
- net.ipv6.conf.all.disable_ipv6=0
|
||||||
entrypoint: ["./start-lnd.sh"]
|
entrypoint: ["./start-lnd.sh"]
|
||||||
|
|
||||||
|
clightning_client:
|
||||||
|
image: elementsproject/lightningd:v0.11.0.1
|
||||||
|
container_name: clightning_client
|
||||||
|
expose:
|
||||||
|
- "9735"
|
||||||
|
- "19735"
|
||||||
|
- "9835"
|
||||||
|
- "10009"
|
||||||
|
ports:
|
||||||
|
- 10010:10009
|
||||||
|
- 9835:9835
|
||||||
|
volumes:
|
||||||
|
- clightning_client_dir:/root/.lightning
|
||||||
|
- tor-dir:/var/lib/tor
|
||||||
|
links:
|
||||||
|
- "bitcoin-core:bitcoin-core"
|
||||||
|
depends_on:
|
||||||
|
- "tor-node"
|
||||||
|
sysctls:
|
||||||
|
- net.ipv6.conf.all.disable_ipv6=0
|
||||||
|
|
||||||
|
clightning_server:
|
||||||
|
image: elementsproject/lightningd:v0.11.0.1
|
||||||
|
container_name: clightning_server
|
||||||
|
expose:
|
||||||
|
- "9735"
|
||||||
|
- "19735"
|
||||||
|
- "9835"
|
||||||
|
- "10009"
|
||||||
|
volumes:
|
||||||
|
- clightning_server_dir:/root/.lightning
|
||||||
|
- tor-dir:/var/lib/tor
|
||||||
|
links:
|
||||||
|
- "bitcoin-core:bitcoin-core"
|
||||||
|
depends_on:
|
||||||
|
- "tor-node"
|
||||||
|
sysctls:
|
||||||
|
- net.ipv6.conf.all.disable_ipv6=0
|
||||||
|
|
||||||
tor-node:
|
tor-node:
|
||||||
image: osminogin/tor-simple
|
image: osminogin/tor-simple
|
||||||
container_name: tor-node
|
container_name: tor-node
|
||||||
|
|
@ -89,10 +128,42 @@ services:
|
||||||
- net.ipv6.conf.all.disable_ipv6=0
|
- net.ipv6.conf.all.disable_ipv6=0
|
||||||
entrypoint: ["./entrypoint.sh"]
|
entrypoint: ["./entrypoint.sh"]
|
||||||
|
|
||||||
|
squeaknode_clightning:
|
||||||
|
image: squeaknode
|
||||||
|
container_name: squeaknode_clightning
|
||||||
|
build:
|
||||||
|
context: ../
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
depends_on:
|
||||||
|
- "lnd_server"
|
||||||
|
volumes:
|
||||||
|
- clightning_server_dir:/root/.lightning
|
||||||
|
- squeaknode_clightning_dir:/root/.sqk
|
||||||
|
- ./config-clightning.ini:/config.ini
|
||||||
|
ports:
|
||||||
|
- 18558:18555
|
||||||
|
- 12996:12994
|
||||||
|
links:
|
||||||
|
- "bitcoin-core:bitcoin-core"
|
||||||
|
- "lnd_server:lnd"
|
||||||
|
sysctls:
|
||||||
|
- net.ipv6.conf.all.disable_ipv6=0
|
||||||
|
entrypoint: ["./entrypoint.sh"]
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
|
bitcoin:
|
||||||
|
driver: local
|
||||||
|
lnd_client_dir:
|
||||||
|
driver: local
|
||||||
lnd_server_dir:
|
lnd_server_dir:
|
||||||
driver: local
|
driver: local
|
||||||
|
clightning_client_dir:
|
||||||
|
driver: local
|
||||||
|
clightning_server_dir:
|
||||||
|
driver: local
|
||||||
squeaknode_dir:
|
squeaknode_dir:
|
||||||
driver: local
|
driver: local
|
||||||
|
squeaknode_clightning_dir:
|
||||||
|
driver: local
|
||||||
tor-dir:
|
tor-dir:
|
||||||
driver: local
|
driver: local
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,14 @@ bitcoin.rpc_user | string | | yes | "" | SQUEAKNODE_BITCOIN_RPC_USER | The usern
|
||||||
bitcoin.rpc_pass | string | | yes | "" | SQUEAKNODE_BITCOIN_RPC_PASS | The password to use for authentication on the bitcoin node.
|
bitcoin.rpc_pass | string | | yes | "" | SQUEAKNODE_BITCOIN_RPC_PASS | The password to use for authentication on the bitcoin node.
|
||||||
bitcoin.rpc_use_ssl | boolean | [true, false] | yes | false | SQUEAKNODE_BITCOIN_USE_SSL | Use SSL for the connection to the bitcoin node.
|
bitcoin.rpc_use_ssl | boolean | [true, false] | yes | false | SQUEAKNODE_BITCOIN_USE_SSL | Use SSL for the connection to the bitcoin node.
|
||||||
bitcoin.rpc_ssl_cert | str | | yes | "" | SQUEAKNODE_BITCOIN_SSL_CERT | The path to the SSL cert to use for connection to the bitcoin node, if one is used.
|
bitcoin.rpc_ssl_cert | str | | yes | "" | SQUEAKNODE_BITCOIN_SSL_CERT | The path to the SSL cert to use for connection to the bitcoin node, if one is used.
|
||||||
bitcoin.zeromq_hashblock_port | int | | yes | 28334 | SQUEAKNODE_BITCOIN_ZEROMQ_HASHBLOCK_PORT | The port to use to subscribe with zeromq to new block hashes on the bitcoin node.
|
lightning.backend | string | | yes | "lnd" | SQUEAKNODE_LIGHTNING_BACKEND | The Lightning Network node implementation to use.
|
||||||
lnd.host | string | | yes | "localhost" | SQUEAKNODE_LND_HOST | The host of the LND node to connect.
|
lightning.external_host | string | | yes | "" | SQUEAKNODE_LIGHTNING_EXTERNAL_HOST | The host of the lightning node to share with other peers.
|
||||||
lnd.external_host | string | | yes | "" | SQUEAKNODE_LND_EXTERNAL_HOST | The host of the LND node to share with other peers.
|
lightning.external_port | int | | yes | | SQUEAKNODE_LIGHTNING_EXTERNAL_PORT | The port of the lightning node to share with other peers.
|
||||||
lnd.port | int | | yes | | SQUEAKNODE_LND_PORT | The port of the LND node to use for LND peer connections.
|
lightning.lnd_rpc_host | string | | yes | "localhost" | SQUEAKNODE_LIGHTNING_LND_RPC_HOST | The host of the LND node to connect.
|
||||||
lnd.rpc_port | int | | yes | | SQUEAKNODE_LND_RPC_PORT | The port of the LND node to use for RPC connections.
|
lightning.lnd_rpc_port | int | | yes | | SQUEAKNODE_LIGHTNING_LND_RPC_PORT | The port of the LND node to use for RPC connections.
|
||||||
lnd.tls_cert_path | string | | yes | "" | SQUEAKNODE_LND_TLS_CERT_PATH | The path to the TLS certificate to use for LND connection.
|
lightning.lnd_tls_cert_path | string | | yes | "" | SQUEAKNODE_LIGHTNING_LND_TLS_CERT_PATH | The path to the TLS certificate to use for LND connection.
|
||||||
lnd.macaroon_path | string | | yes | "" | SQUEAKNODE_LND_MACAROON_PATH | The path to the macaroon to use for LND connection.
|
lightning.lnd_macaroon_path | string | | yes | "" | SQUEAKNODE_LIGHTNING_LND_MACAROON_PATH | The path to the macaroon to use for LND connection.
|
||||||
|
lightning.clightning_rpc_file | string | | yes | "" | SQUEAKNODE_LIGHTNING_CLIGHTNING_RPC_FILE | The path to the file to use for c-lightning RPC.
|
||||||
tor.proxy_ip | string | | yes | "" | SQUEAKNODE_TOR_PROXY_IP | The ip address or host of the SOCKS5 Tor proxy, if one is used.
|
tor.proxy_ip | string | | yes | "" | SQUEAKNODE_TOR_PROXY_IP | The ip address or host of the SOCKS5 Tor proxy, if one is used.
|
||||||
tor.proxy_port | int | | yes | 0 | SQUEAKNODE_TOR_PROXY_PORT | The port of the SOCKS5 Tor proxy, is one is used.
|
tor.proxy_port | int | | yes | 0 | SQUEAKNODE_TOR_PROXY_PORT | The port of the SOCKS5 Tor proxy, is one is used.
|
||||||
db.connection_string | string | | yes | "" | SQUEAKNODE_DB_CONNECTION_STRING | The connection string to use to connect to a SQL database. If none is specified, a sqlite database will be used on the local file system.
|
db.connection_string | string | | yes | "" | SQUEAKNODE_DB_CONNECTION_STRING | The connection string to use to connect to a SQL database. If none is specified, a sqlite database will be used on the local file system.
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,9 @@ You can also run your own squeaknode on your host machine.
|
||||||
pip install .
|
pip install .
|
||||||
```
|
```
|
||||||
|
|
||||||
- Make sure that `~/.lnd` directory (created by docker container) has read permissions. You may need to change the permissions:
|
- Copy the `~/.lnd` directory from the docker container to your host machine.
|
||||||
```
|
```
|
||||||
sudo chmod -R 755 ~/.lnd/
|
docker cp lnd_client:/root/.lnd/ ~/.lnd
|
||||||
```
|
```
|
||||||
|
|
||||||
- Run squeaknode with authentication disabled:
|
- Run squeaknode with authentication disabled:
|
||||||
|
|
|
||||||
19371
frontend/package-lock.json
generated
19371
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -12,7 +12,7 @@
|
||||||
"google-protobuf": "^3.12.4",
|
"google-protobuf": "^3.12.4",
|
||||||
"informed": "^4.6.1",
|
"informed": "^4.6.1",
|
||||||
"jwt-decode": "^2.2.0",
|
"jwt-decode": "^2.2.0",
|
||||||
"moment": "^2.29.2",
|
"moment": "^2.29.4",
|
||||||
"react": "^16.13.1",
|
"react": "^16.13.1",
|
||||||
"react-contenteditable": "^3.3.4",
|
"react-contenteditable": "^3.3.4",
|
||||||
"react-copy-to-clipboard": "^5.1.0",
|
"react-copy-to-clipboard": "^5.1.0",
|
||||||
|
|
|
||||||
|
|
@ -165,6 +165,8 @@ import {
|
||||||
GetReceivedPaymentsForPeerReply,
|
GetReceivedPaymentsForPeerReply,
|
||||||
DownloadSqueakSecretKeyRequest,
|
DownloadSqueakSecretKeyRequest,
|
||||||
DownloadSqueakSecretKeyReply,
|
DownloadSqueakSecretKeyReply,
|
||||||
|
RenamePeerRequest,
|
||||||
|
RenamePeerReply,
|
||||||
} from '../proto/squeak_admin_pb';
|
} from '../proto/squeak_admin_pb';
|
||||||
|
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
|
@ -718,8 +720,20 @@ export const getPrivateKey = (id) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getPeer = (network, host, port) => {
|
export const getPeer = (peerId) => {
|
||||||
console.log('Calling getPeer');
|
console.log('Calling getPeer');
|
||||||
|
const request = new GetPeerRequest();
|
||||||
|
request.setPeerId(peerId);
|
||||||
|
const deser = GetPeerReply.deserializeBinary;
|
||||||
|
return baseRequest({
|
||||||
|
url: '/getpeer',
|
||||||
|
req: request,
|
||||||
|
deser: deser,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getPeerByAddress = (network, host, port) => {
|
||||||
|
console.log('Calling getPeerByAddress');
|
||||||
const request = new GetPeerByAddressRequest();
|
const request = new GetPeerByAddressRequest();
|
||||||
const peerAddress = new PeerAddress();
|
const peerAddress = new PeerAddress();
|
||||||
peerAddress.setNetwork(network);
|
peerAddress.setNetwork(network);
|
||||||
|
|
@ -734,6 +748,19 @@ export const getPeer = (network, host, port) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const renamePeer = (peerId, peerName) => {
|
||||||
|
console.log('Calling renamePeer');
|
||||||
|
const request = new RenamePeerRequest();
|
||||||
|
request.setPeerId(peerId);
|
||||||
|
request.setPeerName(peerName);
|
||||||
|
const deser = RenamePeerReply.deserializeBinary;
|
||||||
|
return baseRequest({
|
||||||
|
url: '/renamepeer',
|
||||||
|
req: request,
|
||||||
|
deser: deser,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export const getConnectedPeers = () => {
|
export const getConnectedPeers = () => {
|
||||||
console.log('Calling getConnectedPeers');
|
console.log('Calling getConnectedPeers');
|
||||||
const request = new GetConnectedPeersRequest();
|
const request = new GetConnectedPeersRequest();
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import {
|
||||||
setDeletePeer,
|
setDeletePeer,
|
||||||
setPeerAutoconnectEnabled,
|
setPeerAutoconnectEnabled,
|
||||||
setPeerAutoconnectDisabled,
|
setPeerAutoconnectDisabled,
|
||||||
|
setRenamePeer,
|
||||||
} from '../../features/peers/peersSlice'
|
} from '../../features/peers/peersSlice'
|
||||||
import {
|
import {
|
||||||
fetchPaymentSummaryForPeer,
|
fetchPaymentSummaryForPeer,
|
||||||
|
|
@ -121,13 +122,10 @@ const Peer = (props) => {
|
||||||
|
|
||||||
const editPeer = ({values}) => {
|
const editPeer = ({values}) => {
|
||||||
console.log('Calling editPeer with name:', values.name);
|
console.log('Calling editPeer with name:', values.name);
|
||||||
// TODO: call rename action.
|
dispatch(setRenamePeer({
|
||||||
alert('Rename peer not yet implemented!');
|
peerId: peer.getPeerId(),
|
||||||
// dispatch(setRenameProfile({
|
peerName: values.name,
|
||||||
// peerId: user.getPeerId(),
|
}));
|
||||||
// profileName: editName,
|
|
||||||
// }));
|
|
||||||
// TODO: chain action to update profile squeaks with the new name.
|
|
||||||
setSaved(true)
|
setSaved(true)
|
||||||
toggleEditModal()
|
toggleEditModal()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,17 +61,26 @@ const Peers = (props) => {
|
||||||
return 'IPV4';
|
return 'IPV4';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getExternalAddressStr = () => {
|
||||||
|
if (externalAddress) {
|
||||||
|
return `${externalAddress.getHost()}:${externalAddress.getPort()}`;
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
function removeHttp(url) {
|
function removeHttp(url) {
|
||||||
return url.replace(/^https?:\/\//, '');
|
return url.replace(/^https?:\/\//, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
const savePeer = ({values}) => {
|
const savePeer = ({values}) => {
|
||||||
const network = getNetwork(values.useTor);
|
const network = getNetwork(values.useTor);
|
||||||
const strippedHost = removeHttp(values.host);
|
const strippedAddress = removeHttp(values.address);
|
||||||
|
const url = new URL(`http://${strippedAddress}`);
|
||||||
dispatch(setSavePeer({
|
dispatch(setSavePeer({
|
||||||
name: values.name,
|
name: values.name,
|
||||||
host: strippedHost,
|
host: url.hostname,
|
||||||
port: values.port,
|
port: url.port,
|
||||||
network: network,
|
network: network,
|
||||||
}));
|
}));
|
||||||
toggleSavePeerModal();
|
toggleSavePeerModal();
|
||||||
|
|
@ -92,8 +101,7 @@ const Peers = (props) => {
|
||||||
</div>
|
</div>
|
||||||
<div className="edit-input-wrap">
|
<div className="edit-input-wrap">
|
||||||
<Input class="informed-input" name="name" label="Peer Name (not required)" />
|
<Input class="informed-input" name="name" label="Peer Name (not required)" />
|
||||||
<Input class="informed-input" name="host" label="Host" />
|
<Input class="informed-input" name="address" label="Address (host:port)" />
|
||||||
<Input class="informed-input" name="port" type="number" label="Port" />
|
|
||||||
<Checkbox class="informed-input" name="useTor" label="Connect With Tor: " />
|
<Checkbox class="informed-input" name="useTor" label="Connect With Tor: " />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -119,32 +127,14 @@ const Peers = (props) => {
|
||||||
<div class="float-container">
|
<div class="float-container">
|
||||||
<div class="float-child">
|
<div class="float-child">
|
||||||
<div className="edit-input-wrap">
|
<div className="edit-input-wrap">
|
||||||
<Input class="informed-input" name="host" label="Host" initialValue={externalAddress && externalAddress.getHost()} readOnly />
|
<Input class="informed-input" name="external-address" label="External Address" initialValue={externalAddress && `${getExternalAddressStr()}`} readOnly />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="float-child">
|
<div class="float-child">
|
||||||
<CopyToClipboard
|
<CopyToClipboard
|
||||||
text={externalAddress && externalAddress.getHost()}
|
text={externalAddress && `${getExternalAddressStr()}`}
|
||||||
>
|
>
|
||||||
<a data-tip="Copy host">
|
<a data-tip="Copy address">
|
||||||
<button fullWidth={false}>
|
|
||||||
<ICON_CLIPBOARD />
|
|
||||||
</button>
|
|
||||||
</a>
|
|
||||||
</CopyToClipboard>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="float-container">
|
|
||||||
<div class="float-child">
|
|
||||||
<div className="edit-input-wrap">
|
|
||||||
<Input class="informed-input" name="port" label="Port" initialValue={externalAddress && externalAddress.getPort()} readOnly/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="float-child">
|
|
||||||
<CopyToClipboard
|
|
||||||
text={externalAddress && externalAddress.getPort()}
|
|
||||||
>
|
|
||||||
<a data-tip="Copy port">
|
|
||||||
<button fullWidth={false}>
|
<button fullWidth={false}>
|
||||||
<ICON_CLIPBOARD />
|
<ICON_CLIPBOARD />
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,14 @@ import {
|
||||||
} from '@reduxjs/toolkit'
|
} from '@reduxjs/toolkit'
|
||||||
import {
|
import {
|
||||||
getPeer,
|
getPeer,
|
||||||
|
getPeerByAddress,
|
||||||
getConnectedPeers,
|
getConnectedPeers,
|
||||||
connectPeer,
|
connectPeer,
|
||||||
disconnectPeer,
|
disconnectPeer,
|
||||||
getSavedPeers,
|
getSavedPeers,
|
||||||
savePeer,
|
savePeer,
|
||||||
deletePeer,
|
deletePeer,
|
||||||
|
renamePeer,
|
||||||
enableAutoconnectPeer,
|
enableAutoconnectPeer,
|
||||||
disableAutoconnectPeer,
|
disableAutoconnectPeer,
|
||||||
} from '../../api/client'
|
} from '../../api/client'
|
||||||
|
|
@ -37,7 +39,7 @@ export const fetchPeer = createAsyncThunk(
|
||||||
let network = values.network;
|
let network = values.network;
|
||||||
let host = values.host;
|
let host = values.host;
|
||||||
let port = values.port;
|
let port = values.port;
|
||||||
const response = await getPeer(
|
const response = await getPeerByAddress(
|
||||||
network,
|
network,
|
||||||
host,
|
host,
|
||||||
port,
|
port,
|
||||||
|
|
@ -153,6 +155,22 @@ export const setPeerAutoconnectDisabled = createAsyncThunk(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
export const setRenamePeer = createAsyncThunk(
|
||||||
|
'profile/setRenamePeer',
|
||||||
|
async (values) => {
|
||||||
|
console.log('Renaming peer');
|
||||||
|
console.log(values.peerId);
|
||||||
|
console.log(values.peerName);
|
||||||
|
let peerId = values.peerId;
|
||||||
|
let peerName = values.peerName;
|
||||||
|
await renamePeer(peerId, peerName);
|
||||||
|
console.log('Getting renamed peer');
|
||||||
|
const response = await getPeer(peerId);
|
||||||
|
console.log(response);
|
||||||
|
return response.getSqueakPeer();
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
const peersSlice = createSlice({
|
const peersSlice = createSlice({
|
||||||
name: 'peers',
|
name: 'peers',
|
||||||
|
|
@ -262,6 +280,14 @@ const peersSlice = createSlice({
|
||||||
state.currentPeer = newSavedPeer;
|
state.currentPeer = newSavedPeer;
|
||||||
state.savedPeers = newSavedPeers;
|
state.savedPeers = newSavedPeers;
|
||||||
})
|
})
|
||||||
|
.addCase(setRenamePeer.pending, (state, action) => {
|
||||||
|
state.currentPeerStatus = 'loading'
|
||||||
|
})
|
||||||
|
.addCase(setRenamePeer.fulfilled, (state, action) => {
|
||||||
|
const newPeer = action.payload;
|
||||||
|
state.currentPeer = newPeer;
|
||||||
|
state.currentPeerStatus = 'idle';
|
||||||
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1267,13 +1267,32 @@
|
||||||
"@types/yargs" "^16.0.0"
|
"@types/yargs" "^16.0.0"
|
||||||
chalk "^4.0.0"
|
chalk "^4.0.0"
|
||||||
|
|
||||||
|
"@jridgewell/gen-mapping@^0.3.0":
|
||||||
|
version "0.3.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9"
|
||||||
|
dependencies:
|
||||||
|
"@jridgewell/set-array" "^1.0.1"
|
||||||
|
"@jridgewell/sourcemap-codec" "^1.4.10"
|
||||||
|
"@jridgewell/trace-mapping" "^0.3.9"
|
||||||
|
|
||||||
"@jridgewell/resolve-uri@^3.0.3":
|
"@jridgewell/resolve-uri@^3.0.3":
|
||||||
version "3.0.5"
|
version "3.1.0"
|
||||||
resolved "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.0.5.tgz"
|
resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78"
|
||||||
|
|
||||||
|
"@jridgewell/set-array@^1.0.1":
|
||||||
|
version "1.1.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72"
|
||||||
|
|
||||||
|
"@jridgewell/source-map@^0.3.2":
|
||||||
|
version "0.3.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.2.tgz#f45351aaed4527a298512ec72f81040c998580fb"
|
||||||
|
dependencies:
|
||||||
|
"@jridgewell/gen-mapping" "^0.3.0"
|
||||||
|
"@jridgewell/trace-mapping" "^0.3.9"
|
||||||
|
|
||||||
"@jridgewell/sourcemap-codec@^1.4.10":
|
"@jridgewell/sourcemap-codec@^1.4.10":
|
||||||
version "1.4.11"
|
version "1.4.14"
|
||||||
resolved "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.11.tgz"
|
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24"
|
||||||
|
|
||||||
"@jridgewell/trace-mapping@^0.3.0":
|
"@jridgewell/trace-mapping@^0.3.0":
|
||||||
version "0.3.4"
|
version "0.3.4"
|
||||||
|
|
@ -1282,6 +1301,13 @@
|
||||||
"@jridgewell/resolve-uri" "^3.0.3"
|
"@jridgewell/resolve-uri" "^3.0.3"
|
||||||
"@jridgewell/sourcemap-codec" "^1.4.10"
|
"@jridgewell/sourcemap-codec" "^1.4.10"
|
||||||
|
|
||||||
|
"@jridgewell/trace-mapping@^0.3.9":
|
||||||
|
version "0.3.14"
|
||||||
|
resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.14.tgz#b231a081d8f66796e475ad588a1ef473112701ed"
|
||||||
|
dependencies:
|
||||||
|
"@jridgewell/resolve-uri" "^3.0.3"
|
||||||
|
"@jridgewell/sourcemap-codec" "^1.4.10"
|
||||||
|
|
||||||
"@leichtgewicht/ip-codec@^2.0.1":
|
"@leichtgewicht/ip-codec@^2.0.1":
|
||||||
version "2.0.3"
|
version "2.0.3"
|
||||||
resolved "https://registry.npmjs.org/@leichtgewicht/ip-codec/-/ip-codec-2.0.3.tgz"
|
resolved "https://registry.npmjs.org/@leichtgewicht/ip-codec/-/ip-codec-2.0.3.tgz"
|
||||||
|
|
@ -2038,8 +2064,8 @@ acorn@^7.0.0, acorn@^7.1.1:
|
||||||
resolved "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz"
|
resolved "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz"
|
||||||
|
|
||||||
acorn@^8.2.4, acorn@^8.4.1, acorn@^8.5.0, acorn@^8.7.0:
|
acorn@^8.2.4, acorn@^8.4.1, acorn@^8.5.0, acorn@^8.7.0:
|
||||||
version "8.7.0"
|
version "8.7.1"
|
||||||
resolved "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz"
|
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.1.tgz#0197122c843d1bf6d0a5e83220a788f278f63c30"
|
||||||
|
|
||||||
address@^1.0.1, address@^1.1.2:
|
address@^1.0.1, address@^1.1.2:
|
||||||
version "1.1.2"
|
version "1.1.2"
|
||||||
|
|
@ -2139,7 +2165,7 @@ ansi-styles@^4.0.0:
|
||||||
|
|
||||||
ansi-styles@^4.1.0:
|
ansi-styles@^4.1.0:
|
||||||
version "4.3.0"
|
version "4.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937"
|
resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz"
|
||||||
dependencies:
|
dependencies:
|
||||||
color-convert "^2.0.1"
|
color-convert "^2.0.1"
|
||||||
|
|
||||||
|
|
@ -2237,13 +2263,13 @@ ast-types-flow@^0.0.7:
|
||||||
|
|
||||||
async@^2.6.2:
|
async@^2.6.2:
|
||||||
version "2.6.4"
|
version "2.6.4"
|
||||||
resolved "https://registry.yarnpkg.com/async/-/async-2.6.4.tgz#706b7ff6084664cd7eae713f6f965433b5504221"
|
resolved "https://registry.npmjs.org/async/-/async-2.6.4.tgz"
|
||||||
dependencies:
|
dependencies:
|
||||||
lodash "^4.17.14"
|
lodash "^4.17.14"
|
||||||
|
|
||||||
async@^3.2.3:
|
async@^3.2.3:
|
||||||
version "3.2.3"
|
version "3.2.3"
|
||||||
resolved "https://registry.yarnpkg.com/async/-/async-3.2.3.tgz#ac53dafd3f4720ee9e8a160628f18ea91df196c9"
|
resolved "https://registry.npmjs.org/async/-/async-3.2.3.tgz"
|
||||||
|
|
||||||
asynckit@^0.4.0:
|
asynckit@^0.4.0:
|
||||||
version "0.4.0"
|
version "0.4.0"
|
||||||
|
|
@ -2416,8 +2442,8 @@ backo2@1.0.2:
|
||||||
resolved "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz"
|
resolved "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz"
|
||||||
|
|
||||||
balanced-match@^1.0.0:
|
balanced-match@^1.0.0:
|
||||||
version "1.0.2"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
|
resolved "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz"
|
||||||
|
|
||||||
base64-arraybuffer@0.1.4:
|
base64-arraybuffer@0.1.4:
|
||||||
version "0.1.4"
|
version "0.1.4"
|
||||||
|
|
@ -2438,7 +2464,7 @@ bfj@^7.0.2:
|
||||||
|
|
||||||
big.js@^5.2.2:
|
big.js@^5.2.2:
|
||||||
version "5.2.2"
|
version "5.2.2"
|
||||||
resolved "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz"
|
resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328"
|
||||||
|
|
||||||
binary-extensions@^2.0.0:
|
binary-extensions@^2.0.0:
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
|
|
@ -2495,14 +2521,14 @@ boxen@5.1.2:
|
||||||
|
|
||||||
brace-expansion@^1.1.7:
|
brace-expansion@^1.1.7:
|
||||||
version "1.1.11"
|
version "1.1.11"
|
||||||
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
|
resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz"
|
||||||
dependencies:
|
dependencies:
|
||||||
balanced-match "^1.0.0"
|
balanced-match "^1.0.0"
|
||||||
concat-map "0.0.1"
|
concat-map "0.0.1"
|
||||||
|
|
||||||
brace-expansion@^2.0.1:
|
brace-expansion@^2.0.1:
|
||||||
version "2.0.1"
|
version "2.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae"
|
resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz"
|
||||||
dependencies:
|
dependencies:
|
||||||
balanced-match "^1.0.0"
|
balanced-match "^1.0.0"
|
||||||
|
|
||||||
|
|
@ -2534,7 +2560,7 @@ bser@2.1.1:
|
||||||
|
|
||||||
buffer-from@^1.0.0:
|
buffer-from@^1.0.0:
|
||||||
version "1.1.2"
|
version "1.1.2"
|
||||||
resolved "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz"
|
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5"
|
||||||
|
|
||||||
builtin-modules@^3.1.0:
|
builtin-modules@^3.1.0:
|
||||||
version "3.2.0"
|
version "3.2.0"
|
||||||
|
|
@ -2717,7 +2743,7 @@ color-convert@^1.9.0:
|
||||||
|
|
||||||
color-convert@^2.0.1:
|
color-convert@^2.0.1:
|
||||||
version "2.0.1"
|
version "2.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3"
|
resolved "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz"
|
||||||
dependencies:
|
dependencies:
|
||||||
color-name "~1.1.4"
|
color-name "~1.1.4"
|
||||||
|
|
||||||
|
|
@ -2727,7 +2753,7 @@ color-name@1.1.3:
|
||||||
|
|
||||||
color-name@^1.1.4, color-name@~1.1.4:
|
color-name@^1.1.4, color-name@~1.1.4:
|
||||||
version "1.1.4"
|
version "1.1.4"
|
||||||
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
|
resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz"
|
||||||
|
|
||||||
colord@^2.9.1:
|
colord@^2.9.1:
|
||||||
version "2.9.2"
|
version "2.9.2"
|
||||||
|
|
@ -2745,7 +2771,7 @@ combined-stream@^1.0.8:
|
||||||
|
|
||||||
commander@^2.20.0:
|
commander@^2.20.0:
|
||||||
version "2.20.3"
|
version "2.20.3"
|
||||||
resolved "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz"
|
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
|
||||||
|
|
||||||
commander@^7.2.0:
|
commander@^7.2.0:
|
||||||
version "7.2.0"
|
version "7.2.0"
|
||||||
|
|
@ -2811,7 +2837,7 @@ compression@^1.7.4:
|
||||||
|
|
||||||
concat-map@0.0.1:
|
concat-map@0.0.1:
|
||||||
version "0.0.1"
|
version "0.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz"
|
||||||
|
|
||||||
confusing-browser-globals@^1.0.11:
|
confusing-browser-globals@^1.0.11:
|
||||||
version "1.0.11"
|
version "1.0.11"
|
||||||
|
|
@ -3151,8 +3177,8 @@ decimal.js@^10.2.1:
|
||||||
resolved "https://registry.npmjs.org/decimal.js/-/decimal.js-10.3.1.tgz"
|
resolved "https://registry.npmjs.org/decimal.js/-/decimal.js-10.3.1.tgz"
|
||||||
|
|
||||||
decode-uri-component@^0.2.0:
|
decode-uri-component@^0.2.0:
|
||||||
version "0.2.0"
|
version "0.2.2"
|
||||||
resolved "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz"
|
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.2.tgz#e69dbe25d37941171dd540e024c444cd5188e1e9"
|
||||||
|
|
||||||
dedent@^0.7.0:
|
dedent@^0.7.0:
|
||||||
version "0.7.0"
|
version "0.7.0"
|
||||||
|
|
@ -3361,7 +3387,7 @@ ee-first@1.1.1:
|
||||||
|
|
||||||
ejs@^3.1.6:
|
ejs@^3.1.6:
|
||||||
version "3.1.7"
|
version "3.1.7"
|
||||||
resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.7.tgz#c544d9c7f715783dd92f0bddcf73a59e6962d006"
|
resolved "https://registry.npmjs.org/ejs/-/ejs-3.1.7.tgz"
|
||||||
dependencies:
|
dependencies:
|
||||||
jake "^10.8.5"
|
jake "^10.8.5"
|
||||||
|
|
||||||
|
|
@ -3383,7 +3409,7 @@ emoji-regex@^9.2.2:
|
||||||
|
|
||||||
emojis-list@^3.0.0:
|
emojis-list@^3.0.0:
|
||||||
version "3.0.0"
|
version "3.0.0"
|
||||||
resolved "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz"
|
resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78"
|
||||||
|
|
||||||
encodeurl@~1.0.2:
|
encodeurl@~1.0.2:
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
|
|
@ -3897,7 +3923,7 @@ file-loader@^6.2.0:
|
||||||
|
|
||||||
filelist@^1.0.1:
|
filelist@^1.0.1:
|
||||||
version "1.0.3"
|
version "1.0.3"
|
||||||
resolved "https://registry.yarnpkg.com/filelist/-/filelist-1.0.3.tgz#448607750376484932f67ef1b9ff07386b036c83"
|
resolved "https://registry.npmjs.org/filelist/-/filelist-1.0.3.tgz"
|
||||||
dependencies:
|
dependencies:
|
||||||
minimatch "^5.0.1"
|
minimatch "^5.0.1"
|
||||||
|
|
||||||
|
|
@ -4192,7 +4218,7 @@ has-flag@^3.0.0:
|
||||||
|
|
||||||
has-flag@^4.0.0:
|
has-flag@^4.0.0:
|
||||||
version "4.0.0"
|
version "4.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
|
resolved "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz"
|
||||||
|
|
||||||
has-symbols@^1.0.1, has-symbols@^1.0.2, has-symbols@^1.0.3:
|
has-symbols@^1.0.1, has-symbols@^1.0.2, has-symbols@^1.0.3:
|
||||||
version "1.0.3"
|
version "1.0.3"
|
||||||
|
|
@ -4663,7 +4689,7 @@ istanbul-reports@^3.1.3:
|
||||||
|
|
||||||
jake@^10.8.5:
|
jake@^10.8.5:
|
||||||
version "10.8.5"
|
version "10.8.5"
|
||||||
resolved "https://registry.yarnpkg.com/jake/-/jake-10.8.5.tgz#f2183d2c59382cb274226034543b9c03b8164c46"
|
resolved "https://registry.npmjs.org/jake/-/jake-10.8.5.tgz"
|
||||||
dependencies:
|
dependencies:
|
||||||
async "^3.2.3"
|
async "^3.2.3"
|
||||||
chalk "^4.0.2"
|
chalk "^4.0.2"
|
||||||
|
|
@ -5255,8 +5281,8 @@ loader-runner@^4.2.0:
|
||||||
resolved "https://registry.npmjs.org/loader-runner/-/loader-runner-4.2.0.tgz"
|
resolved "https://registry.npmjs.org/loader-runner/-/loader-runner-4.2.0.tgz"
|
||||||
|
|
||||||
loader-utils@^2.0.0:
|
loader-utils@^2.0.0:
|
||||||
version "2.0.2"
|
version "2.0.3"
|
||||||
resolved "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.2.tgz"
|
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.3.tgz#d4b15b8504c63d1fc3f2ade52d41bc8459d6ede1"
|
||||||
dependencies:
|
dependencies:
|
||||||
big.js "^5.2.2"
|
big.js "^5.2.2"
|
||||||
emojis-list "^3.0.0"
|
emojis-list "^3.0.0"
|
||||||
|
|
@ -5454,21 +5480,21 @@ minimalistic-assert@^1.0.0:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz"
|
resolved "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz"
|
||||||
|
|
||||||
minimatch@3.0.4:
|
minimatch@3.0.4, minimatch@^3.0.4:
|
||||||
version "3.0.4"
|
version "3.0.4"
|
||||||
resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz"
|
resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz"
|
||||||
dependencies:
|
dependencies:
|
||||||
brace-expansion "^1.1.7"
|
brace-expansion "^1.1.7"
|
||||||
|
|
||||||
minimatch@^3.0.4, minimatch@^3.1.2:
|
minimatch@^3.1.2:
|
||||||
version "3.1.2"
|
version "3.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
|
resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz"
|
||||||
dependencies:
|
dependencies:
|
||||||
brace-expansion "^1.1.7"
|
brace-expansion "^1.1.7"
|
||||||
|
|
||||||
minimatch@^5.0.1:
|
minimatch@^5.0.1:
|
||||||
version "5.0.1"
|
version "5.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.0.1.tgz#fb9022f7528125187c92bd9e9b6366be1cf3415b"
|
resolved "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz"
|
||||||
dependencies:
|
dependencies:
|
||||||
brace-expansion "^2.0.1"
|
brace-expansion "^2.0.1"
|
||||||
|
|
||||||
|
|
@ -5482,9 +5508,9 @@ mkdirp@^0.5.5, mkdirp@~0.5.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
minimist "^1.2.6"
|
minimist "^1.2.6"
|
||||||
|
|
||||||
moment@^2.29.2:
|
moment@^2.29.4:
|
||||||
version "2.29.2"
|
version "2.29.4"
|
||||||
resolved "https://registry.npmjs.org/moment/-/moment-2.29.2.tgz"
|
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108"
|
||||||
|
|
||||||
ms@2.0.0:
|
ms@2.0.0:
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
|
|
@ -7262,7 +7288,7 @@ source-map-resolve@^0.5.2:
|
||||||
|
|
||||||
source-map-support@^0.5.6, source-map-support@~0.5.20:
|
source-map-support@^0.5.6, source-map-support@~0.5.20:
|
||||||
version "0.5.21"
|
version "0.5.21"
|
||||||
resolved "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz"
|
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f"
|
||||||
dependencies:
|
dependencies:
|
||||||
buffer-from "^1.0.0"
|
buffer-from "^1.0.0"
|
||||||
source-map "^0.6.0"
|
source-map "^0.6.0"
|
||||||
|
|
@ -7279,7 +7305,7 @@ source-map@^0.5.0:
|
||||||
version "0.5.7"
|
version "0.5.7"
|
||||||
resolved "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz"
|
resolved "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz"
|
||||||
|
|
||||||
source-map@^0.7.3, source-map@~0.7.2:
|
source-map@^0.7.3:
|
||||||
version "0.7.3"
|
version "0.7.3"
|
||||||
resolved "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz"
|
resolved "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz"
|
||||||
|
|
||||||
|
|
@ -7478,7 +7504,7 @@ supports-color@^5.3.0:
|
||||||
|
|
||||||
supports-color@^7.0.0, supports-color@^7.1.0:
|
supports-color@^7.0.0, supports-color@^7.1.0:
|
||||||
version "7.2.0"
|
version "7.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da"
|
resolved "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz"
|
||||||
dependencies:
|
dependencies:
|
||||||
has-flag "^4.0.0"
|
has-flag "^4.0.0"
|
||||||
|
|
||||||
|
|
@ -7602,12 +7628,12 @@ terser-webpack-plugin@^5.1.3, terser-webpack-plugin@^5.2.5:
|
||||||
terser "^5.7.2"
|
terser "^5.7.2"
|
||||||
|
|
||||||
terser@^5.0.0, terser@^5.10.0, terser@^5.7.2:
|
terser@^5.0.0, terser@^5.10.0, terser@^5.7.2:
|
||||||
version "5.12.1"
|
version "5.14.2"
|
||||||
resolved "https://registry.npmjs.org/terser/-/terser-5.12.1.tgz"
|
resolved "https://registry.yarnpkg.com/terser/-/terser-5.14.2.tgz#9ac9f22b06994d736174f4091aa368db896f1c10"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
"@jridgewell/source-map" "^0.3.2"
|
||||||
acorn "^8.5.0"
|
acorn "^8.5.0"
|
||||||
commander "^2.20.0"
|
commander "^2.20.0"
|
||||||
source-map "~0.7.2"
|
|
||||||
source-map-support "~0.5.20"
|
source-map-support "~0.5.20"
|
||||||
|
|
||||||
test-exclude@^6.0.0:
|
test-exclude@^6.0.0:
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@ network=simnet
|
||||||
price_msat=1000000
|
price_msat=1000000
|
||||||
max_squeaks_per_public_key_per_block=50
|
max_squeaks_per_public_key_per_block=50
|
||||||
|
|
||||||
[lnd]
|
[lightning]
|
||||||
host=lnd
|
lnd_rpc_host=lnd
|
||||||
tls_cert_path=/root/.lnd/tls.cert
|
lnd_tls_cert_path=/root/.lnd/tls.cert
|
||||||
macaroon_path=/root/.lnd/data/chain/bitcoin/simnet/admin.macaroon
|
lnd_macaroon_path=/root/.lnd/data/chain/bitcoin/simnet/admin.macaroon
|
||||||
|
|
||||||
[bitcoin]
|
[bitcoin]
|
||||||
rpc_host=btcd
|
rpc_host=btcd
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
client_address=$(docker exec -it test_lnd_client lncli --network=simnet newaddress np2wkh | jq .address -r)
|
client_address=$(docker exec -it test_lnd_client lncli --network=simnet newaddress np2wkh | jq .address -r)
|
||||||
MINING_ADDRESS=$client_address docker-compose up -d btcd
|
MINING_ADDRESS=$client_address docker compose up -d btcd
|
||||||
echo "Mining 1 blocks to address: $client_address ..."
|
echo "Mining 1 blocks to address: $client_address ..."
|
||||||
docker-compose run btcctl generate 400
|
docker compose run btcctl generate 400
|
||||||
sleep 10
|
sleep 10
|
||||||
done
|
done
|
||||||
|
|
|
||||||
|
|
@ -6,16 +6,16 @@ trap "kill 0" EXIT
|
||||||
function mine_blocks {
|
function mine_blocks {
|
||||||
while true; do
|
while true; do
|
||||||
printf "Mining 1 block to address: $MINING_ADDRESS ..."
|
printf "Mining 1 block to address: $MINING_ADDRESS ..."
|
||||||
docker-compose run btcctl generate 1
|
docker compose run btcctl generate 1
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cd itests
|
cd itests
|
||||||
docker-compose down --volumes --remove-orphans
|
docker compose down --volumes --remove-orphans
|
||||||
docker-compose build
|
docker compose build
|
||||||
docker-compose up -d
|
docker compose up -d
|
||||||
|
|
||||||
# Initialize the blockchain with miner rewards going to the test client.
|
# Initialize the blockchain with miner rewards going to the test client.
|
||||||
|
|
||||||
|
|
@ -29,9 +29,9 @@ do
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
|
||||||
MINING_ADDRESS=$client_address docker-compose up -d btcd
|
export MINING_ADDRESS="$client_address docker compose up -d btcd"
|
||||||
echo "Mining 400 blocks to address: $client_address ..."
|
echo "Mining 400 blocks to address: $client_address ..."
|
||||||
docker-compose run btcctl generate 400
|
docker compose run btcctl generate 400
|
||||||
echo "Finished mining blocks."
|
echo "Finished mining blocks."
|
||||||
sleep 30
|
sleep 30
|
||||||
|
|
||||||
|
|
@ -40,7 +40,7 @@ mine_blocks &
|
||||||
echo "Background mining task is in background..."
|
echo "Background mining task is in background..."
|
||||||
|
|
||||||
echo "Running test.sh...."
|
echo "Running test.sh...."
|
||||||
docker-compose run test ./test.sh
|
docker compose run test ./test.sh
|
||||||
|
|
||||||
echo "Shutting down itest..."
|
echo "Shutting down itest..."
|
||||||
# docker-compose down
|
# docker compose down
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ from tests.util import delete_squeak
|
||||||
from tests.util import download_squeak
|
from tests.util import download_squeak
|
||||||
from tests.util import download_squeak_secret_key
|
from tests.util import download_squeak_secret_key
|
||||||
from tests.util import free_price
|
from tests.util import free_price
|
||||||
|
from tests.util import get_balance
|
||||||
from tests.util import get_external_address
|
from tests.util import get_external_address
|
||||||
from tests.util import get_hash
|
from tests.util import get_hash
|
||||||
from tests.util import get_network
|
from tests.util import get_network
|
||||||
|
|
@ -607,6 +608,18 @@ def test_delete_peer(admin_stub, peer_id):
|
||||||
|
|
||||||
def test_send_coins(admin_stub, other_admin_stub):
|
def test_send_coins(admin_stub, other_admin_stub):
|
||||||
new_address_response = admin_stub.LndNewAddress(ln.NewAddressRequest())
|
new_address_response = admin_stub.LndNewAddress(ln.NewAddressRequest())
|
||||||
|
get_balance_response = get_balance(
|
||||||
|
other_admin_stub,
|
||||||
|
)
|
||||||
|
print("Get balance: {}".format(get_balance_response))
|
||||||
|
print("--------------------")
|
||||||
|
print("--------------------")
|
||||||
|
print("--------------------")
|
||||||
|
print("--------------------")
|
||||||
|
print("--------------------")
|
||||||
|
print("--------------------")
|
||||||
|
print("--------------------")
|
||||||
|
print("--------------------", flush=True)
|
||||||
send_coins_response = send_coins(
|
send_coins_response = send_coins(
|
||||||
other_admin_stub, new_address_response.address, 55555555
|
other_admin_stub, new_address_response.address, 55555555
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -437,6 +437,13 @@ def disconnect_peer(node_stub, pubkey):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_balance(node_stub):
|
||||||
|
get_balance_request = lnd_pb2.WalletBalanceRequest()
|
||||||
|
return node_stub.LndWalletBalance(
|
||||||
|
get_balance_request,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def send_coins(node_stub, addr, amount):
|
def send_coins(node_stub, addr, amount):
|
||||||
send_coins_request = lnd_pb2.SendCoinsRequest(
|
send_coins_request = lnd_pb2.SendCoinsRequest(
|
||||||
addr=addr,
|
addr=addr,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
alembic==1.7.1
|
alembic==1.7.1
|
||||||
|
docutils==0.17.1
|
||||||
Flask==2.0.1
|
Flask==2.0.1
|
||||||
flask-cors==3.0.10
|
flask-cors==3.0.10
|
||||||
flask-login==0.5.0
|
flask-login==0.5.0
|
||||||
|
|
@ -7,6 +8,7 @@ googleapis-common-protos==1.53.0
|
||||||
importlib_resources==1.4.0
|
importlib_resources==1.4.0
|
||||||
mypy-protobuf==2.9
|
mypy-protobuf==2.9
|
||||||
protobuf==3.17.3
|
protobuf==3.17.3
|
||||||
|
pyln-client==0.10.1
|
||||||
PySocks==1.7.1
|
PySocks==1.7.1
|
||||||
python-bitcoinlib==0.11.0
|
python-bitcoinlib==0.11.0
|
||||||
pyzmq==22.3.0
|
pyzmq==22.3.0
|
||||||
|
|
|
||||||
|
|
@ -20,4 +20,4 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
|
|
||||||
__version__ = '0.2.22'
|
__version__ = '0.3.5'
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ def create_app(handler, username, password):
|
||||||
|
|
||||||
@login.unauthorized_handler
|
@login.unauthorized_handler
|
||||||
def unauthorized_callback():
|
def unauthorized_callback():
|
||||||
return redirect("/login")
|
return redirect(url_for("login"))
|
||||||
|
|
||||||
def protobuf_serialized(request_message):
|
def protobuf_serialized(request_message):
|
||||||
def decorator(func):
|
def decorator(func):
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,26 @@
|
||||||
{
|
{
|
||||||
"files": {
|
"files": {
|
||||||
"main.css": "/static/css/main.fe6c5463.css",
|
"main.css": "/static/css/main.fe6c5463.css",
|
||||||
"main.js": "/static/js/main.f6f1567b.js",
|
"main.js": "/static/js/main.f8361353.js",
|
||||||
"static/css/306.7f7715a0.chunk.css": "/static/css/306.7f7715a0.chunk.css",
|
"static/css/306.7f7715a0.chunk.css": "/static/css/306.7f7715a0.chunk.css",
|
||||||
"static/js/306.90b2a66c.chunk.js": "/static/js/306.90b2a66c.chunk.js",
|
"static/js/306.90b2a66c.chunk.js": "/static/js/306.90b2a66c.chunk.js",
|
||||||
"static/css/900.5027b0a1.chunk.css": "/static/css/900.5027b0a1.chunk.css",
|
"static/css/900.5027b0a1.chunk.css": "/static/css/900.5027b0a1.chunk.css",
|
||||||
"static/js/900.1b104345.chunk.js": "/static/js/900.1b104345.chunk.js",
|
"static/js/900.1b104345.chunk.js": "/static/js/900.1b104345.chunk.js",
|
||||||
"static/css/841.693c3c31.chunk.css": "/static/css/841.693c3c31.chunk.css",
|
"static/css/841.693c3c31.chunk.css": "/static/css/841.693c3c31.chunk.css",
|
||||||
"static/js/841.9f23f674.chunk.js": "/static/js/841.9f23f674.chunk.js",
|
"static/js/841.91f0aab2.chunk.js": "/static/js/841.91f0aab2.chunk.js",
|
||||||
"static/media/icon.svg": "/static/media/icon.982210ec9275956e4d3cc77fa90167fd.svg",
|
"static/media/icon.svg": "/static/media/icon.982210ec9275956e4d3cc77fa90167fd.svg",
|
||||||
"index.html": "/index.html",
|
"index.html": "/index.html",
|
||||||
"main.fe6c5463.css.map": "/static/css/main.fe6c5463.css.map",
|
"main.fe6c5463.css.map": "/static/css/main.fe6c5463.css.map",
|
||||||
"main.f6f1567b.js.map": "/static/js/main.f6f1567b.js.map",
|
"main.f8361353.js.map": "/static/js/main.f8361353.js.map",
|
||||||
"306.7f7715a0.chunk.css.map": "/static/css/306.7f7715a0.chunk.css.map",
|
"306.7f7715a0.chunk.css.map": "/static/css/306.7f7715a0.chunk.css.map",
|
||||||
"306.90b2a66c.chunk.js.map": "/static/js/306.90b2a66c.chunk.js.map",
|
"306.90b2a66c.chunk.js.map": "/static/js/306.90b2a66c.chunk.js.map",
|
||||||
"900.5027b0a1.chunk.css.map": "/static/css/900.5027b0a1.chunk.css.map",
|
"900.5027b0a1.chunk.css.map": "/static/css/900.5027b0a1.chunk.css.map",
|
||||||
"900.1b104345.chunk.js.map": "/static/js/900.1b104345.chunk.js.map",
|
"900.1b104345.chunk.js.map": "/static/js/900.1b104345.chunk.js.map",
|
||||||
"841.693c3c31.chunk.css.map": "/static/css/841.693c3c31.chunk.css.map",
|
"841.693c3c31.chunk.css.map": "/static/css/841.693c3c31.chunk.css.map",
|
||||||
"841.9f23f674.chunk.js.map": "/static/js/841.9f23f674.chunk.js.map"
|
"841.91f0aab2.chunk.js.map": "/static/js/841.91f0aab2.chunk.js.map"
|
||||||
},
|
},
|
||||||
"entrypoints": [
|
"entrypoints": [
|
||||||
"static/css/main.fe6c5463.css",
|
"static/css/main.fe6c5463.css",
|
||||||
"static/js/main.f6f1567b.js"
|
"static/js/main.f8361353.js"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -1 +1 @@
|
||||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#1da1f2"/><meta nam="description" content="Squeaknode!"/><meta name="og:title" content="Squeaknode"/><meta name="og:description" content="check out my the Squeaknode I made"/><link href="https://fonts.googleapis.com/css2?family=Assistant&display=swap" rel="stylesheet"><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Squeaknode</title><script defer="defer" src="/static/js/main.f6f1567b.js"></script><link href="/static/css/main.fe6c5463.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#1da1f2"/><meta nam="description" content="Squeaknode!"/><meta name="og:title" content="Squeaknode"/><meta name="og:description" content="check out my the Squeaknode I made"/><link href="https://fonts.googleapis.com/css2?family=Assistant&display=swap" rel="stylesheet"><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Squeaknode</title><script defer="defer" src="/static/js/main.f8361353.js"></script><link href="/static/css/main.fe6c5463.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -99,19 +99,16 @@ class PeerClient:
|
||||||
)
|
)
|
||||||
if r.status_code != requests.codes.ok:
|
if r.status_code != requests.codes.ok:
|
||||||
return None
|
return None
|
||||||
logger.info(r)
|
squeak_bytes = r.content
|
||||||
squeak_json = r.json()
|
try:
|
||||||
# squeak_bytes = r.content
|
|
||||||
squeak_type = squeak_json['squeak_type']
|
|
||||||
squeak_bytes_hex = squeak_json['squeak_bytes']
|
|
||||||
squeak_bytes = bytes.fromhex(squeak_bytes_hex)
|
|
||||||
logger.info('Client downloaded: {}'.format(squeak_json))
|
|
||||||
if squeak_type == 'squeak':
|
|
||||||
return CSqueak.deserialize(squeak_bytes)
|
return CSqueak.deserialize(squeak_bytes)
|
||||||
elif squeak_type == 'resqueak':
|
except Exception:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
return CResqueak.deserialize(squeak_bytes)
|
return CResqueak.deserialize(squeak_bytes)
|
||||||
else:
|
except Exception:
|
||||||
return None
|
pass
|
||||||
|
return None
|
||||||
|
|
||||||
def get_secret_key(self, squeak_hash: bytes) -> Optional[bytes]:
|
def get_secret_key(self, squeak_hash: bytes) -> Optional[bytes]:
|
||||||
squeak_hash_str = squeak_hash.hex()
|
squeak_hash_str = squeak_hash.hex()
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ DEFAULT_LOG_LEVEL = "INFO"
|
||||||
DEFAULT_MAX_SQUEAKS = 10000
|
DEFAULT_MAX_SQUEAKS = 10000
|
||||||
DEFAULT_MAX_SQUEAKS_PER_PUBLIC_KEY_PER_BLOCK = 100
|
DEFAULT_MAX_SQUEAKS_PER_PUBLIC_KEY_PER_BLOCK = 100
|
||||||
DEFAULT_SERVER_RPC_HOST = "0.0.0.0"
|
DEFAULT_SERVER_RPC_HOST = "0.0.0.0"
|
||||||
DEFAULT_SERVER_RPC_PORT = None
|
DEFAULT_SERVER_RPC_PORT = 8555
|
||||||
DEFAULT_EXTERNAL_PORT = 8555
|
DEFAULT_EXTERNAL_PORT = 8555
|
||||||
DEFAULT_ADMIN_RPC_HOST = "0.0.0.0"
|
DEFAULT_ADMIN_RPC_HOST = "0.0.0.0"
|
||||||
DEFAULT_ADMIN_RPC_PORT = 8994
|
DEFAULT_ADMIN_RPC_PORT = 8994
|
||||||
|
|
@ -48,17 +48,20 @@ DEFAULT_WEBADMIN_HOST = "0.0.0.0"
|
||||||
DEFAULT_WEBADMIN_PORT = 12994
|
DEFAULT_WEBADMIN_PORT = 12994
|
||||||
DEFAULT_BITCOIN_RPC_HOST = "localhost"
|
DEFAULT_BITCOIN_RPC_HOST = "localhost"
|
||||||
DEFAULT_BITCOIN_RPC_PORT = 18334
|
DEFAULT_BITCOIN_RPC_PORT = 18334
|
||||||
DEFAULT_BITCOIN_ZEROMQ_HASHBLOCK_PORT = 28334
|
|
||||||
BITCOIN_RPC_PORT = {
|
BITCOIN_RPC_PORT = {
|
||||||
"mainnet": 8332,
|
"mainnet": 8332,
|
||||||
"testnet": 18332,
|
"testnet": 18332,
|
||||||
"simnet": 18556,
|
"simnet": 18556,
|
||||||
}
|
}
|
||||||
|
DEFAULT_LIGHTNING_BACKEND = "lnd"
|
||||||
DEFAULT_LND_PORT = 9735
|
DEFAULT_LND_PORT = 9735
|
||||||
DEFAULT_LND_RPC_PORT = 10009
|
DEFAULT_LND_RPC_PORT = 10009
|
||||||
|
DEFAULT_CLIGHTNING_DIR = ".lightning"
|
||||||
|
DEFAULT_CLIGHTNING_RPC_FILE = str(
|
||||||
|
Path.home() / DEFAULT_CLIGHTNING_DIR / 'lightning-rpc')
|
||||||
DEFAULT_SQK_DIR = ".sqk"
|
DEFAULT_SQK_DIR = ".sqk"
|
||||||
DEFAULT_SQK_DIR_PATH = str(Path.home() / DEFAULT_SQK_DIR)
|
DEFAULT_SQK_DIR_PATH = str(Path.home() / DEFAULT_SQK_DIR)
|
||||||
DEFAULT_LND_HOST = "localhost"
|
DEFAULT_LND_RPC_HOST = "localhost"
|
||||||
DEFAULT_INTEREST_BLOCK_INTERVAL = 2016
|
DEFAULT_INTEREST_BLOCK_INTERVAL = 2016
|
||||||
DEFAULT_SENT_OFFER_RETENTION_S = 86400
|
DEFAULT_SENT_OFFER_RETENTION_S = 86400
|
||||||
DEFAULT_RECEIVED_OFFER_RETENTION_S = 86400
|
DEFAULT_RECEIVED_OFFER_RETENTION_S = 86400
|
||||||
|
|
@ -78,18 +81,19 @@ class BitcoinConfig(Config):
|
||||||
rpc_pass = key(cast=str, required=False, default="")
|
rpc_pass = key(cast=str, required=False, default="")
|
||||||
rpc_use_ssl = key(cast=bool, required=False, default=False)
|
rpc_use_ssl = key(cast=bool, required=False, default=False)
|
||||||
rpc_ssl_cert = key(cast=str, required=False, default="")
|
rpc_ssl_cert = key(cast=str, required=False, default="")
|
||||||
zeromq_hashblock_port = key(cast=int, required=False,
|
|
||||||
default=DEFAULT_BITCOIN_ZEROMQ_HASHBLOCK_PORT)
|
|
||||||
|
|
||||||
|
|
||||||
@section('lnd')
|
@section('lightning')
|
||||||
class LndConfig(Config):
|
class LightningConfig(Config):
|
||||||
host = key(cast=str, required=False, default=DEFAULT_LND_HOST)
|
backend = key(cast=str, required=False, default=DEFAULT_LIGHTNING_BACKEND)
|
||||||
external_host = key(cast=str, required=False, default="")
|
external_host = key(cast=str, required=False, default="")
|
||||||
port = key(cast=int, required=False, default=DEFAULT_LND_PORT)
|
external_port = key(cast=int, required=False, default=DEFAULT_LND_PORT)
|
||||||
rpc_port = key(cast=int, required=False, default=DEFAULT_LND_RPC_PORT)
|
lnd_rpc_host = key(cast=str, required=False, default=DEFAULT_LND_RPC_HOST)
|
||||||
tls_cert_path = key(cast=str, required=False, default="")
|
lnd_rpc_port = key(cast=int, required=False, default=DEFAULT_LND_RPC_PORT)
|
||||||
macaroon_path = key(cast=str, required=False, default="")
|
lnd_tls_cert_path = key(cast=str, required=False, default="")
|
||||||
|
lnd_macaroon_path = key(cast=str, required=False, default="")
|
||||||
|
clightning_rpc_file = key(cast=str, required=False,
|
||||||
|
default=DEFAULT_CLIGHTNING_RPC_FILE)
|
||||||
|
|
||||||
|
|
||||||
@section('tor')
|
@section('tor')
|
||||||
|
|
@ -102,7 +106,7 @@ class TorConfig(Config):
|
||||||
class ServerConfig(Config):
|
class ServerConfig(Config):
|
||||||
enabled = key(cast=bool, required=False, default=True)
|
enabled = key(cast=bool, required=False, default=True)
|
||||||
host = key(cast=str, required=False, default=DEFAULT_SERVER_RPC_HOST)
|
host = key(cast=str, required=False, default=DEFAULT_SERVER_RPC_HOST)
|
||||||
port = key(cast=int, required=False, default=DEFAULT_SERVER_RPC_PORT)
|
port = key(cast=int, required=False, default=0)
|
||||||
external_address = key(cast=str, required=False, default="")
|
external_address = key(cast=str, required=False, default="")
|
||||||
external_port = key(cast=int, required=False,
|
external_port = key(cast=int, required=False,
|
||||||
default=DEFAULT_EXTERNAL_PORT)
|
default=DEFAULT_EXTERNAL_PORT)
|
||||||
|
|
@ -172,7 +176,7 @@ class TwitterConfig(Config):
|
||||||
|
|
||||||
class SqueaknodeConfig(Config):
|
class SqueaknodeConfig(Config):
|
||||||
bitcoin = group_key(BitcoinConfig)
|
bitcoin = group_key(BitcoinConfig)
|
||||||
lnd = group_key(LndConfig)
|
lightning = group_key(LightningConfig)
|
||||||
tor = group_key(TorConfig)
|
tor = group_key(TorConfig)
|
||||||
server = group_key(ServerConfig)
|
server = group_key(ServerConfig)
|
||||||
rpc = group_key(RpcConfig)
|
rpc = group_key(RpcConfig)
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,13 @@ from squeaknode.core.squeak_peer import SqueakPeer
|
||||||
def create_saved_peer(
|
def create_saved_peer(
|
||||||
peer_name: str,
|
peer_name: str,
|
||||||
peer_address: PeerAddress,
|
peer_address: PeerAddress,
|
||||||
|
default_peer_port: int,
|
||||||
) -> SqueakPeer:
|
) -> SqueakPeer:
|
||||||
validate_saved_peer_name(peer_name)
|
validate_saved_peer_name(peer_name)
|
||||||
|
if peer_address.port == 0:
|
||||||
|
peer_address = peer_address._replace(
|
||||||
|
port=default_peer_port,
|
||||||
|
)
|
||||||
return SqueakPeer(
|
return SqueakPeer(
|
||||||
peer_id=None,
|
peer_id=None,
|
||||||
peer_name=peer_name,
|
peer_name=peer_name,
|
||||||
|
|
|
||||||
|
|
@ -24,13 +24,11 @@ from typing import Callable
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
|
||||||
import grpc
|
|
||||||
from bitcoin.core import CBlockHeader
|
from bitcoin.core import CBlockHeader
|
||||||
from squeak.core import CBaseSqueak
|
from squeak.core import CBaseSqueak
|
||||||
from squeak.core import CSqueak
|
from squeak.core import CSqueak
|
||||||
|
|
||||||
from squeaknode.bitcoin.bitcoin_client import BitcoinClient
|
from squeaknode.bitcoin.bitcoin_client import BitcoinClient
|
||||||
from squeaknode.core.exception import InvoiceSubscriptionError
|
|
||||||
from squeaknode.core.lightning_address import LightningAddressHostPort
|
from squeaknode.core.lightning_address import LightningAddressHostPort
|
||||||
from squeaknode.core.offer import Offer
|
from squeaknode.core.offer import Offer
|
||||||
from squeaknode.core.peer_address import PeerAddress
|
from squeaknode.core.peer_address import PeerAddress
|
||||||
|
|
@ -415,25 +413,20 @@ class SqueakCore:
|
||||||
|
|
||||||
def get_payment_stream():
|
def get_payment_stream():
|
||||||
# Yield the received payments.
|
# Yield the received payments.
|
||||||
try:
|
for invoice in invoice_stream.result_stream:
|
||||||
for invoice in invoice_stream.result_stream:
|
payment_hash = invoice.r_hash
|
||||||
if invoice.settled:
|
settle_index = invoice.settle_index
|
||||||
payment_hash = invoice.r_hash
|
sent_offer = get_sent_offer_fn(payment_hash)
|
||||||
settle_index = invoice.settle_index
|
if sent_offer is not None:
|
||||||
sent_offer = get_sent_offer_fn(payment_hash)
|
yield ReceivedPayment(
|
||||||
if sent_offer is not None:
|
received_payment_id=None,
|
||||||
yield ReceivedPayment(
|
created_time_ms=None,
|
||||||
received_payment_id=None,
|
squeak_hash=sent_offer.squeak_hash,
|
||||||
created_time_ms=None,
|
payment_hash=sent_offer.payment_hash,
|
||||||
squeak_hash=sent_offer.squeak_hash,
|
price_msat=sent_offer.price_msat,
|
||||||
payment_hash=sent_offer.payment_hash,
|
settle_index=settle_index,
|
||||||
price_msat=sent_offer.price_msat,
|
peer_address=sent_offer.peer_address,
|
||||||
settle_index=settle_index,
|
)
|
||||||
peer_address=sent_offer.peer_address,
|
|
||||||
)
|
|
||||||
except grpc.RpcError as e:
|
|
||||||
if e.code() != grpc.StatusCode.CANCELLED:
|
|
||||||
raise InvoiceSubscriptionError()
|
|
||||||
|
|
||||||
return ReceivedPaymentsStream(
|
return ReceivedPaymentsStream(
|
||||||
cancel_fn=cancel_subscription,
|
cancel_fn=cancel_subscription,
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ from squeaknode.db.models import Models
|
||||||
|
|
||||||
# this is the Alembic Config object, which provides
|
# this is the Alembic Config object, which provides
|
||||||
# access to the values within the .ini file in use.
|
# access to the values within the .ini file in use.
|
||||||
config = context.config
|
config = context.config # type: ignore
|
||||||
|
|
||||||
# Interpret the config file for Python logging.
|
# Interpret the config file for Python logging.
|
||||||
# This line sets up loggers basically.
|
# This line sets up loggers basically.
|
||||||
|
|
|
||||||
140
squeaknode/lightning/clightning_lightning_client.py
Normal file
140
squeaknode/lightning/clightning_lightning_client.py
Normal file
|
|
@ -0,0 +1,140 @@
|
||||||
|
# MIT License
|
||||||
|
#
|
||||||
|
# Copyright (c) 2020 Jonathan Zernik
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
import logging
|
||||||
|
import time
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
from pyln.client import LightningRpc
|
||||||
|
|
||||||
|
from squeaknode.core.exception import InvoiceSubscriptionError
|
||||||
|
from squeaknode.lightning.info import Info
|
||||||
|
from squeaknode.lightning.invoice import Invoice
|
||||||
|
from squeaknode.lightning.invoice_stream import InvoiceStream
|
||||||
|
from squeaknode.lightning.lightning_client import LightningClient
|
||||||
|
from squeaknode.lightning.pay_req import PayReq
|
||||||
|
from squeaknode.lightning.payment import Payment
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class CLightningClient(LightningClient):
|
||||||
|
"""Access a c-lightning instance using the Python API."""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
rpc_path: str,
|
||||||
|
) -> None:
|
||||||
|
self.rpc_path = rpc_path
|
||||||
|
|
||||||
|
def init(self):
|
||||||
|
# Create an instance of the LightningRpc object using the Core Lightning daemon on your computer.
|
||||||
|
logger.info('initializing clightning client: {}'.format(self.rpc_path))
|
||||||
|
self.lrpc = LightningRpc(self.rpc_path)
|
||||||
|
|
||||||
|
def pay_invoice(self, payment_request: str) -> Payment:
|
||||||
|
payment = self.lrpc.pay(payment_request)
|
||||||
|
if payment['status'] == 'complete':
|
||||||
|
return Payment(
|
||||||
|
payment_preimage=bytes.fromhex(payment['payment_preimage']),
|
||||||
|
payment_error='',
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return Payment(
|
||||||
|
payment_preimage=b'',
|
||||||
|
payment_error='Payment failed.',
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_info(self) -> Info:
|
||||||
|
info = self.lrpc.getinfo()
|
||||||
|
pubkey = info['id']
|
||||||
|
binding = info.get('binding')
|
||||||
|
uris = []
|
||||||
|
if binding:
|
||||||
|
for b in binding:
|
||||||
|
address = b['address']
|
||||||
|
if ':' not in address: # TODO: Change type of uri to LightningAddress.
|
||||||
|
port = b['port']
|
||||||
|
uri = f"{pubkey}@{address}:{port}"
|
||||||
|
uris.append(uri)
|
||||||
|
return Info(
|
||||||
|
uris=uris,
|
||||||
|
)
|
||||||
|
|
||||||
|
def decode_pay_req(self, payment_request: str) -> PayReq:
|
||||||
|
pay_req = self.lrpc.decodepay(payment_request)
|
||||||
|
return PayReq(
|
||||||
|
payment_hash=bytes.fromhex(pay_req['payment_hash']),
|
||||||
|
payment_point=b'', # TODO: Use real payment point.
|
||||||
|
num_msat=pay_req['amount_msat'].millisatoshis,
|
||||||
|
destination=pay_req['payee'],
|
||||||
|
timestamp=int(pay_req['created_at']),
|
||||||
|
expiry=int(pay_req['expiry']),
|
||||||
|
)
|
||||||
|
|
||||||
|
def create_invoice(self, preimage: bytes, amount_msat: int) -> Invoice:
|
||||||
|
created_invoice = self.lrpc.invoice(
|
||||||
|
amount_msat,
|
||||||
|
label=str(uuid.uuid4()),
|
||||||
|
description="Squeaknode invoice",
|
||||||
|
preimage=preimage.hex(),
|
||||||
|
)
|
||||||
|
creation_time = int(time.time())
|
||||||
|
expiry = int(created_invoice['expires_at']) - creation_time
|
||||||
|
return Invoice(
|
||||||
|
r_hash=bytes.fromhex(created_invoice['payment_hash']),
|
||||||
|
payment_request=created_invoice['bolt11'],
|
||||||
|
value_msat=amount_msat,
|
||||||
|
settled=False,
|
||||||
|
settle_index=0,
|
||||||
|
creation_date=creation_time,
|
||||||
|
expiry=expiry,
|
||||||
|
)
|
||||||
|
|
||||||
|
def subscribe_invoices(self, settle_index: int) -> InvoiceStream:
|
||||||
|
|
||||||
|
def cancel_fn():
|
||||||
|
return None
|
||||||
|
|
||||||
|
def get_invoice_stream():
|
||||||
|
try:
|
||||||
|
pay_index = settle_index
|
||||||
|
while True:
|
||||||
|
payment = self.lrpc.waitanyinvoice(lastpay_index=pay_index)
|
||||||
|
if payment['status'] == 'paid':
|
||||||
|
pay_index = payment.get('pay_index') or 0
|
||||||
|
yield Invoice(
|
||||||
|
r_hash=bytes.fromhex(payment['payment_hash']),
|
||||||
|
payment_request=payment.get('bolt11') or '',
|
||||||
|
value_msat=payment.get('value_msat'),
|
||||||
|
settled=True,
|
||||||
|
settle_index=pay_index,
|
||||||
|
creation_date=0, # This value is ignored.
|
||||||
|
expiry=payment['expires_at'],
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
raise InvoiceSubscriptionError()
|
||||||
|
|
||||||
|
return InvoiceStream(
|
||||||
|
cancel=cancel_fn,
|
||||||
|
result_stream=get_invoice_stream(),
|
||||||
|
)
|
||||||
|
|
@ -34,6 +34,13 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class LightningClient(ABC):
|
class LightningClient(ABC):
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def init(self):
|
||||||
|
"""Initialize the lightning client.
|
||||||
|
Returns:
|
||||||
|
None
|
||||||
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_info(self) -> Info:
|
def get_info(self) -> Info:
|
||||||
"""Get info about the lightning node.
|
"""Get info about the lightning node.
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import grpc
|
||||||
|
|
||||||
from proto import lnd_pb2
|
from proto import lnd_pb2
|
||||||
from proto import lnd_pb2_grpc
|
from proto import lnd_pb2_grpc
|
||||||
|
from squeaknode.core.exception import InvoiceSubscriptionError
|
||||||
from squeaknode.lightning.info import Info
|
from squeaknode.lightning.info import Info
|
||||||
from squeaknode.lightning.invoice import Invoice
|
from squeaknode.lightning.invoice import Invoice
|
||||||
from squeaknode.lightning.invoice_stream import InvoiceStream
|
from squeaknode.lightning.invoice_stream import InvoiceStream
|
||||||
|
|
@ -165,7 +166,25 @@ class LNDLightningClient(LightningClient):
|
||||||
subscribe_result = self.stub.SubscribeInvoices(
|
subscribe_result = self.stub.SubscribeInvoices(
|
||||||
subscribe_invoices_request,
|
subscribe_invoices_request,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_invoice_stream():
|
||||||
|
try:
|
||||||
|
for invoice in subscribe_result:
|
||||||
|
if invoice.settled:
|
||||||
|
yield Invoice(
|
||||||
|
r_hash=invoice.r_hash,
|
||||||
|
payment_request=invoice.payment_request,
|
||||||
|
value_msat=invoice.value_msat,
|
||||||
|
settled=invoice.settled,
|
||||||
|
settle_index=invoice.settle_index,
|
||||||
|
creation_date=invoice.creation_date,
|
||||||
|
expiry=invoice.expiry,
|
||||||
|
)
|
||||||
|
except grpc.RpcError as e:
|
||||||
|
if e.code() != grpc.StatusCode.CANCELLED:
|
||||||
|
raise InvoiceSubscriptionError()
|
||||||
|
|
||||||
return InvoiceStream(
|
return InvoiceStream(
|
||||||
cancel=subscribe_result.cancel,
|
cancel=subscribe_result.cancel,
|
||||||
result_stream=iter(subscribe_result),
|
result_stream=get_invoice_stream(),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,9 @@ class PaymentProcessorTask:
|
||||||
def process_subscribed_invoices(self):
|
def process_subscribed_invoices(self):
|
||||||
while not self.stopped.is_set():
|
while not self.stopped.is_set():
|
||||||
try:
|
try:
|
||||||
latest_settle_index = self.get_latest_settle_index()
|
# Use zero as starting settle index, so that no invoices are skipped.
|
||||||
|
# latest_settle_index = self.get_latest_settle_index()
|
||||||
|
latest_settle_index = 0
|
||||||
logger.info("Starting payment subscription with settle index: {}".format(
|
logger.info("Starting payment subscription with settle index: {}".format(
|
||||||
latest_settle_index,
|
latest_settle_index,
|
||||||
))
|
))
|
||||||
|
|
|
||||||
|
|
@ -105,10 +105,10 @@ class SqueakController:
|
||||||
peer_address: PeerAddress,
|
peer_address: PeerAddress,
|
||||||
) -> Optional[Offer]:
|
) -> Optional[Offer]:
|
||||||
lnd_external_address: Optional[LightningAddressHostPort] = None
|
lnd_external_address: Optional[LightningAddressHostPort] = None
|
||||||
if self.config.lnd.external_host:
|
if self.config.lightning.external_host:
|
||||||
lnd_external_address = LightningAddressHostPort(
|
lnd_external_address = LightningAddressHostPort(
|
||||||
host=self.config.lnd.external_host,
|
host=self.config.lightning.external_host,
|
||||||
port=self.config.lnd.port,
|
port=self.config.lightning.external_port,
|
||||||
)
|
)
|
||||||
price_msat = self.get_sell_price_msat()
|
price_msat = self.get_sell_price_msat()
|
||||||
if price_msat == 0:
|
if price_msat == 0:
|
||||||
|
|
@ -187,7 +187,11 @@ class SqueakController:
|
||||||
return self.squeak_store.get_squeak_profile_private_key(profile_id)
|
return self.squeak_store.get_squeak_profile_private_key(profile_id)
|
||||||
|
|
||||||
def create_peer(self, peer_name: str, peer_address: PeerAddress):
|
def create_peer(self, peer_name: str, peer_address: PeerAddress):
|
||||||
return self.squeak_store.create_peer(peer_name, peer_address)
|
return self.squeak_store.create_peer(
|
||||||
|
peer_name,
|
||||||
|
peer_address,
|
||||||
|
self.config.server.port or 0,
|
||||||
|
)
|
||||||
|
|
||||||
def get_peer(self, peer_id: int) -> Optional[SqueakPeer]:
|
def get_peer(self, peer_id: int) -> Optional[SqueakPeer]:
|
||||||
return self.squeak_store.get_peer(peer_id)
|
return self.squeak_store.get_peer(peer_id)
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ from squeaknode.core.squeak_core import SqueakCore
|
||||||
from squeaknode.db.db_engine import get_connection_string
|
from squeaknode.db.db_engine import get_connection_string
|
||||||
from squeaknode.db.db_engine import get_engine
|
from squeaknode.db.db_engine import get_engine
|
||||||
from squeaknode.db.squeak_db import SqueakDb
|
from squeaknode.db.squeak_db import SqueakDb
|
||||||
|
from squeaknode.lightning.clightning_lightning_client import CLightningClient
|
||||||
from squeaknode.lightning.lnd_lightning_client import LNDLightningClient
|
from squeaknode.lightning.lnd_lightning_client import LNDLightningClient
|
||||||
from squeaknode.node.node_settings import NodeSettings
|
from squeaknode.node.node_settings import NodeSettings
|
||||||
from squeaknode.node.payment_processor import PaymentProcessor
|
from squeaknode.node.payment_processor import PaymentProcessor
|
||||||
|
|
@ -48,6 +49,7 @@ from squeaknode.server.app import SqueakPeerWebServer
|
||||||
from squeaknode.server.squeak_peer_server_handler import SqueakPeerServerHandler
|
from squeaknode.server.squeak_peer_server_handler import SqueakPeerServerHandler
|
||||||
from squeaknode.twitter.twitter_forwarder import TwitterForwarder
|
from squeaknode.twitter.twitter_forwarder import TwitterForwarder
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -118,12 +120,21 @@ class SqueakNode:
|
||||||
self.node_settings = NodeSettings(self.squeak_db)
|
self.node_settings = NodeSettings(self.squeak_db)
|
||||||
|
|
||||||
def create_lightning_client(self):
|
def create_lightning_client(self):
|
||||||
self.lightning_client = LNDLightningClient(
|
if self.config.lightning.backend == 'lnd':
|
||||||
self.config.lnd.host,
|
self.lightning_client = LNDLightningClient(
|
||||||
self.config.lnd.rpc_port,
|
self.config.lightning.lnd_rpc_host,
|
||||||
self.config.lnd.tls_cert_path,
|
self.config.lightning.lnd_rpc_port,
|
||||||
self.config.lnd.macaroon_path,
|
self.config.lightning.lnd_tls_cert_path,
|
||||||
)
|
self.config.lightning.lnd_macaroon_path,
|
||||||
|
)
|
||||||
|
elif self.config.lightning.backend == 'clightning':
|
||||||
|
self.lightning_client = CLightningClient(
|
||||||
|
self.config.lightning.clightning_rpc_file,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
raise Exception('Invalid lightning backend: {}'.format(
|
||||||
|
self.config.lightning.backend,
|
||||||
|
))
|
||||||
|
|
||||||
def create_bitcoin_client(self):
|
def create_bitcoin_client(self):
|
||||||
self.bitcoin_client = BitcoinCoreClient(
|
self.bitcoin_client = BitcoinCoreClient(
|
||||||
|
|
@ -217,7 +228,7 @@ class SqueakNode:
|
||||||
def create_peer_web_server(self):
|
def create_peer_web_server(self):
|
||||||
self.peer_web_server = SqueakPeerWebServer(
|
self.peer_web_server = SqueakPeerWebServer(
|
||||||
self.config.server.host,
|
self.config.server.host,
|
||||||
squeak.params.params.DEFAULT_PORT,
|
self.config.server.port or squeak.params.params.DEFAULT_PORT,
|
||||||
self.peer_handler,
|
self.peer_handler,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -389,10 +389,11 @@ class SqueakStore:
|
||||||
))
|
))
|
||||||
return get_profile_private_key(profile)
|
return get_profile_private_key(profile)
|
||||||
|
|
||||||
def create_peer(self, peer_name: str, peer_address: PeerAddress):
|
def create_peer(self, peer_name: str, peer_address: PeerAddress, default_peer_port):
|
||||||
squeak_peer = create_saved_peer(
|
squeak_peer = create_saved_peer(
|
||||||
peer_name,
|
peer_name,
|
||||||
peer_address,
|
peer_address,
|
||||||
|
default_peer_port,
|
||||||
)
|
)
|
||||||
return self.squeak_db.insert_peer(squeak_peer)
|
return self.squeak_db.insert_peer(squeak_peer)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,13 +59,10 @@ def create_app(handler):
|
||||||
@app.route('/squeak/<hash>')
|
@app.route('/squeak/<hash>')
|
||||||
def squeak(hash):
|
def squeak(hash):
|
||||||
try:
|
try:
|
||||||
squeak_type, squeak_bytes = handler.handle_get_squeak_bytes(hash)
|
squeak_bytes = handler.handle_get_squeak_bytes(hash)
|
||||||
except NotFoundError:
|
except NotFoundError:
|
||||||
return "Not found", 404
|
return "Not found", 404
|
||||||
return jsonify({
|
return squeak_bytes
|
||||||
'squeak_type': squeak_type,
|
|
||||||
'squeak_bytes': squeak_bytes.hex(),
|
|
||||||
})
|
|
||||||
|
|
||||||
@app.route('/secretkey/<hash>')
|
@app.route('/secretkey/<hash>')
|
||||||
def secret_key(hash):
|
def secret_key(hash):
|
||||||
|
|
@ -80,8 +77,9 @@ def create_app(handler):
|
||||||
@app.route('/offer/<hash>')
|
@app.route('/offer/<hash>')
|
||||||
def offer(hash):
|
def offer(hash):
|
||||||
client_host = request.remote_addr
|
client_host = request.remote_addr
|
||||||
|
client_port = request.environ.get('REMOTE_PORT') or 0
|
||||||
try:
|
try:
|
||||||
offer = handler.handle_get_offer(hash, client_host)
|
offer = handler.handle_get_offer(hash, client_host, client_port)
|
||||||
except NotFoundError:
|
except NotFoundError:
|
||||||
return "Not found", 404
|
return "Not found", 404
|
||||||
return jsonify({
|
return jsonify({
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@
|
||||||
import logging
|
import logging
|
||||||
from typing import List
|
from typing import List
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from typing import Tuple
|
|
||||||
|
|
||||||
from squeak.core.keys import SqueakPublicKey
|
from squeak.core.keys import SqueakPublicKey
|
||||||
|
|
||||||
|
|
@ -55,17 +54,16 @@ class SqueakPeerServerHandler(object):
|
||||||
self.node_settings = node_settings
|
self.node_settings = node_settings
|
||||||
self.config = config
|
self.config = config
|
||||||
|
|
||||||
def handle_get_squeak_bytes(self, squeak_hash_str) -> Tuple[str, bytes]:
|
def handle_get_squeak_bytes(self, squeak_hash_str) -> bytes:
|
||||||
"""Return a tuple with the squeak type and the squeak bytes.
|
"""Return a tuple with the squeak type and the squeak bytes.
|
||||||
|
|
||||||
Returns: (str, bytes)
|
Returns: bytes
|
||||||
"""
|
"""
|
||||||
squeak_hash = bytes.fromhex(squeak_hash_str)
|
squeak_hash = bytes.fromhex(squeak_hash_str)
|
||||||
squeak = self.squeak_controller.get_squeak(squeak_hash)
|
squeak = self.squeak_controller.get_squeak(squeak_hash)
|
||||||
if not squeak:
|
if not squeak:
|
||||||
raise NotFoundError()
|
raise NotFoundError()
|
||||||
squeak_type = 'resqueak' if squeak.is_resqueak else 'squeak'
|
return squeak.serialize()
|
||||||
return squeak_type, squeak.serialize()
|
|
||||||
|
|
||||||
def handle_get_secret_key(self, squeak_hash_str) -> bytes:
|
def handle_get_secret_key(self, squeak_hash_str) -> bytes:
|
||||||
squeak_hash = bytes.fromhex(squeak_hash_str)
|
squeak_hash = bytes.fromhex(squeak_hash_str)
|
||||||
|
|
@ -77,12 +75,12 @@ class SqueakPeerServerHandler(object):
|
||||||
raise NotFoundError()
|
raise NotFoundError()
|
||||||
return secret_key
|
return secret_key
|
||||||
|
|
||||||
def handle_get_offer(self, squeak_hash_str, client_host) -> Offer:
|
def handle_get_offer(self, squeak_hash_str, client_host, client_port) -> Offer:
|
||||||
squeak_hash = bytes.fromhex(squeak_hash_str)
|
squeak_hash = bytes.fromhex(squeak_hash_str)
|
||||||
client_addr = PeerAddress(
|
client_addr = PeerAddress(
|
||||||
network=Network.IPV4,
|
network=Network.IPV4,
|
||||||
host=client_host,
|
host=client_host,
|
||||||
port=0,
|
port=client_port,
|
||||||
)
|
)
|
||||||
offer = self.squeak_controller.get_packaged_offer(
|
offer = self.squeak_controller.get_packaged_offer(
|
||||||
squeak_hash,
|
squeak_hash,
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,11 @@ def peer_name():
|
||||||
yield "fake_peer_name"
|
yield "fake_peer_name"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def default_peer_port():
|
||||||
|
yield 9999
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def peer_address():
|
def peer_address():
|
||||||
yield PeerAddress(
|
yield PeerAddress(
|
||||||
|
|
@ -58,24 +63,37 @@ def peer_address_with_no_port():
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_create_saved_peer(peer_name, peer_address):
|
def test_create_saved_peer(peer_name, peer_address, default_peer_port):
|
||||||
peer = create_saved_peer(
|
peer = create_saved_peer(
|
||||||
peer_name,
|
peer_name,
|
||||||
peer_address,
|
peer_address,
|
||||||
|
default_peer_port,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert peer.peer_name == peer_name
|
assert peer.peer_name == peer_name
|
||||||
assert peer.address == peer_address
|
assert peer.address == peer_address
|
||||||
|
|
||||||
|
|
||||||
def test_create_saved_peer_empty_name(peer_address):
|
def test_create_saved_peer_empty_name(peer_address, default_peer_port):
|
||||||
create_saved_peer("", peer_address)
|
create_saved_peer("", peer_address, default_peer_port)
|
||||||
|
|
||||||
|
|
||||||
def test_create_saved_peer_use_tor(peer_name, peer_address_with_tor):
|
def test_create_saved_peer_no_port(peer_name, peer_address_with_no_port, default_peer_port):
|
||||||
|
peer = create_saved_peer(
|
||||||
|
peer_name,
|
||||||
|
peer_address_with_no_port,
|
||||||
|
default_peer_port,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert peer.peer_name == peer_name
|
||||||
|
assert peer.address.port == default_peer_port
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_saved_peer_use_tor(peer_name, peer_address_with_tor, default_peer_port):
|
||||||
peer = create_saved_peer(
|
peer = create_saved_peer(
|
||||||
peer_name,
|
peer_name,
|
||||||
peer_address_with_tor,
|
peer_address_with_tor,
|
||||||
|
default_peer_port,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert peer.peer_name == peer_name
|
assert peer.peer_name == peer_name
|
||||||
|
|
|
||||||
|
|
@ -131,9 +131,10 @@ def failed_payment(payment_request):
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def invoice_stream(settled_invoice, unsettled_invoice):
|
def invoice_stream(settled_invoice, unsettled_invoice):
|
||||||
|
# Length of invoices list is 1.
|
||||||
invoices = [
|
invoices = [
|
||||||
settled_invoice,
|
settled_invoice,
|
||||||
unsettled_invoice,
|
# unsettled_invoice,
|
||||||
]
|
]
|
||||||
yield InvoiceStream(
|
yield InvoiceStream(
|
||||||
cancel=lambda: None,
|
cancel=lambda: None,
|
||||||
|
|
@ -188,6 +189,9 @@ class MockLightningClient(LightningClient):
|
||||||
self.payment = payment
|
self.payment = payment
|
||||||
self.invoice_stream = invoice_stream
|
self.invoice_stream = invoice_stream
|
||||||
|
|
||||||
|
def init(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def get_info(self):
|
def get_info(self):
|
||||||
return self.info
|
return self.info
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ def rpc_invoice(preimage, payment_hash, payment_request, price_msat, creation_da
|
||||||
r_hash=payment_hash,
|
r_hash=payment_hash,
|
||||||
payment_request=payment_request,
|
payment_request=payment_request,
|
||||||
value_msat=price_msat,
|
value_msat=price_msat,
|
||||||
settled=False,
|
settled=True,
|
||||||
settle_index=0,
|
settle_index=0,
|
||||||
creation_date=creation_date,
|
creation_date=creation_date,
|
||||||
expiry=expiry,
|
expiry=expiry,
|
||||||
|
|
@ -122,7 +122,7 @@ def invoice(payment_hash, payment_request, price_msat, creation_date, expiry):
|
||||||
r_hash=payment_hash,
|
r_hash=payment_hash,
|
||||||
payment_request=payment_request,
|
payment_request=payment_request,
|
||||||
value_msat=price_msat,
|
value_msat=price_msat,
|
||||||
settled=False,
|
settled=True,
|
||||||
settle_index=0,
|
settle_index=0,
|
||||||
creation_date=creation_date,
|
creation_date=creation_date,
|
||||||
expiry=expiry,
|
expiry=expiry,
|
||||||
|
|
|
||||||
|
|
@ -167,4 +167,5 @@ def test_create_peer(squeak_store, squeak_controller, peer_address):
|
||||||
squeak_store.create_peer.assert_called_with(
|
squeak_store.create_peer.assert_called_with(
|
||||||
"fake_peer_name",
|
"fake_peer_name",
|
||||||
peer_address,
|
peer_address,
|
||||||
|
0,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,7 @@ def gen_squeak_peer(peer_name):
|
||||||
return create_saved_peer(
|
return create_saved_peer(
|
||||||
peer_name,
|
peer_name,
|
||||||
peer_address,
|
peer_address,
|
||||||
|
0,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue