587 Commits

Author SHA1 Message Date
26f9698bad fix: correct Palladium chain params and sanitize branding
- bitcoin/chainparams.c:
  - Fix mainnet RPC port 2333 → 2332 (was the P2P port)
  - Fix regtest RPC port 28444 → 12443 (verified against palladiumcore)
  - Add missing testnet entry (tplm, RPC 12332, P2P 19735, P2PKH 127/P2SH 115)
  - Reset when_lightning_became_cool to 1 (no Bitcoin-specific block reference)
  - Add operational notes: Resilience Fork at block 340,000 (2 min blocks),
    Taproot via BIP9 on mainnet / ALWAYS_ACTIVE on regtest

- common/configdir.c:
  - Fix --network help text to list palladium/testnet/regtest
  - Fix --mainnet alias description (bitcoin → palladium)

- configure: make lowdown optional (warning, not fatal); only needed for man pages

- lightningd/: replace all remaining "bitcoind/bitcoin network" log messages
  with "palladiumd/palladium network" (dual_open_control.c, opening_control.c,
  peer_htlcs.c)

- .gitignore: add ccan/config.h.* (PIDs left by build system)
2026-03-11 19:49:23 +01:00
37cc8b9cf9 feat: Update network references from bitcoin to palladium and add palladiumd RPC warmup retry logic.
Some checks failed
Coverage (Nightly) / Build with Coverage (push) Has been cancelled
Coverage (Nightly) / Test (postgres) (push) Has been cancelled
Coverage (Nightly) / Test (sqlite) (push) Has been cancelled
Coverage (Nightly) / Generate Coverage Report (push) Has been cancelled
Repro Build Nightly / Ubuntu repro build: focal (push) Has been cancelled
Repro Build Nightly / Ubuntu repro build: jammy (push) Has been cancelled
Repro Build Nightly / Ubuntu repro build: noble (push) Has been cancelled
Python API Docs (Nightly) / Generate Python API Documentation (push) Has been cancelled
Documentation (Nightly) / Generate Project Documentation (push) Has been cancelled
Publish Documentation Site / Generate Coverage Reports (push) Has been cancelled
Publish Documentation Site / Generate Python API Documentation (push) Has been cancelled
Publish Documentation Site / Generate Project Documentation (push) Has been cancelled
Publish Documentation Site / Deploy to GitHub Pages (push) Has been cancelled
2026-02-20 16:15:16 +01:00
ee8dccdd4d 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
2026-02-20 14:10:53 +01:00
Rusty Russell
d9774e73dc bitcoin: hash_scid and hash_scidd public functions.
We reimplemented this redundantly: hash_scid was called
short_channel_id_hash, so I obviously missed it.

Rename, and implement hash_scidd helper too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2026-02-19 17:04:35 +10:30
Rusty Russell
f8fd97fb5d global: replace randombytes_buf() with randbytes() wrapper.
This allows us to override it for deterministic results.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-11-13 21:21:29 +10:30
Rusty Russell
82fff3c74b Remove litecoin support.
No idea if it works, we don't test it and nobody runs it.  I guess not.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Removed: Config: non-functioning litecoin support (who knew we even had that?)
2025-10-26 20:31:45 +10:30
Sangbida Chaudhuri
185ab3d0dc utxo: remove UTXO_P2TR_BIP86 enum and consolidate to UTXO_P2TR
This simplifies the UTXO type system by removing the separate BIP86
enum value. P2TR addresses will now use unified derivation logic
based on the wallet's HSM secret type rather than having separate
enum values."
2025-10-26 12:37:58 +10:30
Sangbida Chaudhuri
d0d51479f5 wallet: scaffold BIP86 addrtype
Add the UTXO_P2TR_BIP86 in preparation to add BIP86 wallet functions such as newaddr, listaddr etc. We also add a new index in the database for BIP86 as this is using a completely different derivation path and hsm_secret.
2025-10-26 12:37:58 +10:30
Rusty Russell
f801054e26 tests: use timemono not time_now() for duration measurement.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-10-24 11:30:17 +10:30
Rusty Russell
4bc357f0a6 bitcoin: remove unused scriptpubkey_opreturn_padded.
I noticed, because it pulled in randomness routines.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-10-24 11:30:17 +10:30
Rusty Russell
6e5cb299dd global: remove unnecessary includes from C files.
Basically, `devtools/reduce-includes.sh */*.c`.

Build time from make clean (RUST=0) (includes building external libs):

Before:
	real    0m38.944000-40.416000(40.1131+/-0.4)s
	user    3m6.790000-17.159000(15.0571+/-2.8)s
	sys     0m35.304000-37.336000(36.8942+/-0.57)s
