mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-14 12:43:24 +02:00
Compare commits
No commits in common. "master" and "v0.2.23" have entirely different histories.
49 changed files with 26296 additions and 6124 deletions
16
README.md
16
README.md
|
|
@ -39,10 +39,10 @@ The protocol is defined [here](https://github.com/yzernik/squeak/blob/master/doc
|
|||
[node]
|
||||
network=mainnet
|
||||
|
||||
[lightning]
|
||||
backend=lnd
|
||||
lnd_tls_cert_path=~/.lnd/tls.cert
|
||||
lnd_macaroon_path=~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon
|
||||
[lnd]
|
||||
host=localhost
|
||||
tls_cert_path=~/.lnd/tls.cert
|
||||
macaroon_path=~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon
|
||||
|
||||
[bitcoin]
|
||||
rpc_host=localhost
|
||||
|
|
@ -60,14 +60,6 @@ username=devuser
|
|||
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.
|
||||
|
||||
### Step 2. Install squeaknode:
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
[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
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
[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,18 +1,17 @@
|
|||
[node]
|
||||
network=testnet
|
||||
|
||||
[lightning]
|
||||
external_host=localhost
|
||||
lnd_rpc_host=localhost
|
||||
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
|
||||
[lnd]
|
||||
host=localhost
|
||||
tls_cert_path=~/.lnd/tls.cert
|
||||
macaroon_path=~/.lnd/data/chain/bitcoin/testnet/admin.macaroon
|
||||
|
||||
[bitcoin]
|
||||
rpc_host=localhost
|
||||
rpc_port=18445
|
||||
rpc_user=polaruser
|
||||
rpc_pass=polarpass
|
||||
rpc_port=18332
|
||||
rpc_user=devuser
|
||||
rpc_pass=devpass
|
||||
zeromq_hashblock_port=28334
|
||||
|
||||
[tor]
|
||||
proxy_ip=localhost
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
FROM golang:1.18-alpine as builder
|
||||
FROM golang:1.12-alpine as builder
|
||||
|
||||
MAINTAINER Olaoluwa Osuntokun <laolu@lightning.network>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
[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]
|
||||
network=testnet
|
||||
|
||||
[lightning]
|
||||
lnd_rpc_host=lnd
|
||||
external_host=lnd
|
||||
lnd_tls_cert_path=~/.lnd/tls.cert
|
||||
lnd_macaroon_path=~/.lnd/data/chain/bitcoin/testnet/admin.macaroon
|
||||
[lnd]
|
||||
host=lnd
|
||||
tls_cert_path=~/.lnd/tls.cert
|
||||
macaroon_path=~/.lnd/data/chain/bitcoin/testnet/admin.macaroon
|
||||
|
||||
[bitcoin]
|
||||
rpc_host=bitcoin-core
|
||||
rpc_port=18332
|
||||
rpc_user=devuser
|
||||
rpc_pass=devpass
|
||||
zeromq_hashblock_port=28334
|
||||
|
||||
[tor]
|
||||
proxy_ip=tor-node
|
||||
|
|
|
|||
|
|
@ -19,16 +19,6 @@ services:
|
|||
environment:
|
||||
- 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:
|
||||
# environment:
|
||||
# - NETWORK=mainnet
|
||||
|
|
|
|||
|
|
@ -15,32 +15,6 @@ services:
|
|||
-zmqpubhashblock=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:
|
||||
# environment:
|
||||
# - NETWORK=testnet
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ services:
|
|||
image: ruimarinho/bitcoin-core:0.21.1
|
||||
container_name: bitcoin-core
|
||||
volumes:
|
||||
- bitcoin:/home/bitcoin/.bitcoin
|
||||
- ~/.bitcoin:/home/bitcoin/.bitcoin
|
||||
ports:
|
||||
- 8332:8332
|
||||
- 18332:18332
|
||||
|
|
@ -25,7 +25,7 @@ services:
|
|||
depends_on:
|
||||
- "tor-node"
|
||||
volumes:
|
||||
- lnd_client_dir:/root/.lnd
|
||||
- ~/.lnd:/root/.lnd
|
||||
- tor-dir:/var/lib/tor
|
||||
ports:
|
||||
- 10009:10009
|
||||
|
|
@ -57,45 +57,6 @@ services:
|
|||
- net.ipv6.conf.all.disable_ipv6=0
|
||||
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:
|
||||
image: osminogin/tor-simple
|
||||
container_name: tor-node
|
||||
|
|
@ -128,42 +89,10 @@ services:
|
|||
- net.ipv6.conf.all.disable_ipv6=0
|
||||
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:
|
||||
bitcoin:
|
||||
driver: local
|
||||
lnd_client_dir:
|
||||
driver: local
|
||||
lnd_server_dir:
|
||||
driver: local
|
||||
clightning_client_dir:
|
||||
driver: local
|
||||
clightning_server_dir:
|
||||
driver: local
|
||||
squeaknode_dir:
|
||||
driver: local
|
||||
squeaknode_clightning_dir:
|
||||
driver: local
|
||||
tor-dir:
|
||||
driver: local
|
||||
|
|
|
|||
|
|
@ -26,14 +26,13 @@ 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_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.
|
||||
lightning.backend | string | | yes | "lnd" | SQUEAKNODE_LIGHTNING_BACKEND | The Lightning Network node implementation to use.
|
||||
lightning.external_host | string | | yes | "" | SQUEAKNODE_LIGHTNING_EXTERNAL_HOST | The host of the lightning 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.
|
||||
lightning.lnd_rpc_host | string | | yes | "localhost" | SQUEAKNODE_LIGHTNING_LND_RPC_HOST | The host of the LND node to connect.
|
||||
lightning.lnd_rpc_port | int | | yes | | SQUEAKNODE_LIGHTNING_LND_RPC_PORT | The port of the LND node to use for RPC connections.
|
||||
lightning.lnd_tls_cert_path | string | | yes | "" | SQUEAKNODE_LIGHTNING_LND_TLS_CERT_PATH | The path to the TLS certificate 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.
|
||||
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.
|
||||
lnd.host | string | | yes | "localhost" | SQUEAKNODE_LND_HOST | The host of the LND node to connect.
|
||||
lnd.external_host | string | | yes | "" | SQUEAKNODE_LND_EXTERNAL_HOST | The host of the LND 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.
|
||||
lnd.rpc_port | int | | yes | | SQUEAKNODE_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.
|
||||
lnd.macaroon_path | string | | yes | "" | SQUEAKNODE_LND_MACAROON_PATH | The path to the macaroon to use for LND connection.
|
||||
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.
|
||||
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 .
|
||||
```
|
||||
|
||||
- Copy the `~/.lnd` directory from the docker container to your host machine.
|
||||
- Make sure that `~/.lnd` directory (created by docker container) has read permissions. You may need to change the permissions:
|
||||
```
|
||||
docker cp lnd_client:/root/.lnd/ ~/.lnd
|
||||
sudo chmod -R 755 ~/.lnd/
|
||||
```
|
||||
|
||||
- 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",
|
||||
"informed": "^4.6.1",
|
||||
"jwt-decode": "^2.2.0",
|
||||
"moment": "^2.29.4",
|
||||
"moment": "^2.29.2",
|
||||
"react": "^16.13.1",
|
||||
"react-contenteditable": "^3.3.4",
|
||||
"react-copy-to-clipboard": "^5.1.0",
|
||||
|
|
|
|||
|
|
@ -61,26 +61,17 @@ const Peers = (props) => {
|
|||
return 'IPV4';
|
||||
};
|
||||
|
||||
const getExternalAddressStr = () => {
|
||||
if (externalAddress) {
|
||||
return `${externalAddress.getHost()}:${externalAddress.getPort()}`;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
function removeHttp(url) {
|
||||
return url.replace(/^https?:\/\//, '');
|
||||
}
|
||||
|
||||
const savePeer = ({values}) => {
|
||||
const network = getNetwork(values.useTor);
|
||||
const strippedAddress = removeHttp(values.address);
|
||||
const url = new URL(`http://${strippedAddress}`);
|
||||
const strippedHost = removeHttp(values.host);
|
||||
dispatch(setSavePeer({
|
||||
name: values.name,
|
||||
host: url.hostname,
|
||||
port: url.port,
|
||||
host: strippedHost,
|
||||
port: values.port,
|
||||
network: network,
|
||||
}));
|
||||
toggleSavePeerModal();
|
||||
|
|
@ -101,7 +92,8 @@ const Peers = (props) => {
|
|||
</div>
|
||||
<div className="edit-input-wrap">
|
||||
<Input class="informed-input" name="name" label="Peer Name (not required)" />
|
||||
<Input class="informed-input" name="address" label="Address (host:port)" />
|
||||
<Input class="informed-input" name="host" label="Host" />
|
||||
<Input class="informed-input" name="port" type="number" label="Port" />
|
||||
<Checkbox class="informed-input" name="useTor" label="Connect With Tor: " />
|
||||
</div>
|
||||
|
||||
|
|
@ -127,14 +119,32 @@ const Peers = (props) => {
|
|||
<div class="float-container">
|
||||
<div class="float-child">
|
||||
<div className="edit-input-wrap">
|
||||
<Input class="informed-input" name="external-address" label="External Address" initialValue={externalAddress && `${getExternalAddressStr()}`} readOnly />
|
||||
<Input class="informed-input" name="host" label="Host" initialValue={externalAddress && externalAddress.getHost()} readOnly />
|
||||
</div>
|
||||
</div>
|
||||
<div class="float-child">
|
||||
<CopyToClipboard
|
||||
text={externalAddress && `${getExternalAddressStr()}`}
|
||||
text={externalAddress && externalAddress.getHost()}
|
||||
>
|
||||
<a data-tip="Copy address">
|
||||
<a data-tip="Copy host">
|
||||
<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}>
|
||||
<ICON_CLIPBOARD />
|
||||
</button>
|
||||
|
|
|
|||
12343
frontend/yarn.lock
12343
frontend/yarn.lock
File diff suppressed because it is too large
Load diff
|
|
@ -3,10 +3,10 @@ network=simnet
|
|||
price_msat=1000000
|
||||
max_squeaks_per_public_key_per_block=50
|
||||
|
||||
[lightning]
|
||||
lnd_rpc_host=lnd
|
||||
lnd_tls_cert_path=/root/.lnd/tls.cert
|
||||
lnd_macaroon_path=/root/.lnd/data/chain/bitcoin/simnet/admin.macaroon
|
||||
[lnd]
|
||||
host=lnd
|
||||
tls_cert_path=/root/.lnd/tls.cert
|
||||
macaroon_path=/root/.lnd/data/chain/bitcoin/simnet/admin.macaroon
|
||||
|
||||
[bitcoin]
|
||||
rpc_host=btcd
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
while true; do
|
||||
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 ..."
|
||||
docker compose run btcctl generate 400
|
||||
docker-compose run btcctl generate 400
|
||||
sleep 10
|
||||
done
|
||||
|
|
|
|||
|
|
@ -6,16 +6,16 @@ trap "kill 0" EXIT
|
|||
function mine_blocks {
|
||||
while true; do
|
||||
printf "Mining 1 block to address: $MINING_ADDRESS ..."
|
||||
docker compose run btcctl generate 1
|
||||
docker-compose run btcctl generate 1
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
cd itests
|
||||
docker compose down --volumes --remove-orphans
|
||||
docker compose build
|
||||
docker compose up -d
|
||||
docker-compose down --volumes --remove-orphans
|
||||
docker-compose build
|
||||
docker-compose up -d
|
||||
|
||||
# Initialize the blockchain with miner rewards going to the test client.
|
||||
|
||||
|
|
@ -29,9 +29,9 @@ do
|
|||
sleep 2
|
||||
done
|
||||
|
||||
export MINING_ADDRESS="$client_address docker compose up -d btcd"
|
||||
MINING_ADDRESS=$client_address docker-compose up -d btcd
|
||||
echo "Mining 400 blocks to address: $client_address ..."
|
||||
docker compose run btcctl generate 400
|
||||
docker-compose run btcctl generate 400
|
||||
echo "Finished mining blocks."
|
||||
sleep 30
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ mine_blocks &
|
|||
echo "Background mining task is in background..."
|
||||
|
||||
echo "Running test.sh...."
|
||||
docker compose run test ./test.sh
|
||||
docker-compose run test ./test.sh
|
||||
|
||||
echo "Shutting down itest..."
|
||||
# docker compose down
|
||||
# docker-compose down
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ from tests.util import delete_squeak
|
|||
from tests.util import download_squeak
|
||||
from tests.util import download_squeak_secret_key
|
||||
from tests.util import free_price
|
||||
from tests.util import get_balance
|
||||
from tests.util import get_external_address
|
||||
from tests.util import get_hash
|
||||
from tests.util import get_network
|
||||
|
|
@ -608,18 +607,6 @@ def test_delete_peer(admin_stub, peer_id):
|
|||
|
||||
def test_send_coins(admin_stub, other_admin_stub):
|
||||
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(
|
||||
other_admin_stub, new_address_response.address, 55555555
|
||||
)
|
||||
|
|
|
|||
|
|
@ -437,13 +437,6 @@ 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):
|
||||
send_coins_request = lnd_pb2.SendCoinsRequest(
|
||||
addr=addr,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
alembic==1.7.1
|
||||
docutils==0.17.1
|
||||
Flask==2.0.1
|
||||
flask-cors==3.0.10
|
||||
flask-login==0.5.0
|
||||
|
|
@ -8,7 +7,6 @@ googleapis-common-protos==1.53.0
|
|||
importlib_resources==1.4.0
|
||||
mypy-protobuf==2.9
|
||||
protobuf==3.17.3
|
||||
pyln-client==0.10.1
|
||||
PySocks==1.7.1
|
||||
python-bitcoinlib==0.11.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
|
||||
# SOFTWARE.
|
||||
|
||||
__version__ = '0.3.5'
|
||||
__version__ = '0.2.23'
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"files": {
|
||||
"main.css": "/static/css/main.fe6c5463.css",
|
||||
"main.js": "/static/js/main.f8361353.js",
|
||||
"main.js": "/static/js/main.e69a9816.js",
|
||||
"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/css/900.5027b0a1.chunk.css": "/static/css/900.5027b0a1.chunk.css",
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
"static/media/icon.svg": "/static/media/icon.982210ec9275956e4d3cc77fa90167fd.svg",
|
||||
"index.html": "/index.html",
|
||||
"main.fe6c5463.css.map": "/static/css/main.fe6c5463.css.map",
|
||||
"main.f8361353.js.map": "/static/js/main.f8361353.js.map",
|
||||
"main.e69a9816.js.map": "/static/js/main.e69a9816.js.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",
|
||||
"900.5027b0a1.chunk.css.map": "/static/css/900.5027b0a1.chunk.css.map",
|
||||
|
|
@ -21,6 +21,6 @@
|
|||
},
|
||||
"entrypoints": [
|
||||
"static/css/main.fe6c5463.css",
|
||||
"static/js/main.f8361353.js"
|
||||
"static/js/main.e69a9816.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.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>
|
||||
<!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.e69a9816.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
|
|
@ -40,7 +40,7 @@ DEFAULT_LOG_LEVEL = "INFO"
|
|||
DEFAULT_MAX_SQUEAKS = 10000
|
||||
DEFAULT_MAX_SQUEAKS_PER_PUBLIC_KEY_PER_BLOCK = 100
|
||||
DEFAULT_SERVER_RPC_HOST = "0.0.0.0"
|
||||
DEFAULT_SERVER_RPC_PORT = 8555
|
||||
DEFAULT_SERVER_RPC_PORT = None
|
||||
DEFAULT_EXTERNAL_PORT = 8555
|
||||
DEFAULT_ADMIN_RPC_HOST = "0.0.0.0"
|
||||
DEFAULT_ADMIN_RPC_PORT = 8994
|
||||
|
|
@ -48,20 +48,17 @@ DEFAULT_WEBADMIN_HOST = "0.0.0.0"
|
|||
DEFAULT_WEBADMIN_PORT = 12994
|
||||
DEFAULT_BITCOIN_RPC_HOST = "localhost"
|
||||
DEFAULT_BITCOIN_RPC_PORT = 18334
|
||||
DEFAULT_BITCOIN_ZEROMQ_HASHBLOCK_PORT = 28334
|
||||
BITCOIN_RPC_PORT = {
|
||||
"mainnet": 8332,
|
||||
"testnet": 18332,
|
||||
"simnet": 18556,
|
||||
}
|
||||
DEFAULT_LIGHTNING_BACKEND = "lnd"
|
||||
DEFAULT_LND_PORT = 9735
|
||||
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_PATH = str(Path.home() / DEFAULT_SQK_DIR)
|
||||
DEFAULT_LND_RPC_HOST = "localhost"
|
||||
DEFAULT_LND_HOST = "localhost"
|
||||
DEFAULT_INTEREST_BLOCK_INTERVAL = 2016
|
||||
DEFAULT_SENT_OFFER_RETENTION_S = 86400
|
||||
DEFAULT_RECEIVED_OFFER_RETENTION_S = 86400
|
||||
|
|
@ -81,19 +78,18 @@ class BitcoinConfig(Config):
|
|||
rpc_pass = key(cast=str, required=False, default="")
|
||||
rpc_use_ssl = key(cast=bool, required=False, default=False)
|
||||
rpc_ssl_cert = key(cast=str, required=False, default="")
|
||||
zeromq_hashblock_port = key(cast=int, required=False,
|
||||
default=DEFAULT_BITCOIN_ZEROMQ_HASHBLOCK_PORT)
|
||||
|
||||
|
||||
@section('lightning')
|
||||
class LightningConfig(Config):
|
||||
backend = key(cast=str, required=False, default=DEFAULT_LIGHTNING_BACKEND)
|
||||
@section('lnd')
|
||||
class LndConfig(Config):
|
||||
host = key(cast=str, required=False, default=DEFAULT_LND_HOST)
|
||||
external_host = key(cast=str, required=False, default="")
|
||||
external_port = key(cast=int, required=False, default=DEFAULT_LND_PORT)
|
||||
lnd_rpc_host = key(cast=str, required=False, default=DEFAULT_LND_RPC_HOST)
|
||||
lnd_rpc_port = key(cast=int, required=False, default=DEFAULT_LND_RPC_PORT)
|
||||
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)
|
||||
port = key(cast=int, required=False, default=DEFAULT_LND_PORT)
|
||||
rpc_port = key(cast=int, required=False, default=DEFAULT_LND_RPC_PORT)
|
||||
tls_cert_path = key(cast=str, required=False, default="")
|
||||
macaroon_path = key(cast=str, required=False, default="")
|
||||
|
||||
|
||||
@section('tor')
|
||||
|
|
@ -106,7 +102,7 @@ class TorConfig(Config):
|
|||
class ServerConfig(Config):
|
||||
enabled = key(cast=bool, required=False, default=True)
|
||||
host = key(cast=str, required=False, default=DEFAULT_SERVER_RPC_HOST)
|
||||
port = key(cast=int, required=False, default=0)
|
||||
port = key(cast=int, required=False, default=DEFAULT_SERVER_RPC_PORT)
|
||||
external_address = key(cast=str, required=False, default="")
|
||||
external_port = key(cast=int, required=False,
|
||||
default=DEFAULT_EXTERNAL_PORT)
|
||||
|
|
@ -176,7 +172,7 @@ class TwitterConfig(Config):
|
|||
|
||||
class SqueaknodeConfig(Config):
|
||||
bitcoin = group_key(BitcoinConfig)
|
||||
lightning = group_key(LightningConfig)
|
||||
lnd = group_key(LndConfig)
|
||||
tor = group_key(TorConfig)
|
||||
server = group_key(ServerConfig)
|
||||
rpc = group_key(RpcConfig)
|
||||
|
|
|
|||
|
|
@ -26,13 +26,8 @@ from squeaknode.core.squeak_peer import SqueakPeer
|
|||
def create_saved_peer(
|
||||
peer_name: str,
|
||||
peer_address: PeerAddress,
|
||||
default_peer_port: int,
|
||||
) -> SqueakPeer:
|
||||
validate_saved_peer_name(peer_name)
|
||||
if peer_address.port == 0:
|
||||
peer_address = peer_address._replace(
|
||||
port=default_peer_port,
|
||||
)
|
||||
return SqueakPeer(
|
||||
peer_id=None,
|
||||
peer_name=peer_name,
|
||||
|
|
|
|||
|
|
@ -24,11 +24,13 @@ from typing import Callable
|
|||
from typing import Optional
|
||||
from typing import Tuple
|
||||
|
||||
import grpc
|
||||
from bitcoin.core import CBlockHeader
|
||||
from squeak.core import CBaseSqueak
|
||||
from squeak.core import CSqueak
|
||||
|
||||
from squeaknode.bitcoin.bitcoin_client import BitcoinClient
|
||||
from squeaknode.core.exception import InvoiceSubscriptionError
|
||||
from squeaknode.core.lightning_address import LightningAddressHostPort
|
||||
from squeaknode.core.offer import Offer
|
||||
from squeaknode.core.peer_address import PeerAddress
|
||||
|
|
@ -413,20 +415,25 @@ class SqueakCore:
|
|||
|
||||
def get_payment_stream():
|
||||
# Yield the received payments.
|
||||
for invoice in invoice_stream.result_stream:
|
||||
payment_hash = invoice.r_hash
|
||||
settle_index = invoice.settle_index
|
||||
sent_offer = get_sent_offer_fn(payment_hash)
|
||||
if sent_offer is not None:
|
||||
yield ReceivedPayment(
|
||||
received_payment_id=None,
|
||||
created_time_ms=None,
|
||||
squeak_hash=sent_offer.squeak_hash,
|
||||
payment_hash=sent_offer.payment_hash,
|
||||
price_msat=sent_offer.price_msat,
|
||||
settle_index=settle_index,
|
||||
peer_address=sent_offer.peer_address,
|
||||
)
|
||||
try:
|
||||
for invoice in invoice_stream.result_stream:
|
||||
if invoice.settled:
|
||||
payment_hash = invoice.r_hash
|
||||
settle_index = invoice.settle_index
|
||||
sent_offer = get_sent_offer_fn(payment_hash)
|
||||
if sent_offer is not None:
|
||||
yield ReceivedPayment(
|
||||
received_payment_id=None,
|
||||
created_time_ms=None,
|
||||
squeak_hash=sent_offer.squeak_hash,
|
||||
payment_hash=sent_offer.payment_hash,
|
||||
price_msat=sent_offer.price_msat,
|
||||
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(
|
||||
cancel_fn=cancel_subscription,
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ from squeaknode.db.models import Models
|
|||
|
||||
# this is the Alembic Config object, which provides
|
||||
# access to the values within the .ini file in use.
|
||||
config = context.config # type: ignore
|
||||
config = context.config
|
||||
|
||||
# Interpret the config file for Python logging.
|
||||
# This line sets up loggers basically.
|
||||
|
|
|
|||
|
|
@ -1,140 +0,0 @@
|
|||
# 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,13 +34,6 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
class LightningClient(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def init(self):
|
||||
"""Initialize the lightning client.
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def get_info(self) -> Info:
|
||||
"""Get info about the lightning node.
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import grpc
|
|||
|
||||
from proto import lnd_pb2
|
||||
from proto import lnd_pb2_grpc
|
||||
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
|
||||
|
|
@ -166,25 +165,7 @@ class LNDLightningClient(LightningClient):
|
|||
subscribe_result = self.stub.SubscribeInvoices(
|
||||
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(
|
||||
cancel=subscribe_result.cancel,
|
||||
result_stream=get_invoice_stream(),
|
||||
result_stream=iter(subscribe_result),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -62,6 +62,19 @@ def parse_args():
|
|||
return parser.parse_args()
|
||||
|
||||
|
||||
def get_ascii_name():
|
||||
return r"""
|
||||
_____ _ _
|
||||
/ ____| | | | |
|
||||
| (___ __ _ _ _ ___ __ _| | ___ __ ___ __| | ___
|
||||
\___ \ / _` | | | |/ _ \/ _` | |/ / '_ \ / _ \ / _` |/ _ \
|
||||
____) | (_| | |_| | __/ (_| | <| | | | (_) | (_| | __/
|
||||
|_____/ \__, |\__,_|\___|\__,_|_|\_\_| |_|\___/ \__,_|\___|
|
||||
| |
|
||||
|_|
|
||||
"""
|
||||
|
||||
|
||||
def main():
|
||||
logging.basicConfig(level=logging.ERROR)
|
||||
args = parse_args()
|
||||
|
|
@ -81,6 +94,7 @@ def main():
|
|||
|
||||
|
||||
def run_node(config):
|
||||
logger.info(get_ascii_name())
|
||||
logger.info("Config: {}".format(config))
|
||||
signal(SIGTERM, handler)
|
||||
signal(SIGINT, handler)
|
||||
|
|
|
|||
|
|
@ -91,9 +91,7 @@ class PaymentProcessorTask:
|
|||
def process_subscribed_invoices(self):
|
||||
while not self.stopped.is_set():
|
||||
try:
|
||||
# Use zero as starting settle index, so that no invoices are skipped.
|
||||
# latest_settle_index = self.get_latest_settle_index()
|
||||
latest_settle_index = 0
|
||||
latest_settle_index = self.get_latest_settle_index()
|
||||
logger.info("Starting payment subscription with settle index: {}".format(
|
||||
latest_settle_index,
|
||||
))
|
||||
|
|
|
|||
|
|
@ -105,10 +105,10 @@ class SqueakController:
|
|||
peer_address: PeerAddress,
|
||||
) -> Optional[Offer]:
|
||||
lnd_external_address: Optional[LightningAddressHostPort] = None
|
||||
if self.config.lightning.external_host:
|
||||
if self.config.lnd.external_host:
|
||||
lnd_external_address = LightningAddressHostPort(
|
||||
host=self.config.lightning.external_host,
|
||||
port=self.config.lightning.external_port,
|
||||
host=self.config.lnd.external_host,
|
||||
port=self.config.lnd.port,
|
||||
)
|
||||
price_msat = self.get_sell_price_msat()
|
||||
if price_msat == 0:
|
||||
|
|
@ -187,11 +187,7 @@ class SqueakController:
|
|||
return self.squeak_store.get_squeak_profile_private_key(profile_id)
|
||||
|
||||
def create_peer(self, peer_name: str, peer_address: PeerAddress):
|
||||
return self.squeak_store.create_peer(
|
||||
peer_name,
|
||||
peer_address,
|
||||
self.config.server.port or 0,
|
||||
)
|
||||
return self.squeak_store.create_peer(peer_name, peer_address)
|
||||
|
||||
def get_peer(self, peer_id: int) -> Optional[SqueakPeer]:
|
||||
return self.squeak_store.get_peer(peer_id)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ from squeaknode.core.squeak_core import SqueakCore
|
|||
from squeaknode.db.db_engine import get_connection_string
|
||||
from squeaknode.db.db_engine import get_engine
|
||||
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.node.node_settings import NodeSettings
|
||||
from squeaknode.node.payment_processor import PaymentProcessor
|
||||
|
|
@ -49,7 +48,6 @@ from squeaknode.server.app import SqueakPeerWebServer
|
|||
from squeaknode.server.squeak_peer_server_handler import SqueakPeerServerHandler
|
||||
from squeaknode.twitter.twitter_forwarder import TwitterForwarder
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
|
@ -120,21 +118,12 @@ class SqueakNode:
|
|||
self.node_settings = NodeSettings(self.squeak_db)
|
||||
|
||||
def create_lightning_client(self):
|
||||
if self.config.lightning.backend == 'lnd':
|
||||
self.lightning_client = LNDLightningClient(
|
||||
self.config.lightning.lnd_rpc_host,
|
||||
self.config.lightning.lnd_rpc_port,
|
||||
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,
|
||||
))
|
||||
self.lightning_client = LNDLightningClient(
|
||||
self.config.lnd.host,
|
||||
self.config.lnd.rpc_port,
|
||||
self.config.lnd.tls_cert_path,
|
||||
self.config.lnd.macaroon_path,
|
||||
)
|
||||
|
||||
def create_bitcoin_client(self):
|
||||
self.bitcoin_client = BitcoinCoreClient(
|
||||
|
|
@ -228,7 +217,7 @@ class SqueakNode:
|
|||
def create_peer_web_server(self):
|
||||
self.peer_web_server = SqueakPeerWebServer(
|
||||
self.config.server.host,
|
||||
self.config.server.port or squeak.params.params.DEFAULT_PORT,
|
||||
squeak.params.params.DEFAULT_PORT,
|
||||
self.peer_handler,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -389,11 +389,10 @@ class SqueakStore:
|
|||
))
|
||||
return get_profile_private_key(profile)
|
||||
|
||||
def create_peer(self, peer_name: str, peer_address: PeerAddress, default_peer_port):
|
||||
def create_peer(self, peer_name: str, peer_address: PeerAddress):
|
||||
squeak_peer = create_saved_peer(
|
||||
peer_name,
|
||||
peer_address,
|
||||
default_peer_port,
|
||||
)
|
||||
return self.squeak_db.insert_peer(squeak_peer)
|
||||
|
||||
|
|
|
|||
|
|
@ -77,9 +77,8 @@ def create_app(handler):
|
|||
@app.route('/offer/<hash>')
|
||||
def offer(hash):
|
||||
client_host = request.remote_addr
|
||||
client_port = request.environ.get('REMOTE_PORT') or 0
|
||||
try:
|
||||
offer = handler.handle_get_offer(hash, client_host, client_port)
|
||||
offer = handler.handle_get_offer(hash, client_host)
|
||||
except NotFoundError:
|
||||
return "Not found", 404
|
||||
return jsonify({
|
||||
|
|
|
|||
|
|
@ -75,12 +75,12 @@ class SqueakPeerServerHandler(object):
|
|||
raise NotFoundError()
|
||||
return secret_key
|
||||
|
||||
def handle_get_offer(self, squeak_hash_str, client_host, client_port) -> Offer:
|
||||
def handle_get_offer(self, squeak_hash_str, client_host) -> Offer:
|
||||
squeak_hash = bytes.fromhex(squeak_hash_str)
|
||||
client_addr = PeerAddress(
|
||||
network=Network.IPV4,
|
||||
host=client_host,
|
||||
port=client_port,
|
||||
port=0,
|
||||
)
|
||||
offer = self.squeak_controller.get_packaged_offer(
|
||||
squeak_hash,
|
||||
|
|
|
|||
|
|
@ -31,11 +31,6 @@ def peer_name():
|
|||
yield "fake_peer_name"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def default_peer_port():
|
||||
yield 9999
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def peer_address():
|
||||
yield PeerAddress(
|
||||
|
|
@ -63,37 +58,24 @@ def peer_address_with_no_port():
|
|||
)
|
||||
|
||||
|
||||
def test_create_saved_peer(peer_name, peer_address, default_peer_port):
|
||||
def test_create_saved_peer(peer_name, peer_address):
|
||||
peer = create_saved_peer(
|
||||
peer_name,
|
||||
peer_address,
|
||||
default_peer_port,
|
||||
)
|
||||
|
||||
assert peer.peer_name == peer_name
|
||||
assert peer.address == peer_address
|
||||
|
||||
|
||||
def test_create_saved_peer_empty_name(peer_address, default_peer_port):
|
||||
create_saved_peer("", peer_address, default_peer_port)
|
||||
def test_create_saved_peer_empty_name(peer_address):
|
||||
create_saved_peer("", peer_address)
|
||||
|
||||
|
||||
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):
|
||||
def test_create_saved_peer_use_tor(peer_name, peer_address_with_tor):
|
||||
peer = create_saved_peer(
|
||||
peer_name,
|
||||
peer_address_with_tor,
|
||||
default_peer_port,
|
||||
)
|
||||
|
||||
assert peer.peer_name == peer_name
|
||||
|
|
|
|||
|
|
@ -131,10 +131,9 @@ def failed_payment(payment_request):
|
|||
|
||||
@pytest.fixture
|
||||
def invoice_stream(settled_invoice, unsettled_invoice):
|
||||
# Length of invoices list is 1.
|
||||
invoices = [
|
||||
settled_invoice,
|
||||
# unsettled_invoice,
|
||||
unsettled_invoice,
|
||||
]
|
||||
yield InvoiceStream(
|
||||
cancel=lambda: None,
|
||||
|
|
@ -189,9 +188,6 @@ class MockLightningClient(LightningClient):
|
|||
self.payment = payment
|
||||
self.invoice_stream = invoice_stream
|
||||
|
||||
def init(self):
|
||||
pass
|
||||
|
||||
def get_info(self):
|
||||
return self.info
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ def rpc_invoice(preimage, payment_hash, payment_request, price_msat, creation_da
|
|||
r_hash=payment_hash,
|
||||
payment_request=payment_request,
|
||||
value_msat=price_msat,
|
||||
settled=True,
|
||||
settled=False,
|
||||
settle_index=0,
|
||||
creation_date=creation_date,
|
||||
expiry=expiry,
|
||||
|
|
@ -122,7 +122,7 @@ def invoice(payment_hash, payment_request, price_msat, creation_date, expiry):
|
|||
r_hash=payment_hash,
|
||||
payment_request=payment_request,
|
||||
value_msat=price_msat,
|
||||
settled=True,
|
||||
settled=False,
|
||||
settle_index=0,
|
||||
creation_date=creation_date,
|
||||
expiry=expiry,
|
||||
|
|
|
|||
|
|
@ -167,5 +167,4 @@ def test_create_peer(squeak_store, squeak_controller, peer_address):
|
|||
squeak_store.create_peer.assert_called_with(
|
||||
"fake_peer_name",
|
||||
peer_address,
|
||||
0,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -121,7 +121,6 @@ def gen_squeak_peer(peer_name):
|
|||
return create_saved_peer(
|
||||
peer_name,
|
||||
peer_address,
|
||||
0,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue