Commit graph

2125 commits

Author SHA1 Message Date
Matt Corallo
4b04f3ff1e Allow cloning NetworkGraphs 2021-02-22 11:44:22 -05:00
Matt Corallo
8051fb0118 Standardize trait derives in network graph objects
In general, trivial structs that have no inner logic can/should
all derive, at least, `Clone, Debug, PartialEq`.
2021-02-22 11:44:22 -05:00
Matt Corallo
9a5d846c9e Standardize trait derives in network message objects
In general, trivial structs that have no inner logic can/should
all derive, at least, `Clone, Debug, PartialEq`.
2021-02-22 11:44:22 -05:00
Matt Corallo
94bb0c9128
Merge pull request #799 from TheBlueMatt/2021-02-chansigner-rename
Rename ChannelKeys -> Sign and generic it consistently
2021-02-22 08:44:00 -08:00
Matt Corallo
4b6f0a3b26 Further rename chan_keys variables to signers 2021-02-20 10:06:22 -05:00
Matt Corallo
fc416d6295 Update C++ bindings demo with new struct naming 2021-02-20 10:06:22 -05:00
Matt Corallo
aa3f84123d Update auto-generated bindings 2021-02-20 10:06:22 -05:00
Matt Corallo
aa127f55ed Use ChannelSigner instead of ChanSigner for type parameters 2021-02-19 16:04:19 -05:00
Matt Corallo
523fcb6f3f Change Persist's Sign from an associated type to a generic param 2021-02-19 16:04:19 -05:00
Matt Corallo
20a25967ef Use signer instead of keys_storage in OnchainTx to hold Sign 2021-02-19 15:54:43 -05:00
Matt Corallo
ff00f6f886 Rename ChannelKeys -> Sign and generic it consistently
The `ChannelKeys` object really isn't about keys at all anymore,
its all about signing. At the same time, we rename the type aliases
used in traits from both `ChanKeySigner` and `Keys` to just
`Signer` (or, in contexts where Channel isnt clear, `ChanSigner`).
2021-02-19 15:54:41 -05:00
Matt Corallo
ee68ffa5fd
Merge pull request #801 from TheBlueMatt/2021-02-789-bindings
Bindings updates for 789
2021-02-19 12:42:17 -08:00
Matt Corallo
041d7aaa9d
Merge pull request #752 from valentinewallace/chanman-persistence
ChannelManager persistence
2021-02-19 12:37:24 -08:00
Valentine Wallace
a368093803
Add BackgroundProcessor for ChannelManager persistence and other
Other includes calling timer_chan_freshness_every_minute() and in the
future, possibly persisting channel graph data.

This struct is suitable for things that need to happen periodically and
can happen in the background.
2021-02-19 15:00:43 -05:00
Valentine Wallace
12c735ab3a
Add PersistenceNotifier to ChannelManager
This will allow the ChannelManager to signal when it has new
updates to persist, and adds a way for ChannelManager persisters
to be notified when they should re-persist the ChannelManager
to disk/backups.