After:
	real    0m37.872000-39.974000(39.5466+/-0.59)s
	user    3m1.211000-14.968000(12.4556+/-3.9)s
	sys     0m35.008000-36.830000(36.4143+/-0.5)s

Build time after touch config.vars (RUST=0):

Before:
	real    0m19.831000-21.862000(21.5528+/-0.58)s
	user    2m15.361000-30.731000(28.4798+/-4.4)s
	sys     0m21.056000-22.339000(22.0346+/-0.35)s

After:
	real    0m18.384000-21.307000(20.8605+/-0.92)s
	user    2m5.585000-26.843000(23.6017+/-6.7)s
	sys     0m19.650000-22.003000(21.4943+/-0.69)s

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-10-23 06:44:04 +10:30
Rusty Russell
f6a4e79420 global: remove unnecessary includes from headers.
Each header should only include the other headers it needs to compile;
`devtools/reduce-includes.sh */*.h` does this.  The C files then need
additional includes if they don't compile.

And remove the entirely useless wire/onion_wire.h, which only serves to include wire/onion_wiregen.h.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-10-23 06:44:04 +10:30
Rusty Russell
65d997842e Makefiles: remove redundant dependencies, and have objects depend on their Makefile.
1. $(JSMN_OBJS) is not set anywhere.
2. You don't need to depend on CCAN_HEADERS, COMMON_HEADERS or JSMN_HEADERS: the top level Makefile has all object depedning on it.
3. Similarly, CCAN_OBJS.
4. Every object file should be rebuilt if its Makefile changes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-10-23 06:44:04 +10:30
Rusty Russell
e120f87083 Makefile: create a library containing common, wire and bitcoin objects.
This means we don't have to manually choose what to link against,
which is much of the complexity of our Makefiles: the compiler will
automatically use any object files it needs to link.

We already do this for ccan as libccan.a, now we have libcommon.a.

We don't link against it for *everything*, as some tests require their own
versions.

Notes:
1. I get rid of the weird plugins/test/Makefile2 (accidental commit?)
2. Many tests change due to update-mocks.
3. In some places I added the missing dependency on the Makefile itself, though most are in the next
   patch.

Before:
	Total program size:     221366528
	Total tests size:       364243856

After:
	Total program size:     190733656
	Total tests size:       337880888

Build time from make clean (RUST=0) (includes building external libs):

Before:
	real    0m38.227000-44.245000(41.8222+/-1.6)s
	user    3m2.105000-33.696000(23.1442+/-8.4)s
	sys     0m35.054000-42.269000(39.7231+/-2)s
After:
	real    0m38.944000-40.416000(40.1131+/-0.4)s
	user    3m6.790000-17.159000(15.0571+/-2.8)s
	sys     0m35.304000-37.336000(36.8942+/-0.57)s

Build time after touch config.vars (RUST=0):

Before:
	real    0m18.928000-22.776000(21.5084+/-1.1)s
	user    2m8.613000-36.567000(27.7281+/-7.7)s
	sys     0m20.458000-23.436000(22.3963+/-0.77)s

After:
	real    0m19.831000-21.862000(21.5528+/-0.58)s
	user    2m15.361000-30.731000(28.4798+/-4.4)s
	sys     0m21.056000-22.339000(22.0346+/-0.35)s

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

