Add Palladium testing infrastructure and local regtest setup

This commit finalizes the integration of Palladium Lightning with
the Palladium Core backend, making it trivial for developers to
spin up and test a local regtest network.

Key changes:
- Created [TESTING_PALLADIUM.md](cci:7://file:///home/davide/lightning-plm/TESTING_PALLADIUM.md:0:0-0:0) with comprehensive regtest instructions.
- Linked the new testing guide in the main [README.md](cci:7://file:///home/davide/lightning-plm/README.md:0:0-0:0).
- Ignored `/palladium-bin/` in `.gitignore` to allow developers to drop
  backend binaries locally without accidentally committing them.
- Patched `contrib/startup_regtest.sh` to automatically detect and use
  these local `palladiumd`/`palladium-cli` binaries if present, removing
  the strict need to manually export environment variables.
- Fixed a false-positive timeout error in `startup_regtest.sh` when
  parsing the absent `clnrest` plugin logs
This commit is contained in:
2026-02-20 14:10:53 +01:00
parent 8193fbce55
commit ee8dccdd4d
11 changed files with 435 additions and 127 deletions

4
.gitignore vendored
View File

@@ -23,6 +23,10 @@ gen_*.c
gen_*.h
wire/gen_*_csv
cli/lightning-cli
# Custom local binaries for testing
/palladium-bin/
coverage
# Coverage profiling data files
*.profraw

View File

@@ -19,6 +19,10 @@ Palladium Lightning aims to be lightweight, highly customizable, and fully compl
To compile the source code, please refer to the updated instructions or refer to the original installation documentation available in `doc/getting-started/getting-started/installation.md`.
## Testing
For instructions on how to test Palladium Lightning against a local Palladium Regtest network, please refer to the dedicated guide: **[TESTING_PALLADIUM.md](TESTING_PALLADIUM.md)**.
## License
The code is released under the BSD-MIT License. See the [LICENSE](LICENSE) file for more details.

106
TESTING_PALLADIUM.md Normal file
View File

@@ -0,0 +1,106 @@
# Testing Palladium Lightning
This guide explains how to test the Palladium Lightning (`lightning-plm`) integration with Palladium Core (`palladiumcore`) on your local machine using a Regtest environment.
## Prerequisites
1. **Palladium Core**: You must have `palladiumd` and `palladium-cli` compiled.
2. **Palladium Lightning**: Ensure you have successfully compiled this repository (`make`).
3. **Dependencies**: Make sure you have `bash` and standard Unix utilities installed.
## 1. Regtest Setup
The easiest way to test channels and interactions is by using the provided `startup_regtest.sh` script. This script automatically spins up a local Palladium Regtest network alongside 3 Lightning nodes.
First, you need to make the Palladium binaries accessible to the test scripts. The simplest method is to copy them directly into a `palladium-bin` directory in the root of the repository:
```bash
mkdir -p palladium-bin
cp /path/to/palladiumcore/src/palladiumd palladium-bin/
cp /path/to/palladiumcore/src/palladium-cli palladium-bin/
```
*(Note: The `palladium-bin` directory is correctly ignored by git, so your local binaries won't be pushed).*
Alternatively, you can skip copying the binaries and specify their path manually using an environment variable before running the script:
```bash
export PALLADIUM_BIN=/path/to/palladiumcore/src
```
Then, initialize the test environment using the startup script:
```bash
# Sourcing the script loads useful aliases into your terminal
source contrib/startup_regtest.sh
# Start the cluster with 3 nodes
start_ln 3
```
## 2. Using the Aliases
Once the cluster is running, the script creates several handy aliases to interact with the nodes easily.
- **`bt-cli`**: Connects to the local Palladium backend.
```bash
bt-cli getblockchaininfo
```
- **`l1-cli`, `l2-cli`, `l3-cli`**: Connects to the respective Lightning nodes.
```bash
l1-cli getinfo
l2-cli newaddr
```
## 3. Funding and Connecting Nodes
To test the complete lifecycle of a Lightning channel, you can automatically fund the nodes and connect them together with a single command:
```bash
fund_nodes
```
This will:
1. Generate some Palladium blocks to fund the default wallet.
2. Connect `l1` to `l2`, and `l2` to `l3`.
3. Fund the channels automatically and mine the necessary confirmation blocks.
You can verify the channels by running:
```bash
l1-cli listchannels
```
## 4. Teardown
When you are finished testing, cleanly shut down the environment and remove the temporary data.
```bash
# Stop the Palladium and Lightning daemons
stop_ln
# Clean up the temporary node directories in /tmp
destroy_ln
```
## Running Python Integration Tests
If you want to run the automated Python test suite against the Palladium backend:
1. Install the testing dependencies:
```bash
pip3 install -r contrib/pyln-testing/requirements.txt
```
2. Run pytest from the root of the repository:
```bash
pytest tests/
```
*(Note: Be sure your environment variables correctly point to your Palladium binaries if they are not system-wide installed).*

View File

@@ -27,17 +27,17 @@ static u8 liquid_regtest_fee_asset[] = {
const struct chainparams networks[] = {
{.network_name = "bitcoin",
.onchain_hrp = "bc",
.lightning_hrp = "bc",
.onchain_hrp = "plm",
.lightning_hrp = "plm",
.bip70_name = "main",
.genesis_blockhash = {{{.u.u8 = {0x6f, 0xe2, 0x8c, 0x0a, 0xb6, 0xf1, 0xb3,
0x72, 0xc1, 0xa6, 0xa2, 0x46, 0xae, 0x63,
0xf7, 0x4f, 0x93, 0x1e, 0x83, 0x65, 0xe1,
0x5a, 0x08, 0x9c, 0x68, 0xd6, 0x19, 0x00,
0x00, 0x00, 0x00, 0x00}}}},
.rpc_port = 8332,
.rpc_port = 2332,
.ln_port = 9735,
.cli = "bitcoin-cli",
.cli = "palladium-cli",
.cli_args = NULL,
.cli_min_supported_version = 150000,
.dust_limit = { 546 },
@@ -52,7 +52,7 @@ const struct chainparams networks[] = {
.max_supply = AMOUNT_SAT_INIT(2100000000000000),
/* "Lightning Charge Powers Developers & Blockstream Store" */
.when_lightning_became_cool = 504500,
.p2pkh_version = 0,
.p2pkh_version = 55,
.p2sh_version = 5,
.testnet = false,
.fee_asset_tag = NULL,
@@ -60,17 +60,17 @@ const struct chainparams networks[] = {
.bip32_privkey_version = BIP32_VER_MAIN_PRIVATE},
.is_elements = false},
{.network_name = "regtest",
.onchain_hrp = "bcrt",
.lightning_hrp = "bcrt",
.onchain_hrp = "rplm",
.lightning_hrp = "rplm",
.bip70_name = "regtest",
.genesis_blockhash = {{{.u.u8 = {0x06, 0x22, 0x6e, 0x46, 0x11, 0x1a, 0x0b,
0x59, 0xca, 0xaf, 0x12, 0x60, 0x43, 0xeb,
0x5b, 0xbf, 0x28, 0xc3, 0x4f, 0x3a, 0x5e,
0x33, 0x2a, 0x1f, 0xc7, 0xb2, 0xb7, 0x3c,
0xf1, 0x88, 0x91, 0x0f}}}},
.rpc_port = 18443,
.rpc_port = 12443,
.ln_port = 19846,
.cli = "bitcoin-cli",
.cli = "palladium-cli",
.cli_args = "-regtest",
.cli_min_supported_version = 150000,
.dust_limit = { 546 },
@@ -78,16 +78,16 @@ const struct chainparams networks[] = {
.max_payment = AMOUNT_MSAT_INIT(0xFFFFFFFFULL),
.max_supply = AMOUNT_SAT_INIT(2100000000000000),
.when_lightning_became_cool = 1,
.p2pkh_version = 111,
.p2sh_version = 196,
.p2pkh_version = 127,
.p2sh_version = 115,
.testnet = true,
.fee_asset_tag = NULL,
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_TEST_PUBLIC,
.bip32_privkey_version = BIP32_VER_TEST_PRIVATE},
.is_elements = false},
{.network_name = "signet",
.onchain_hrp = "tb",
.lightning_hrp = "tbs",
.onchain_hrp = "tplm",
.lightning_hrp = "tsplm",
.bip70_name = "signet",
// 00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6
.genesis_blockhash = {{{.u.u8 = {0xf6, 0x1e, 0xee, 0x3b, 0x63, 0xa3, 0x80,
@@ -97,7 +97,7 @@ const struct chainparams networks[] = {
0x08, 0x00, 0x00, 0x00}}}},
.rpc_port = 38332,
.ln_port = 39735,
.cli = "bitcoin-cli",
.cli = "palladium-cli",
.cli_args = "-signet",
.cli_min_supported_version = 150000,
.dust_limit = { 546 },
@@ -105,40 +105,40 @@ const struct chainparams networks[] = {
.max_payment = AMOUNT_MSAT_INIT(0xFFFFFFFFULL),
.max_supply = AMOUNT_SAT_INIT(2100000000000000),
.when_lightning_became_cool = 1,
.p2pkh_version = 111,
.p2sh_version = 196,
.p2pkh_version = 127,
.p2sh_version = 115,
.testnet = true,
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_SIGT_PUBLIC, .bip32_privkey_version = BIP32_VER_SIGT_PRIVATE},
.is_elements = false,
},
{.network_name = "testnet",
.onchain_hrp = "tb",
.lightning_hrp = "tb",
.onchain_hrp = "tplm",
.lightning_hrp = "tplm",
.bip70_name = "test",
.genesis_blockhash = {{{.u.u8 = {0x43, 0x49, 0x7f, 0xd7, 0xf8, 0x26, 0x95,
0x71, 0x08, 0xf4, 0xa3, 0x0f, 0xd9, 0xce,
0xc3, 0xae, 0xba, 0x79, 0x97, 0x20, 0x84,
0xe9, 0x0e, 0xad, 0x01, 0xea, 0x33, 0x09,
0x00, 0x00, 0x00, 0x00}}}},
.rpc_port = 18332,
.rpc_port = 12332,
.ln_port = 19735,
.cli = "bitcoin-cli",
.cli = "palladium-cli",
.cli_args = "-testnet",
.cli_min_supported_version = 150000,
.dust_limit = { 546 },
.max_funding = AMOUNT_SAT_INIT((1 << 24) - 1),
.max_payment = AMOUNT_MSAT_INIT(0xFFFFFFFFULL),
.max_supply = AMOUNT_SAT_INIT(2100000000000000),
.p2pkh_version = 111,
.p2sh_version = 196,
.p2pkh_version = 127,
.p2sh_version = 115,
.testnet = true,
.fee_asset_tag = NULL,
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_TEST_PUBLIC,
.bip32_privkey_version = BIP32_VER_TEST_PRIVATE},
.is_elements = false},
{.network_name = "testnet4",
.onchain_hrp = "tb",
.lightning_hrp = "tb",
.onchain_hrp = "tplm",
.lightning_hrp = "tplm",
.bip70_name = "testnet4",
// 00000000da84f2bafbbc53dee25a72ae507ff4914b867c565be350b0da8bf043
.genesis_blockhash = {{{.u.u8 = {0x43, 0xf0, 0x8b, 0xda, 0xb0, 0x50, 0xe3,
@@ -148,15 +148,15 @@ const struct chainparams networks[] = {
0x00, 0x00, 0x00, 0x00}}}},
.rpc_port = 48332,
.ln_port = 49735,
.cli = "bitcoin-cli",
.cli = "palladium-cli",
.cli_args = "-testnet4",
.cli_min_supported_version = 150000,
.dust_limit = { 546 },
.max_funding = AMOUNT_SAT_INIT((1 << 24) - 1),
.max_payment = AMOUNT_MSAT_INIT(0xFFFFFFFFULL),
.max_supply = AMOUNT_SAT_INIT(2100000000000000),
.p2pkh_version = 111,
.p2sh_version = 196,
.p2pkh_version = 127,
.p2sh_version = 115,
.testnet = true,
.fee_asset_tag = NULL,
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_TEST_PUBLIC,

91
ccan/config.h.56641 Normal file
View File

@@ -0,0 +1,91 @@
/* Generated by CCAN configurator */
#ifndef CCAN_CONFIG_H
#define CCAN_CONFIG_H
#ifndef _GNU_SOURCE
#define _GNU_SOURCE /* Always use GNU extensions. */
#endif
#define CCAN_COMPILER "cc"
#define CCAN_CFLAGS "-Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition -Werror -std=gnu11 -g -fstack-protector-strong -Og -ffunction-sections -I/usr/local/lib -L/usr/local/lib"
#define CCAN_OUTPUT_EXE_CFLAG "-o"
#define HAVE_CCAN 1
#define HAVE_32BIT_OFF_T 0
#define HAVE_ALIGNOF 1
#define HAVE_ASPRINTF 1
#define HAVE_ATTRIBUTE_COLD 1
#define HAVE_ATTRIBUTE_CONST 1
#define HAVE_ATTRIBUTE_DEPRECATED 1
#define HAVE_ATTRIBUTE_NONNULL 1
#define HAVE_ATTRIBUTE_RETURNS_NONNULL 1
#define HAVE_ATTRIBUTE_SENTINEL 1
#define HAVE_ATTRIBUTE_PURE 1
#define HAVE_ATTRIBUTE_MAY_ALIAS 1
#define HAVE_ATTRIBUTE_NORETURN 1
#define HAVE_ATTRIBUTE_PRINTF 1
#define HAVE_ATTRIBUTE_UNUSED 1
#define HAVE_ATTRIBUTE_USED 1
#define HAVE_BACKTRACE 1
#define HAVE_BIG_ENDIAN 0
#define HAVE_BSWAP_64 1
#define HAVE_BUILTIN_CHOOSE_EXPR 1
#define HAVE_BUILTIN_CLZ 1
#define HAVE_BUILTIN_CLZL 1
#define HAVE_BUILTIN_CLZLL 1
#define HAVE_BUILTIN_CTZ 1
#define HAVE_BUILTIN_CTZL 1
#define HAVE_BUILTIN_CTZLL 1
#define HAVE_BUILTIN_CONSTANT_P 1
#define HAVE_BUILTIN_EXPECT 1
#define HAVE_BUILTIN_FFS 1
#define HAVE_BUILTIN_FFSL 1
#define HAVE_BUILTIN_FFSLL 1
#define HAVE_BUILTIN_POPCOUNT 1
#define HAVE_BUILTIN_POPCOUNTL 1
#define HAVE_BUILTIN_POPCOUNTLL 1
#define HAVE_BUILTIN_TYPES_COMPATIBLE_P 1
#define HAVE_ICCARM_INTRINSICS 0
#define HAVE_BYTESWAP_H 1
#define HAVE_CLOCK_GETTIME 1
#define HAVE_CLOCK_GETTIME_IN_LIBRT 0
#define HAVE_COMPOUND_LITERALS 1
#define HAVE_FCHDIR 1
#define HAVE_ERR_H 1
#define HAVE_FILE_OFFSET_BITS 0
#define HAVE_FOR_LOOP_DECLARATION 1
#define HAVE_FLEXIBLE_ARRAY_MEMBER 1
#define HAVE_GETPAGESIZE 1
#define HAVE_ISBLANK 1
#define HAVE_LITTLE_ENDIAN 1
#define HAVE_MEMMEM 1
#define HAVE_MEMRCHR 1
#define HAVE_MMAP 1
#define HAVE_PROC_SELF_MAPS 1
#define HAVE_QSORT_R_PRIVATE_LAST 1
#define HAVE_STRUCT_TIMESPEC 1
#define HAVE_SECTION_START_STOP 1
#define HAVE_STACK_GROWS_UPWARDS 0
#define HAVE_STATEMENT_EXPR 1
#define HAVE_SYS_FILIO_H 0
#define HAVE_SYS_TERMIOS_H 1
#define HAVE_SYS_UNISTD_H 1
#define HAVE_TYPEOF 1
#define HAVE_UNALIGNED_ACCESS 1
#define HAVE_UTIME 1
#define HAVE_WARN_UNUSED_RESULT 1
#define HAVE_OPENMP 1
#define HAVE_VALGRIND_MEMCHECK_H 1
#define HAVE_UCONTEXT 1
#define HAVE_POINTER_SAFE_MAKECONTEXT 1
#define HAVE_BUILTIN_CPU_SUPPORTS 1
#define HAVE_CLOSEFROM 1
#define HAVE_F_CLOSEM 0
#define HAVE_NR_CLOSE_RANGE 1
#define HAVE_F_MAXFD 0
#define HAVE_ZLIB 1
#define HAVE_GOOD_LIBSODIUM 1
#define HAVE_SQLITE3 0
#define HAVE_POSTGRES 0
#define HAVE_USDT 0
#define HAVE_GCC 1
#define HAVE_MODERN_GCC 1
#endif /* CCAN_CONFIG_H */

93
ccan/config.h.58384 Normal file
View File

@@ -0,0 +1,93 @@
/* Generated by CCAN configurator */
#ifndef CCAN_CONFIG_H
#define CCAN_CONFIG_H
#ifndef _GNU_SOURCE
#define _GNU_SOURCE /* Always use GNU extensions. */
#endif
#define CCAN_COMPILER "cc"
#define CCAN_CFLAGS "-Wall -Wundef -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wold-style-definition -Werror -std=gnu11 -g -fstack-protector-strong -Og -ffunction-sections -I/usr/local/lib -L/usr/local/lib"
#define CCAN_OUTPUT_EXE_CFLAG "-o"
#define HAVE_CCAN 1
#define HAVE_32BIT_OFF_T 0
#define HAVE_ALIGNOF 1
#define HAVE_ASPRINTF 1
#define HAVE_ATTRIBUTE_COLD 1
#define HAVE_ATTRIBUTE_CONST 1
#define HAVE_ATTRIBUTE_DEPRECATED 1
#define HAVE_ATTRIBUTE_NONNULL 1
#define HAVE_ATTRIBUTE_RETURNS_NONNULL 1
#define HAVE_ATTRIBUTE_SENTINEL 1
#define HAVE_ATTRIBUTE_PURE 1
#define HAVE_ATTRIBUTE_MAY_ALIAS 1
#define HAVE_ATTRIBUTE_NORETURN 1
#define HAVE_ATTRIBUTE_PRINTF 1
#define HAVE_ATTRIBUTE_UNUSED 1
#define HAVE_ATTRIBUTE_USED 1
#define HAVE_BACKTRACE 1
#define HAVE_BIG_ENDIAN 0
#define HAVE_BSWAP_64 1
#define HAVE_BUILTIN_CHOOSE_EXPR 1
#define HAVE_BUILTIN_CLZ 1
#define HAVE_BUILTIN_CLZL 1
#define HAVE_BUILTIN_CLZLL 1
#define HAVE_BUILTIN_CTZ 1
#define HAVE_BUILTIN_CTZL 1
#define HAVE_BUILTIN_CTZLL 1
#define HAVE_BUILTIN_CONSTANT_P 1
#define HAVE_BUILTIN_EXPECT 1
#define HAVE_BUILTIN_FFS 1
#define HAVE_BUILTIN_FFSL 1
#define HAVE_BUILTIN_FFSLL 1
#define HAVE_BUILTIN_POPCOUNT 1
#define HAVE_BUILTIN_POPCOUNTL 1
#define HAVE_BUILTIN_POPCOUNTLL 1
#define HAVE_BUILTIN_TYPES_COMPATIBLE_P 1
#define HAVE_ICCARM_INTRINSICS 0
#define HAVE_BYTESWAP_H 1
#define HAVE_CLOCK_GETTIME 1
#define HAVE_CLOCK_GETTIME_IN_LIBRT 0
#define HAVE_COMPOUND_LITERALS 1
#define HAVE_FCHDIR 1
#define HAVE_ERR_H 1
#define HAVE_FILE_OFFSET_BITS 0
#define HAVE_FOR_LOOP_DECLARATION 1
#define HAVE_FLEXIBLE_ARRAY_MEMBER 1
#define HAVE_GETPAGESIZE 1
#define HAVE_ISBLANK 1
#define HAVE_LITTLE_ENDIAN 1
#define HAVE_MEMMEM 1
#define HAVE_MEMRCHR 1
#define HAVE_MMAP 1
#define HAVE_PROC_SELF_MAPS 1
#define HAVE_QSORT_R_PRIVATE_LAST 1
#define HAVE_STRUCT_TIMESPEC 1
#define HAVE_SECTION_START_STOP 1
#define HAVE_STACK_GROWS_UPWARDS 0
#define HAVE_STATEMENT_EXPR 1
#define HAVE_SYS_FILIO_H 0
#define HAVE_SYS_TERMIOS_H 1
#define HAVE_SYS_UNISTD_H 1
#define HAVE_TYPEOF 1
#define HAVE_UNALIGNED_ACCESS 1
#define HAVE_UTIME 1
#define HAVE_WARN_UNUSED_RESULT 1
#define HAVE_OPENMP 1
#define HAVE_VALGRIND_MEMCHECK_H 1
#define HAVE_UCONTEXT 1
#define HAVE_POINTER_SAFE_MAKECONTEXT 1
#define HAVE_BUILTIN_CPU_SUPPORTS 1
#define HAVE_CLOSEFROM 1
#define HAVE_F_CLOSEM 0
#define HAVE_NR_CLOSE_RANGE 1
#define HAVE_F_MAXFD 0
#define HAVE_ZLIB 1
#define HAVE_GOOD_LIBSODIUM 1
#define HAVE_SQLITE3 0
#define HAVE_POSTGRES 0
#define HAVE_USDT 0
#define HAVE_GCC 1
#define HAVE_MODERN_GCC 1
#endif /* CCAN_CONFIG_H */
#define COMPAT 1
#include "ccan_compat.h"

View File

@@ -1,6 +1,6 @@
from concurrent import futures
from pyln.testing.db import SqliteDbProvider, PostgresDbProvider
from pyln.testing.utils import NodeFactory, BitcoinD, ElementsD, env, LightningNode, TEST_DEBUG, TEST_NETWORK, SLOW_MACHINE, VALGRIND
from pyln.testing.utils import NodeFactory, PalladiumD, ElementsD, env, LightningNode, TEST_DEBUG, TEST_NETWORK, SLOW_MACHINE, VALGRIND
from pyln.client import Millisatoshi
from typing import Dict
from pathlib import Path
@@ -117,7 +117,7 @@ def test_name(request):
network_daemons = {
'regtest': BitcoinD,
'regtest': PalladiumD,
'liquid-regtest': ElementsD,
}

View File

@@ -451,7 +451,7 @@ class SimpleBitcoinProxy:
class BitcoinD(TailableProc):
def __init__(self, bitcoin_dir="/tmp/bitcoind-test", rpcport=None):
def __init__(self, bitcoin_dir="/tmp/palladiumd-test", rpcport=None):
TailableProc.__init__(self, bitcoin_dir, verbose=False)
if rpcport is None:
@@ -462,7 +462,7 @@ class BitcoinD(TailableProc):
self.bitcoin_dir = bitcoin_dir
self.rpcport = rpcport
self.prefix = 'bitcoind'
self.prefix = 'palladiumd'
self.canned_blocks = None
regtestdir = os.path.join(bitcoin_dir, 'regtest')
@@ -743,7 +743,7 @@ class LightningD(TailableProc):
'bitcoin-rpcpassword': BITCOIND_CONFIG['rpcpassword'],
# Make sure we don't touch any existing config files in the user's $HOME
'bitcoin-datadir': lightning_dir,
'palladium-datadir': lightning_dir,
}
for k, v in opts.items():
@@ -1163,7 +1163,7 @@ class LightningNode(object):
def is_synced_with_bitcoin(self, info=None):
if info is None:
info = self.rpc.getinfo()
return 'warning_bitcoind_sync' not in info and 'warning_lightningd_sync' not in info
return 'warning_palladiumd_sync' not in info and 'warning_lightningd_sync' not in info
def start(self, wait_for_bitcoind_sync=True, stderr_redir=False):
# If we have a disconnect string, dump it to a file for daemon.

View File

@@ -30,7 +30,7 @@
# We've got a legacy problem is that PATH_TO_LIGHTNING is the
# path to the lightningd / lightning-cli and PATH_TO_BITCOIN
# is the path to the bitcoin data dir. These are not the same
# is the path to the palladium data dir. These are not the same
# things (data directories vs binary locations).
# Ideally we'd let users set each of these four
# things independently. Unless we rename stuff, this going to
@@ -43,8 +43,8 @@ if [ -n "$PATH_TO_LIGHTNING" ]; then
return 1
fi
if [ -n "$PATH_TO_BITCOIN" ]; then
echo PATH_TO_BITCOIN is no longer supported, please use BITCOIN_DIR
if [ -n "$PATH_TO_PALLADIUM" ]; then
echo PATH_TO_PALLADIUM is no longer supported, please use PALLADIUM_DIR
return 1
fi
@@ -82,37 +82,45 @@ if [ -z "$LIGHTNING_DIR" ]; then
LIGHTNING_DIR=/tmp
fi
if [ -z "$BITCOIN_DIR" ]; then
if [ -d "$HOME/snap/bitcoin-core/common/.bitcoin" ]; then
BITCOIN_DIR="$HOME/snap/bitcoin-core/common/.bitcoin"
elif [ -d "$HOME/.bitcoin" ]; then
BITCOIN_DIR="$HOME/.bitcoin"
elif [ -d "$HOME/Library/Application Support/Bitcoin/" ]; then
BITCOIN_DIR="$HOME/Library/Application Support/Bitcoin/"
if [ -z "$PALLADIUM_DIR" ]; then
if [ -d "$HOME/snap/palladium-core/common/.palladium" ]; then
PALLADIUM_DIR="$HOME/snap/palladium-core/common/.palladium"
elif [ -d "$HOME/.palladium" ]; then
PALLADIUM_DIR="$HOME/.palladium"
elif [ -d "$HOME/Library/Application Support/Palladium/" ]; then
PALLADIUM_DIR="$HOME/Library/Application Support/Palladium/"
else
echo "\$BITCOIN_DIR not set to a .bitcoin dir?" >&2
echo "\$PALLADIUM_DIR not set to a .palladium dir?" >&2
return
fi
fi
# shellcheck disable=SC2153
if [ -z "$BITCOIN_BIN" ]; then
# Already installed maybe? Prints
if ! type bitcoin-cli >/dev/null 2>&1 ; then
echo bitcoin-cli: not found
return 1
if [ -z "$PALLADIUM_BIN" ]; then
# Check if the user placed the binaries in palladium-bin
if [ -x "$(pwd)/palladium-bin/palladium-cli" ] && [ -x "$(pwd)/palladium-bin/palladiumd" ]; then
PALLADIUM_BIN="$(pwd)/palladium-bin"
BCLI="$PALLADIUM_BIN/palladium-cli"
BITCOIND="$PALLADIUM_BIN/palladiumd"
else
# Already installed maybe? Prints
if ! type palladium-cli >/dev/null 2>&1 ; then
echo palladium-cli: not found
return 1
fi
if ! type palladiumd >/dev/null 2>&1 ; then
echo palladiumd: not found
return 1
fi
BCLI=palladium-cli
BITCOIND=palladiumd
fi
if ! type bitcoind >/dev/null 2>&1 ; then
echo bitcoind: not found
return 1
fi
BCLI=bitcoin-cli
BITCOIND=bitcoind
else
BCLI="$BITCOIN_BIN"/bitcoin-cli
BITCOIND="$BITCOIN_BIN"/bitcoind
BCLI="$PALLADIUM_BIN"/palladium-cli
BITCOIND="$PALLADIUM_BIN"/palladiumd
fi
export PATH="$PALLADIUM_BIN:$PATH"
echo lightning-cli is "$LCLI"
echo lightningd is "$LIGHTNINGD"
@@ -121,12 +129,12 @@ export LCLI="$LCLI"
export LIGHTNINGD="$LIGHTNINGD"
export LIGHTNING_DIR="$LIGHTNING_DIR"
echo bitcoin-cli is "$BCLI"
echo bitcoind is "$BITCOIND"
echo bitcoin-dir is "$BITCOIN_DIR"
echo palladium-cli is "$BCLI"
echo palladiumd is "$BITCOIND"
echo palladium-dir is "$PALLADIUM_DIR"
export BCLI="$BCLI"
export BITCOIND="$BITCOIND"
export BITCOIN_DIR="$BITCOIN_DIR"
export PALLADIUM_DIR="$PALLADIUM_DIR"
wait_for_lightningd() {
if [ -z "$1" ]; then
@@ -223,7 +231,7 @@ funder-lease-requests-only=false
# Start the lightning nodes
test -f "$LIGHTNING_DIR/l$i/lightningd-$network.pid" || \
$EATMYDATA "$LIGHTNINGD" "--network=$network" "--lightning-dir=$LIGHTNING_DIR/l$i" "--bitcoin-datadir=$BITCOIN_DIR" "--database-upgrade=true" &
$EATMYDATA "$LIGHTNINGD" "--network=$network" "--lightning-dir=$LIGHTNING_DIR/l$i" "--palladium-datadir=$PALLADIUM_DIR" "--palladium-cli=$BCLI" "--database-upgrade=true" &
# shellcheck disable=SC2139 disable=SC2086
alias l$i-cli="$LCLI --lightning-dir=$LIGHTNING_DIR/l$i"
# shellcheck disable=SC2139 disable=SC2086
@@ -243,31 +251,31 @@ funder-lease-requests-only=false
start_ln() {
# Start bitcoind in the background
test -f "$BITCOIN_DIR/regtest/bitcoind.pid" || \
"$BITCOIND" -datadir="$BITCOIN_DIR" -regtest -txindex -fallbackfee=0.00000253 -daemon
test -f "$PALLADIUM_DIR/regtest/palladiumd.pid" || \
"$BITCOIND" -datadir="$PALLADIUM_DIR" -regtest -txindex -fallbackfee=0.00000253 -daemon
# Wait for it to start.
while ! "$BCLI" -datadir="$BITCOIN_DIR" -regtest ping 2> /dev/null; do echo "awaiting bitcoind..." && sleep 1; done
while ! "$BCLI" -datadir="$PALLADIUM_DIR" -regtest ping 2> /dev/null; do echo "awaiting palladiumd..." && sleep 1; done
# Check if default wallet exists
if ! "$BCLI" -datadir="$BITCOIN_DIR" -regtest listwalletdir | jq -r '.wallets[] | .name' | grep -wqe 'default' ; then
if ! "$BCLI" -datadir="$PALLADIUM_DIR" -regtest listwalletdir | jq -r '.wallets[] | .name' | grep -wqe 'default' ; then
# wallet dir does not exist, create one
echo "Making \"default\" bitcoind wallet."
"$BCLI" -datadir="$BITCOIN_DIR" -regtest createwallet default >/dev/null 2>&1
"$BCLI" -datadir="$PALLADIUM_DIR" -regtest createwallet default >/dev/null 2>&1
fi
# Check if default wallet is loaded
if ! "$BCLI" -datadir="$BITCOIN_DIR" -regtest listwallets | jq -r '.[]' | grep -wqe 'default' ; then
echo "Loading \"default\" bitcoind wallet."
"$BCLI" -datadir="$BITCOIN_DIR" -regtest loadwallet default >/dev/null 2>&1
if ! "$BCLI" -datadir="$PALLADIUM_DIR" -regtest listwallets | jq -r '.[]' | grep -wqe 'default' ; then
echo "Loading \"default\" palladiumd wallet."
"$BCLI" -datadir="$PALLADIUM_DIR" -regtest loadwallet default >/dev/null 2>&1
fi
# Kick it out of initialblockdownload if necessary
if "$BCLI" -datadir="$BITCOIN_DIR" -regtest getblockchaininfo | grep -q 'initialblockdownload.*true'; then
"$BCLI" -datadir="$BITCOIN_DIR" -regtest generatetoaddress 1 "$($BCLI -datadir="$BITCOIN_DIR" -regtest getnewaddress)" > /dev/null
if "$BCLI" -datadir="$PALLADIUM_DIR" -regtest getblockchaininfo | grep -q 'initialblockdownload.*true'; then
"$BCLI" -datadir="$PALLADIUM_DIR" -regtest -rpcwallet=default generatetoaddress 1 "$($BCLI -datadir="$PALLADIUM_DIR" -regtest -rpcwallet=default getnewaddress)" > /dev/null
fi
alias bt-cli='"$BCLI" -datadir="$BITCOIN_DIR" -regtest'
alias bt-cli='"$BCLI" -datadir="$PALLADIUM_DIR" -regtest'
if [ -z "$1" ]; then
nodes=2
@@ -278,29 +286,31 @@ start_ln() {
echo " bt-cli, stop_ln, fund_nodes"
wait_for_lightningd "$nodes"
active_status=$(clnrest_status "$LIGHTNING_DIR/l1/log")
if has_clnrest && [ "$active_status" = "active" ] ; then
node_info regtest
elif [ "$active_status" = "disabled" ]; then
echo "clnrest is disabled."
else
echo "timed out parsing log $LIGHTNING_DIR/l1/log"
if has_clnrest; then
active_status=$(clnrest_status "$LIGHTNING_DIR/l1/log")
if [ "$active_status" = "active" ] ; then
node_info regtest
elif [ "$active_status" = "disabled" ]; then
echo "clnrest is disabled."
else
echo "timed out parsing log $LIGHTNING_DIR/l1/log"
fi
fi
}
ensure_bitcoind_funds() {
if [ -z "$ADDRESS" ]; then
ADDRESS=$("$BCLI" -datadir="$BITCOIN_DIR" -regtest "$WALLET" getnewaddress)
ADDRESS=$("$BCLI" -datadir="$PALLADIUM_DIR" -regtest "$WALLET" getnewaddress)
fi
balance=$("$BCLI" -datadir="$BITCOIN_DIR" -regtest "$WALLET" getbalance)
balance=$("$BCLI" -datadir="$PALLADIUM_DIR" -regtest "$WALLET" getbalance)
if [ 1 -eq "$(echo "$balance"'<1' | bc -l)" ]; then
printf "%s" "Mining into address " "$ADDRESS""... "
"$BCLI" -datadir="$BITCOIN_DIR" -regtest generatetoaddress 100 "$ADDRESS" > /dev/null
"$BCLI" -datadir="$PALLADIUM_DIR" -regtest generatetoaddress 100 "$ADDRESS" > /dev/null
echo "done."
fi
@@ -327,11 +337,11 @@ fund_nodes() {
WALLET="-rpcwallet=$WALLET"
ADDRESS=$("$BCLI" -datadir="$BITCOIN_DIR" -regtest "$WALLET" getnewaddress)
ADDRESS=$("$BCLI" -datadir="$PALLADIUM_DIR" -regtest "$WALLET" getnewaddress)
ensure_bitcoind_funds
echo "bitcoind balance:" "$("$BCLI" -datadir="$BITCOIN_DIR" -regtest "$WALLET" getbalance)"
echo "palladiumd balance:" "$("$BCLI" -datadir="$PALLADIUM_DIR" -regtest "$WALLET" getbalance)"
last_node=""
@@ -356,10 +366,10 @@ fund_nodes() {
ensure_bitcoind_funds
"$BCLI" -datadir="$BITCOIN_DIR" -regtest "$WALLET" sendtoaddress "$L1_WALLET_ADDR" 1 > /dev/null
"$BCLI" -datadir="$BITCOIN_DIR" -regtest "$WALLET" sendtoaddress "$L2_WALLET_ADDR" 1 > /dev/null
"$BCLI" -datadir="$PALLADIUM_DIR" -regtest "$WALLET" sendtoaddress "$L1_WALLET_ADDR" 1 > /dev/null
"$BCLI" -datadir="$PALLADIUM_DIR" -regtest "$WALLET" sendtoaddress "$L2_WALLET_ADDR" 1 > /dev/null
"$BCLI" -datadir="$BITCOIN_DIR" -regtest generatetoaddress 1 "$ADDRESS" > /dev/null
"$BCLI" -datadir="$PALLADIUM_DIR" -regtest generatetoaddress 1 "$ADDRESS" > /dev/null
printf "%s" "Waiting for lightning node funds... "
@@ -379,7 +389,7 @@ fund_nodes() {
"$LCLI" --lightning-dir="$LIGHTNING_DIR"/l"$node1" fundchannel "$L2_NODE_ID" 1000000 > /dev/null
"$BCLI" -datadir="$BITCOIN_DIR" -regtest generatetoaddress 6 "$ADDRESS" > /dev/null
"$BCLI" -datadir="$PALLADIUM_DIR" -regtest generatetoaddress 6 "$ADDRESS" > /dev/null
printf "%s" "Waiting for confirmation... "
@@ -408,9 +418,9 @@ stop_nodes() {
stop_ln() {
stop_nodes "$@"
test ! -f "$BITCOIN_DIR/regtest/bitcoind.pid" || \
(kill "$(cat "$BITCOIN_DIR/regtest/bitcoind.pid")"; \
rm "$BITCOIN_DIR/regtest/bitcoind.pid")
test ! -f "$PALLADIUM_DIR/regtest/palladiumd.pid" || \
(kill "$(cat "$PALLADIUM_DIR/regtest/palladiumd.pid")"; \
rm "$PALLADIUM_DIR/regtest/palladiumd.pid")
unset LN_NODES
unalias bt-cli

Binary file not shown.

View File

@@ -23,10 +23,10 @@
#define BITCOIND_VERSION_GETBLOCKFROMPEER 230000
struct bitcoind {
/* eg. "bitcoin-cli" */
/* eg. "palladium-cli" */
char *cli;
/* -datadir arg for bitcoin-cli. */
/* -datadir arg for palladium-cli. */
char *datadir;
/* bitcoind's version, used for compatibility checks. */
@@ -36,7 +36,7 @@ struct bitcoind {
* before fatally exiting. */
u64 retry_timeout;
/* Passthrough parameters for bitcoin-cli */
/* Passthrough parameters for palladium-cli */
char *rpcuser, *rpcpass, *rpcconnect, *rpcport;
u64 rpcclienttimeout;
@@ -52,7 +52,7 @@ struct bitcoind {
static struct bitcoind *bitcoind;
/* Result of a synchronous bitcoin-cli call */
/* Result of a synchronous palladium-cli call */
struct bcli_result {
char *output;
size_t output_len;
@@ -155,7 +155,7 @@ static char *args_string(const tal_t *ctx, const char **args, const char **stdin
return ret;
}
/* Execute bitcoin-cli with pre-built command and optional stdin args.
/* Execute palladium-cli with pre-built command and optional stdin args.
* Returns result with output and exit status. */
static struct bcli_result *
execute_bitcoin_cli(const tal_t *ctx,
@@ -209,7 +209,7 @@ execute_bitcoin_cli(const tal_t *ctx,
return res;
}
/* Synchronous execution of bitcoin-cli.
/* Synchronous execution of palladium-cli.
* Returns result with output and exit status. */
static struct bcli_result *
run_bitcoin_cliv(const tal_t *ctx,
@@ -581,7 +581,7 @@ static struct command_result *get_feerate(struct command *cmd,
if (bitcoind->fake_fees)
*perkb = 1000;
else
/* We return null if estimation failed, and bitcoin-cli will
/* We return null if estimation failed, and palladium-cli will
* exit with 0 but no feerate field on failure. */
return estimatefees_null_response(cmd);
}
@@ -643,7 +643,7 @@ static struct command_result *sendrawtransaction(struct command *cmd,
struct bcli_result *res;
struct json_stream *response;
/* bitcoin-cli wants strings. */
/* palladium-cli wants strings. */
if (!param(cmd, buf, toks,
p_req("tx", param_string, &tx),
p_req("allowhighfees", param_bool, &allowhighfees),
@@ -688,7 +688,7 @@ static struct command_result *getutxout(struct command *cmd,
struct bitcoin_tx_output output;
const char *err;
/* bitcoin-cli wants strings. */
/* palladium-cli wants strings. */
if (!param(cmd, buf, toks,
p_req("txid", param_string, &txid),
p_req("vout", param_string, &vout),
@@ -730,15 +730,15 @@ static void bitcoind_failure(struct plugin *p, const char *error_message)
{
const char **cmd = gather_args(bitcoind, NULL, "echo", NULL);
plugin_err(p, "\n%s\n\n"
"Make sure you have bitcoind running and that bitcoin-cli"
" is able to connect to bitcoind.\n\n"
"Make sure you have palladiumd running and that palladium-cli"
" is able to connect to palladiumd.\n\n"
"You can verify that your Bitcoin Core installation is"
" ready for use by running:\n\n"
" $ %s 'hello world'\n", error_message,
args_string(cmd, cmd, NULL));
}
/* Do some sanity checks on bitcoind based on the output of `getnetworkinfo`. */
/* Do some sanity checks on palladiumd based on the output of `getnetworkinfo`. */
static void parse_getnetworkinfo_result(struct plugin *p, const char *buf)
{
const jsmntok_t *result;
@@ -764,13 +764,13 @@ static void parse_getnetworkinfo_result(struct plugin *p, const char *buf)
json_tok_full_len(result), json_tok_full(buf, result));
if (bitcoind->version < min_version)
plugin_err(p, "Unsupported bitcoind version %"PRIu32", at least"
plugin_err(p, "Unsupported palladiumd version %"PRIu32", at least"
" %"PRIu32" required.", bitcoind->version, min_version);
/* We don't support 'blocksonly', as we rely on transaction relay for fee
* estimates. */
if (!tx_relay)
plugin_err(p, "The 'blocksonly' mode of bitcoind, or any option "
plugin_err(p, "The 'blocksonly' mode of palladiumd, or any option "
"deactivating transaction relay is not supported.");
tal_free(result);
@@ -782,15 +782,15 @@ static void wait_and_check_bitcoind(struct plugin *p)
const char **cmd;
/* Special case: -rpcwait flags go on command line, not stdin */
cmd = gather_args(bitcoind, NULL, "-rpcwait", "-rpcwaittimeout=30",
cmd = gather_args(bitcoind, NULL, "-rpcwait",
"getnetworkinfo", NULL);
res = execute_bitcoin_cli(bitcoind, p, cmd, NULL);
if (res->exitstatus == 1)
bitcoind_failure(p,
"RPC connection timed out. Could "
"not connect to bitcoind using "
"bitcoin-cli. Is bitcoind running?");
"not connect to palladiumd using "
"palladium-cli. Is palladiumd running?");
if (res->exitstatus != 0)
bitcoind_failure(p,
tal_fmt(bitcoind, "%s exited with code %i: %s",
@@ -820,7 +820,7 @@ static const char *init(struct command *init_cmd, const char *buffer UNUSED,
plugin_set_memleak_handler(init_cmd->plugin, memleak_mark_bitcoind);
plugin_log(init_cmd->plugin, LOG_INFORM,
"bitcoin-cli initialized and connected to bitcoind.");
"palladium-cli initialized and connected to palladiumd.");
return NULL;
}
@@ -878,37 +878,37 @@ int main(int argc, char *argv[])
plugin_main(argv, init, NULL, PLUGIN_STATIC, false /* Do not init RPC on startup*/,
NULL, commands, ARRAY_SIZE(commands),
NULL, 0, NULL, 0, NULL, 0,
plugin_option("bitcoin-datadir",
plugin_option("palladium-datadir",
"string",
"-datadir arg for bitcoin-cli",
"-datadir arg for palladium-cli",
charp_option, NULL, &bitcoind->datadir),
plugin_option("bitcoin-cli",
plugin_option("palladium-cli",
"string",
"bitcoin-cli pathname",
"palladium-cli pathname",
charp_option, NULL, &bitcoind->cli),
plugin_option("bitcoin-rpcuser",
plugin_option("palladium-rpcuser",
"string",
"bitcoind RPC username",
"palladiumd RPC username",
charp_option, NULL, &bitcoind->rpcuser),
plugin_option("bitcoin-rpcpassword",
plugin_option("palladium-rpcpassword",
"string",
"bitcoind RPC password",
"palladiumd RPC password",
charp_option, NULL, &bitcoind->rpcpass),
plugin_option("bitcoin-rpcconnect",
plugin_option("palladium-rpcconnect",
"string",
"bitcoind RPC host to connect to",
"palladiumd RPC host to connect to",
charp_option, NULL, &bitcoind->rpcconnect),
plugin_option("bitcoin-rpcport",
plugin_option("palladium-rpcport",
"int",
"bitcoind RPC host's port",
"palladiumd RPC host's port",
charp_option, NULL, &bitcoind->rpcport),
plugin_option("bitcoin-rpcclienttimeout",
plugin_option("palladium-rpcclienttimeout",
"int",
"bitcoind RPC timeout in seconds during HTTP requests",
"palladiumd RPC timeout in seconds during HTTP requests",
u64_option, u64_jsonfmt, &bitcoind->rpcclienttimeout),
plugin_option("bitcoin-retry-timeout",
plugin_option("palladium-retry-timeout",
"int",
"how long to keep retrying to contact bitcoind"
"how long to keep retrying to contact palladiumd"
" before fatally exiting",
u64_option, u64_jsonfmt, &bitcoind->retry_timeout),
plugin_option_dev("dev-no-fake-fees",