Feature-gate the wait_timeout function because the core
lightning crate shouldn't depend on wallclock time unless
users opt into it.
2021-02-19 15:00:43 -05:00
Valentine Wallace
a88dfbfcca
Fix Windows persistence
Windows started giving 'Access is denied' errors after
a few rounds of persistence. This seems to fix it.
2021-02-19 15:00:43 -05:00
Valentine Wallace
36eaccc607
Abstract out disk-writing utilities from FilesystemPersister 2021-02-19 15:00:43 -05:00
Valentine Wallace
f41cfb4da9
Make logger macros public
These will be used in upcoming commits for the BackgroundProcessor
to log.
2021-02-19 15:00:41 -05:00
Matt Corallo
13e990e6ae
Merge pull request #762 from valentinewallace/chan-reserve-fuzz-failure
Don't include below-dust inbound HTLCs in commit tx fee calculation
2021-02-19 11:57:46 -08:00
Matt Corallo
68811da302 Update C bindings demos for new KeysManager API 2021-02-19 14:02:46 -05:00
Matt Corallo
5f0977260e - bindings updates 2021-02-19 14:02:46 -05:00
Matt Corallo
b7538b62d9 [bindings] Handle unnamed enum variants 2021-02-19 14:02:46 -05:00
Matt Corallo
1d0645f7e6 Add a no-bindings-map comment to std::io::ErrorKind in DecodeErr 2021-02-19 14:02:46 -05:00
Matt Corallo
6c0025439e [bindings] Correctly use access string in to-Rust container conv
`from_c_conversion_container_new_var` should use var_access when
it wishes to access the variable being converted, not `var_name`,
but in a few cases it did not. Note that this has no impact on the
generated bindings as of this commit.
2021-02-19 14:02:33 -05:00
Matt Corallo
02c21842fd - bindings updates 2021-02-19 14:01:10 -05:00
Matt Corallo
1a32e23050 [bindings] Ensure owned objects in Vec conversion are marked mut 2021-02-19 14:00:41 -05:00
Matt Corallo
2f06b53abf Switch from slice to slice-of-refs for spend_spendable_outputs
Sadly, there's just not really a practical way to map a slice of
objects in our current bindings infrastructure - either we take
ownership of the underlying objects and move them into a Vec, or we
need to leave the original objects in place and have a list of
pointers to the Rust objects. Thus, the only practical mapping is
to create a slice of references using the pointers we have.
2021-02-19 13:58:05 -05:00
Valentine Wallace
1079753f20
Ensure build_commitment_tx and next_local/remote_tx_fee agree on the fee 2021-02-18 13:09:17 -05:00
Valentine Wallace
3d4735cc0a
Don't include below-dust inbound HTLCs in commit tx fee calculation
Also remove part of the holding cell channel reserve test that's newly failing but
a bit of a redundant test anyway.
2021-02-18 13:09:17 -05:00
Matt Corallo
de58bcf271
Merge pull request #795 from TheBlueMatt/2021-02-features-bindings
Map Features objects in bindings
2021-02-18 09:54:59 -08:00
Matt Corallo
414e62230e
Merge pull request #789 from TheBlueMatt/2021-02-chansigner-util-fns
Add util fn for creating a Transaction from spendable outputs
2021-02-18 09:37:00 -08:00
Matt Corallo
954e66ed08 Update auto-generated bindings 2021-02-18 12:31:29 -05:00
Matt Corallo
0a9a7c5d73 [bindings] Silence c-bindings-gen compile warnings 2021-02-18 12:28:25 -05:00
Matt Corallo
6f5f27e901 [bindings] Handle impl Clone like impl ::core::clone::Clone 2021-02-18 12:28:25 -05:00
Matt Corallo
cdbe8333fa [bindings] Drop manual implementations of Features conversion
We now handle features properly in our own resolution, and these
appear to be self-inconsistent in some cases.
2021-02-18 12:28:25 -05:00
Matt Corallo
a387badfe8 [bindings] Handle generic-ized impl blocks by concretizing them
This handles, for example, the `impl<X: Y> for Features<X>` blocks
which are generic across a number of different contexts. We do so
by walking the set of structs which alias Features and then walking
their generic arguments to check that they meet the bounds
specified in the impl block. For each alias which does, we create
a dummy, explicit, `impl XFeatures` block with the same content as
the original and recurse.
2021-02-18 12:28:25 -05:00
Matt Corallo
842d2f6ce7 [bindings] Resolve type aliases mapped as opaque types
We already map type aliases which alias private types as opaque,
but we don't resolve them like we would any other opaque type,
preventing conversion printing or type use.
2021-02-18 12:28:25 -05:00
Matt Corallo
f3ce70660d [bindings] Track structs impling traits, incl priv traits 2021-02-18 12:28:25 -05:00
Matt Corallo
b49781e8d8 [bindings] Allow resolution of private types in some cases
We need this specifically for resolving the
features::sealed::Context trait which is inside the non-pub
`sealed` module.
2021-02-18 12:28:25 -05:00
Matt Corallo
61f5e79062 Drop a useless import and use Self in return values in Features
`Result` is in the standard prelude, so no need to ever use it.