rusty@rusty-Framework:~/devel/cvs/lightni
2025-10-23 06:44:04 +10:30
Sangbida Chaudhuri
ad0c7318c1 makefile: fix glob expansion for macOS
when bash expands bitcoin/*.h, it returns the files in lexicographically sorted order by default this is not necessarily the case for macOS so it has be explicitly sorted. I get a fairly uninformative error like this:

make: *** [check-bitcoin-makefile] Error 1

The error is now more informative and does not error on a clean branch on macOS:

BITCOIN_HEADERS missing: bitcoin/signature.h bitcoin/tx_parts.h bitcoin/tx.h bitcoin/varint.h
make: *** [check-bitcoin-makefile] Error 1
2025-10-22 11:44:02 +10:30
Rusty Russell
639452ac77 bitcoin: have random_scid() function.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-14 14:04:11 +09:30
Dusty Daemon
5ef0ed3126 psbt: unused code path could leak
If `wally_psbt_extract` fails the function returns early leaking psbt, if it was `taken()`.

Throw it on tmpctx so its not leaked in this case.

Changelog-None
2025-05-15 13:16:02 +09:30
Dusty Daemon
5e5ed774fc PSBT: Add audi_psbt routine
A routine that audit’s and asserts PSBT memory to confirm it has a sane memory allocation hierarchy.

Changelog-None
2025-05-13 14:52:15 +09:30
Dusty Daemon
23e80d9e81 PSBT: Change bitcoin_tx routine to use TAKES
`bitcoin_tx_with_psbt` would somewhat opaquely steal the passed `psbt` value.

This caused a bug where code made a `bitcoin_tx` using a psbt without realizing the value was stolen. Because the resulting `bitcoin_tx` was placed in tmpctx it was not immediately clear that using `psbt` afterwards was an error until the tmpctx was cleared — creating a valgrind backtrace far from the actual issue.

Switching to the routine to using TAKES and adding documentation in the header, makes it explicitly clear which operation the user is doing — helping prevent future regressions of this kind.

Changelog-None
2025-05-13 14:52:15 +09:30
Rusty Russell
74e7264d54 bitcoin: make input witness weight calculation explicit.
This is inspired by a patch from @whitslack, which overlapped with this series.
Most importantly, there was only one call to bitcoin_tx_simple_input_weight(),
and it is better to be explicit with that one.

This also changes our funder calculation to assume our own input is taproot,
which it is likely to be given we've defaulted to taproot for outputs for
change addresses since 23.08.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-05-06 12:27:53 +09:30
Rusty Russell
1d5cb4b49c bitcoin: fix out-by-one-error in bitcoin_tx_input_weight.
We need one byte for the number of witness elements.  Some callers added it themselves,
but it's always needed.  So document and fix the callers.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-05-06 12:27:53 +09:30
Jon Griffiths
0d854ba3d8 psbt: avoid duplicating the input string when parsing from base64
Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2025-03-21 09:48:57 +10:30
2seaq
1da0c1fbe2 common: Chainparams for testnet4 support
The BIP70 name given as testnet4 to correspond with chaininfo value.
2025-01-13 15:45:19 -08:00
Dusty Daemon
9708ee3166 secp256k1 pubkey constant fix
Spotted a number being used instead of the macro constant.

Changelog-None
2024-11-17 10:55:28 +10:30
Christian Decker
f36be4b006 plugin: Add tracing support for send_outreq
The `send_outreq` function is a good place to suspend and resume
traces, since these are usually the places where we hand off control
back to the `io_loop`. This assumes that we do not continue doing
heavy liftin after we have queued an `outreq` call, but that is most
likely the case anyway. This frees us from having to track suspensions
whenever we call the RPC from a plugin.
2024-11-13 13:15:52 +01:00
Dusty Daemon
e4978a4037 splice: Update splice fee maximums
The fee maximum is used to issue a warning to the user their feerate is high in case they accidentally make a large donation to miners.

During python testing the feerates are high on purpose so we raise the warning level to at least the penality feerate.
2024-11-12 06:42:52 +10:30
Dusty Daemon
0d241ee187 psbt: comment typo fix 2024-11-12 06:42:52 +10:30
Dusty Daemon
66fe338290 psbt: Add ability to set global PSBT values
Changelog-None
2024-11-12 06:42:52 +10:30
Dusty Daemon
fa0d9b6d2a psbt: Add ability to extract signature
A routine for getting a signature back out of an input’s list of pending signatures via pubkey search.

This is needed for certain kinds of restarts as we lose our peer’s signature from memory but a copy is kept in the PSBT.
2024-11-12 06:42:52 +10:30
michael1011
d32433a553 bkpr: add payment_id parameter to listaccountevents to filter events.
When you have *lots* of events in your bkpr database looking up a
specific event via calling bkpr-listaccountevents and using jq or
grep to filter gets very slow (and wasteful of CPU and disk resources).
This commit adds the paremeter payment_id to the call to filter for a
specific payment id via a where clause in the request to the database of bkpr.

Changelog-Added: Plugins: Add payment_id parameter to bkpr-listaccountevents to filter events.
2024-08-12 10:22:55 -07:00
Rusty Russell
a29d135bee bitcoin: add short_channel_id_dir_eq.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-08-07 20:35:30 +09:30
Rusty Russell
af90fdc0bb common/utils: macros to help get copy/compare across different types right.
Things are often equivalent but different types:
1. u8 arrays in libwally.
2. sha256
3. Secrets derived via sha256
4. txids

Rather than open-coding a BUILD_ASSERT & memcpy, create a macro to do it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-23 09:54:47 +09:30
Rusty Russell
34052f9960 bitcoin: hoist scid hash into common code.
A second user is coming.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-07-09 15:09:29 +02:00
Rusty Russell
9450d46db1 bitcoin/short_channel_id: pass by copy everywhere.
It's a u64, we should pass by copy.  This is a big sweeping change,
but mainly mechanical (change one, compile, fix breakage, repeat).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-03-20 13:51:48 +10:30
Rusty Russell
e0e879c003 common: remove type_to_string files altogther.
This means including <common/utils.h> where it was indirectly included.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-03-20 13:51:48 +10:30
Rusty Russell
d8c06dccac global: expose all fmt_X functions for direct use, make uniform.
We have various functions to convert to a string, rename them all so we can
count on fmt_X being the formatter for struct X, and make them all return
`char *`.

Sometimes they existed but were private, sometimes they had a
different name.  Most take a pointer, but simple types pass by copy:
short_channel_id, amount_msat and amount_sat.

The following public functions changed:
1. psbt_to_b64 -> fmt_wally_psbt.
2. pubkey_to_hexstr -> fmt_pubkey.
3. short_channel_id_to_str -> fmt_short_channel_id (scid by copy now!)
4. fmt_signature -> fmt_secp256k1_ecdsa_signature
5. fmt_amount_sat/fmt_amount_msat pass copy not pointer, return non-const char *.
6. node_id_to_hexstr -> fmt_node_id

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2024-03-20 13:51:48 +10:30
Jon Griffiths
f39d2ee086 tx: remove allocating script fetchers
The pattern of making tal-allocated copies of wally data to pass around
was made redundant after these calls were added by the use of
tal_wally_start/tal_wally_end to parent wally allocations. We can thus
just pass the data directly and avoid the allocations.

Removes redundant allocations when checking tx filters and computing fees.

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-03-18 12:24:49 +10:30
Jon Griffiths
aa23c2a2b2 script: consistently take the script length in identification functions
Standardizes the is_xxx script function all take a script length, and changes
their first-level callers to pass it. This has several knock on benefits:

- We remove the repeated tal_count/tal_bytelen calls on the script, in
  particular the redundant calls that result when we must check for multiple
  types of script - which is almost all cases.
- We remove the dependency on the memory being tal-allocated (It is, in
  all cases, but theres no reason we need to require that).
- We remove all cases where we create a copy of the script just to id it.
- We remove all allocations for non-interesting scripts while iterating block
  txs in process_getfilteredblock_step1().
- We remove all allocations *including for potentially interesting scripts* in
  topo_add_utxos().

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-03-18 12:24:49 +10:30
Jon Griffiths
5dee5ce178 script: remove repeated tal_count calls from scripteq
Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-03-18 12:24:49 +10:30
Jon Griffiths
5dd8d933d5 Revert "core: Add a function check if a script is P2WSH without allocating"
The is_xxx script functions already perform these checks for us without
allocating. They currently expect their memory to be tal-allocated,
which is why a copy is made. However:

- The memory already *is* tal-allocated since wally is configured to do so.
- The tal-dependency is artifical and is removed in a future commit in
  this PR.

This reverts commit c329756723.

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-03-18 12:24:49 +10:30
Jon Griffiths
6fffba0746 tx_parts: use wally to clone tx inputs
Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-02-21 12:01:33 +01:00
Christian Decker
c329756723 core: Add a function check if a script is P2WSH without allocating
Processing blocks is rather slow at the moment, but one thing we can
do, is to prevent copying all output scripts, when really all we are
interested in are the couple of outputs that are P2WSH.

This builds the foundation of that by adding a method to introspect
the script without having to clone it first, saving us some
allocations, and deallocations.

Changelog-Changed: core: Processing blocks should now be faster
2024-02-21 11:59:31 +01:00
jrakibi
1fdc018b74 Fix incorrect hex value for Signet port 2024-02-16 15:54:29 +01:00
Jon Griffiths
40dd780ea7 bitcoin_block_from_hex: avoid creating PSBT wrappers for finalized block txs
Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-01-16 15:47:03 +01:00
Jon Griffiths
cdb5de0bce fromwire_bitcoin_tx: avoid creating a PSBT wrapper just to throw it away again
Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-01-16 15:47:03 +01:00
Jon Griffiths
2137343e7a tx: add pull_bitcoin_tx_only to pull without creating a psbt wrapper
There are many contexts in which it doesn't make sense to create a PSBT
wrapping the tx. There are also tx features that are not supported in
wallys PSBT implementation yet (such as pegins), which fail if a PSBT
wrapper is created, even though such features are unlikely to ever be
used in txs that cln will create/manipulate.

Allow these cases to be explicit that they only want the tx. This avoids
hitting such errors, is clearer on the caller side, and is more efficient.

Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-01-16 15:47:03 +01:00
Jon Griffiths
2e670a2a62 tx_parts: use wally to clone tx outputs
Input cloning has not been exposed yet; I'll add that to wally in a
future release.

Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-01-16 15:47:03 +01:00
Jon Griffiths
23a04d1bba base58: use _n api variant to avoid duplicating our input string
Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-01-16 15:47:03 +01:00
Jon Griffiths
5e63e55b99 psbt: use wally_map_get instead of wally_map_find
Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-01-16 15:47:03 +01:00
Jon Griffiths
16ac5cf085 psbt: use wally_map_replace instead of coding our own
Changelog-None

Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2024-01-16 15:47:03 +01:00