Sadly, returning a Features<T> in the `impl Futures {}` block
will confuse our new alias-impl-printing logic, as we end up
running through the normal impl-block-printing logic as if we had
an explicit `impl ConcreteFeatures` block.
2021-02-18 12:28:25 -05:00
Matt Corallo
3bbecbef21 [bindings] Use new ImportResolver during first AST pass
This removes some redundant logic and ensures we handle more
import-resolution cases in both contexts.
2021-02-18 12:28:25 -05:00
Matt Corallo
494e0fd8a0 [bindings] Track all declared types in ImportResolver construction
This allows an ImportResolver to handle more than imports, allowing
ident resolution of objects constructed in the same module.
2021-02-18 12:28:25 -05:00
Matt Corallo
dd1ca585b3 [bindings] Extract import resolution logic into a separate struct
This will allow us to reuse the same ident-resolution logic both
during the initial AST pass and during the second conversion pass.
2021-02-18 12:28:25 -05:00
Matt Corallo
0dcc937bf1 Update demo C++ bindings example for new bindings 2021-02-18 12:28:25 -05:00
Matt Corallo
be74b366d2 Gen bindings with rustc --pretty=expanded instead of reading files
Instead of walking individual rust files and reading the AST from
those, we instead call
`RUSTC_BOOTSTRAP=1 cargo rustc --profile=check -- -Zunstable-options --pretty=expanded`
and let it create one giant lib.rs which we can parse as a whole.
This allows us to parse a post-macro crate, working with structs
and functions created inside macros just fine. It does require
handling a few things that we didn't previously, most notably Clone
via `impl ::core::clone::Clone` blocks instead of just looking for
`#![derive(Clone)]`.

This ends up resolving a few types slightly differently, resulting
in different bindings, but only in ways which don't impact the
runtime.
2021-02-18 12:28:25 -05:00
Matt Corallo
9e596e2460 [bindings] Use resolved, not local ident in generic mangling
In traits with associated types which are returned in generics (ie
`trait T { type A: B; fn c() -> Result<Self::A, ()> {} }`), we
created a new generic mapping with the local type name (in this
case A) instead of using the real type (in this case B). This is
confusing as it results in generic manglings that don't reference
the real type (eg `LDKCResult_ChanKeySignerDecodeErrorZ`) and
may have multiple generic definitions that are identical.

Instead, we now use the final ident in the resolved mapping. The
biggest win is `LDKCResult_ChanKeySignerDecodeErrorZ` changing to
`CResult_ChannelKeysDecodeErrorZ`. However, there are several types
where `secp256k1::Error` was imported as `SecpError` and types like
`LDKCResult_SecretKeySecpErrorZ` are now
`LDKCResult_SecretKeyErrorZ` instead. Still, the type of the error
field remains `LDKSecp256k1Error`, which should avoid any confusion.
2021-02-18 12:28:25 -05:00
Matt Corallo
10c45786ab [bindings] Drop some significantly-overly-verbose logging in gen 2021-02-18 12:28:25 -05:00
Matt Corallo
95d0fe99ee Rename output descriptor types for some clarity
Both Miron and Val suggested naming tweaks in their reviews, so
clarifying things some would be good.
2021-02-16 16:36:11 -05:00
Matt Corallo
8dbadd1045 Clarify docs on revocation_pubkey in DynamicP2WSHOutputDescriptor 2021-02-16 15:58:02 -05:00
Matt Corallo
0df01c140e Drop stale and cleanup TODO entries in keysinterface 2021-02-16 15:58:02 -05:00