]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
3 years agoPass along ChannelManager's last_block_hash
Jeffrey Czyz [Fri, 5 Mar 2021 02:22:37 +0000 (18:22 -0800)]
Pass along ChannelManager's last_block_hash

ChannelMonitor keeps track of the last block connected. However, it is
initialized with the default block hash, which is a problem if the
ChannelMonitor is serialized before a block is connected. Instead, pass
ChannelManager's last_block_hash, which is initialized with a "birthday"
hash, when creating a new ChannelMonitor.

3 years agoRemove last_block_connected from Channel
Jeffrey Czyz [Fri, 5 Mar 2021 01:39:21 +0000 (17:39 -0800)]
Remove last_block_connected from Channel

Tracking the last block was only used to de-duplicate block_connected
calls, but this is no longer required as of the previous commit.
Further, the ChannelManager can pass the latest block hash when needing
to create a ChannelMonitor rather than have each Channel maintain an
up-to-date copy. This is implemented in the next commit.

3 years agoRemove block_connected de-duplication logic
Jeffrey Czyz [Fri, 5 Mar 2021 00:58:26 +0000 (16:58 -0800)]
Remove block_connected de-duplication logic

Calling block_connected for the same block was necessary when clients
were expected to re-fetch filtered blocks with relevant transactions. At
the time, all listeners were notified of the connected block again for
re-scanning. Thus, de-duplication logic was put in place.

However, this requirement is no longer applicable for ChannelManager as
of commit bd39b20f642e042981e4fdd5f3600a357be51931, so remove this
logic.

3 years agoParameterize ChannelManager::new with a block hash
Jeffrey Czyz [Wed, 3 Mar 2021 19:24:55 +0000 (11:24 -0800)]
Parameterize ChannelManager::new with a block hash

When ChannelMonitors are persisted, they need to store the most recent
block hash seen. However, for newly created channels the default block
hash is used. If persisted before a block is connected, the funding
output may be missed when syncing after a restart. Instead, initialize
ChannelManager with a "birthday" hash so it can be used later when
creating channels.

3 years agoUpdate docs with correct hash type
Matt Corallo [Tue, 2 Mar 2021 18:07:43 +0000 (13:07 -0500)]
Update docs with correct hash type

Co-authored-by: Matt Corallo <git@bluematt.me>
Co-authored-by: Jeffrey Czyz <jkczyz@gmail.com>
3 years agoRevert "Merge pull request #819 from TheBlueMatt/2021-03-810-rebased"
Jeffrey Czyz [Wed, 3 Mar 2021 16:02:54 +0000 (08:02 -0800)]
Revert "Merge pull request #819 from TheBlueMatt/2021-03-810-rebased"

This reverts commit 793de5fe6944bb6ab414934e53a7ae80bb5a9a31, reversing
changes made to 03a518965100b6852f36e4f95ead4c1d93f5c4b0.

3 years agoMerge pull request #646 from naumenkogs/2020-06-router-mpp
Matt Corallo [Wed, 3 Mar 2021 01:32:45 +0000 (20:32 -0500)]
Merge pull request #646 from naumenkogs/2020-06-router-mpp

MPP on the router side

3 years agoMerge pull request #819 from TheBlueMatt/2021-03-810-rebased
Matt Corallo [Wed, 3 Mar 2021 00:04:23 +0000 (16:04 -0800)]
Merge pull request #819 from TheBlueMatt/2021-03-810-rebased

Change ChannelManager deserialization to return an optional blockhash

3 years agoMerge pull request #818 from jkczyz/2021-03-validate-best-block-header
Matt Corallo [Wed, 3 Mar 2021 00:03:42 +0000 (16:03 -0800)]
Merge pull request #818 from jkczyz/2021-03-validate-best-block-header

Add validate_best_block_header utility

3 years agoMerge pull request #816 from valentinewallace/remove-simple-outer-arcs
Matt Corallo [Wed, 3 Mar 2021 00:02:44 +0000 (16:02 -0800)]
Merge pull request #816 from valentinewallace/remove-simple-outer-arcs

Remove simple outer arcs

3 years agoDon't underpay htlc_min due to path contribution
Gleb Naumenko [Mon, 1 Mar 2021 10:37:51 +0000 (12:37 +0200)]
Don't underpay htlc_min due to path contribution

We could have possibly constructed a slightly inconsistent
path: since we reduce value being transferred all the way, we
could have violated htlc_minimum_msat on some channels
we already passed (assuming dest->source direction). Here,
we recompute the fees again, so that if that's the case, we
match the currently underpaid htlc_minimum_msat with fees.

3 years agoUpdate docs to use the new deserialization requirements 2021-03-810-rebased
Matt Corallo [Tue, 2 Mar 2021 18:07:43 +0000 (13:07 -0500)]
Update docs to use the new deserialization  requirements

3 years agoChange ChannelMonitor deserialization to return an optional blockhash.
Valentine Wallace [Tue, 2 Mar 2021 00:47:55 +0000 (19:47 -0500)]
Change ChannelMonitor deserialization to return an optional blockhash.

See previous commit msg for details.

3 years agoChange ChannelManager deserialization to return an optional blockhash
Valentine Wallace [Fri, 26 Feb 2021 21:09:28 +0000 (16:09 -0500)]
Change ChannelManager deserialization to return an optional blockhash

If the ChannelManager never receives any blocks, it'll return a default blockhash
on deserialization. It's preferable for this to be an Option instead.

3 years agoMind htlc_minimum_msat when truncating overpaid value
Gleb Naumenko [Wed, 17 Feb 2021 20:43:16 +0000 (22:43 +0200)]
Mind htlc_minimum_msat when truncating overpaid value

At truncating the overpaid value, if we fall below
htlc_minimum_msat, reach it by increasing fees.

3 years agoUse outbound_capacity_msat from first_hops for routing
Gleb Naumenko [Sun, 20 Dec 2020 14:19:25 +0000 (16:19 +0200)]
Use outbound_capacity_msat from first_hops for routing

3 years agoImplement finding paths for MPP
Gleb Naumenko [Mon, 10 Aug 2020 10:50:29 +0000 (13:50 +0300)]
Implement finding paths for MPP

3 years agoAdd validate_best_block_header utility
Jeffrey Czyz [Tue, 2 Mar 2021 18:03:11 +0000 (10:03 -0800)]
Add validate_best_block_header utility

Refactor synchronize_listeners by pulling out a function returning the
validated block header of a BlockSource's best chain tip. This is needed
when a node is started from scratch and has no listeners to sync.

3 years agoMerge pull request #814 from TheBlueMatt/2021-03-optional-handlers
Matt Corallo [Tue, 2 Mar 2021 15:00:46 +0000 (07:00 -0800)]
Merge pull request #814 from TheBlueMatt/2021-03-optional-handlers

Provide Dummy routing and channel message handlers for users

3 years agoMerge pull request #813 from jkczyz/2021-02-channel-monitor-mutex
Matt Corallo [Tue, 2 Mar 2021 15:00:20 +0000 (07:00 -0800)]
Merge pull request #813 from jkczyz/2021-02-channel-monitor-mutex

Use interior mutability in ChannelMonitor

3 years agoImplement chain::Listen without using RefCell
Jeffrey Czyz [Mon, 1 Mar 2021 06:39:01 +0000 (22:39 -0800)]
Implement chain::Listen without using RefCell

The implementation of chain::Listen for ChannelMonitor required using a
RefCell since its block_connected method required a mutable borrow. This
is no longer the case since ChannelMonitor now uses interior mutability
via a Mutex. So the RefCell is no longer needed.

3 years agoChange Mutex to RwLock in ChainMonitor
Jeffrey Czyz [Mon, 1 Mar 2021 06:26:41 +0000 (22:26 -0800)]
Change Mutex to RwLock in ChainMonitor

Now that ChannelMonitor uses an internal Mutex to support interior
mutability, ChainMonitor can use a RwLock to manage its ChannelMonitor
map. This allows parallelization of update_channel operations since an
exclusive lock only needs to be held when adding to the map in
watch_channel.

3 years agoUse consistent variable naming in ChainMonitor
Jeffrey Czyz [Mon, 1 Mar 2021 20:01:43 +0000 (12:01 -0800)]
Use consistent variable naming in ChainMonitor

3 years agoMove ChannelMonitor state behind a Mutex
Jeffrey Czyz [Mon, 1 Mar 2021 05:42:27 +0000 (21:42 -0800)]
Move ChannelMonitor state behind a Mutex

ChainMonitor accesses a set of ChannelMonitors behind a single Mutex.
As a result, update_channel operations cannot be parallelized. It also
requires using a RefCell around a ChannelMonitor when implementing
chain::Listen.

Moving the Mutex into ChannelMonitor avoids these problems and aligns it
better with other interfaces. Note, however, that get_funding_txo and
get_outputs_to_watch now clone the underlying data rather than returning
references.

3 years agoAdd utility constructors to PeerHandler to use a dummy handler 2021-03-optional-handlers
Matt Corallo [Mon, 1 Mar 2021 23:04:20 +0000 (18:04 -0500)]
Add utility constructors to PeerHandler to use a dummy handler

3 years agoProvide Dummy routing and channel message handlers for users
Matt Corallo [Mon, 1 Mar 2021 20:10:59 +0000 (15:10 -0500)]
Provide Dummy routing and channel message handlers for users

We currently "support" not having a router or channel in memory by
forcing users to implement the same, but its trivial to provide our
own dummy implementations.

3 years agoMerge pull request #811 from TheBlueMatt/2021-02-bindings-rust-bump
Matt Corallo [Mon, 1 Mar 2021 23:35:35 +0000 (15:35 -0800)]
Merge pull request #811 from TheBlueMatt/2021-02-bindings-rust-bump

Update bindings for new Listen interface

3 years agoAdd simple README about our C bindings generation stuff 2021-02-bindings-rust-bump
Matt Corallo [Fri, 19 Feb 2021 22:56:15 +0000 (17:56 -0500)]
Add simple README about our C bindings generation stuff

3 years ago[bindings] Build a wasm32-wasi library in genbindings.sh
Matt Corallo [Sat, 9 Jan 2021 02:55:47 +0000 (21:55 -0500)]
[bindings] Build a wasm32-wasi library in genbindings.sh

This will switch to use the clang/C WASM ABI instead of the
wasm_bindgen WASM ABI as of rustc 1.51 (or nightly since [1]),
allowing us to link C and Rust code in a single wasm binary.

[1] https://github.com/rust-lang/rust/pull/79998

3 years agoUpdate auto-generated bindings
Matt Corallo [Fri, 26 Feb 2021 23:21:03 +0000 (18:21 -0500)]
Update auto-generated bindings

3 years ago[bindings] Be explicit when calling trait methods in generated code
Matt Corallo [Fri, 26 Feb 2021 23:16:14 +0000 (18:16 -0500)]
[bindings] Be explicit when calling trait methods in generated code

For ChannelManager, at least, we have two separate functions called
block_connected, one in the Listen trait, one in the struct, we
need to be explicit with which one we're trying to call.

3 years agoFix doc typo introduced in the ChannelKeys->Sign renaming
Matt Corallo [Mon, 22 Feb 2021 16:59:17 +0000 (11:59 -0500)]
Fix doc typo introduced in the ChannelKeys->Sign renaming

3 years ago[bindings] Use global context for secp256k1
Matt Corallo [Mon, 1 Feb 2021 05:09:50 +0000 (00:09 -0500)]
[bindings] Use global context for secp256k1

Note that this uses https://github.com/rust-bitcoin/rust-secp256k1/pull/279

3 years agoMerge pull request #802 from TheBlueMatt/2021-01-update-rust-bitcoin
Matt Corallo [Mon, 1 Mar 2021 00:43:08 +0000 (16:43 -0800)]
Merge pull request #802 from TheBlueMatt/2021-01-update-rust-bitcoin

Update rust-bitcoin and add secp256k1 context randomization

3 years agoMerge pull request #806 from valentinewallace/monitor-data-persistence-path
Matt Corallo [Sun, 28 Feb 2021 00:34:54 +0000 (16:34 -0800)]
Merge pull request #806 from valentinewallace/monitor-data-persistence-path

persist: Persist ChannelMonitors in their own directory.

3 years agoRebuild full_stack_target test vector for new secp256k1 fuzz req 2021-01-update-rust-bitcoin
Matt Corallo [Fri, 19 Feb 2021 01:04:47 +0000 (20:04 -0500)]
Rebuild full_stack_target test vector for new secp256k1 fuzz req

3 years agoLog full signed remote commitment transaction hex in channel
Matt Corallo [Fri, 19 Feb 2021 01:02:06 +0000 (20:02 -0500)]
Log full signed remote commitment transaction hex in channel

This is useful when rebuilding the full_stack_target test vector

3 years agoRandomize secp contexts for marginally better sidechannel resistance
Matt Corallo [Sat, 13 Feb 2021 16:20:07 +0000 (11:20 -0500)]
Randomize secp contexts for marginally better sidechannel resistance

3 years agoUse lowmemory mode for secp256k1 fuzzing, reducing memcpy time
Matt Corallo [Sat, 27 Feb 2021 04:45:41 +0000 (23:45 -0500)]
Use lowmemory mode for secp256k1 fuzzing, reducing memcpy time

3 years agoUse rust-secp256k1 PR 282 and bitcoin_hashes PR 111 in fuzzing
Matt Corallo [Fri, 19 Feb 2021 01:35:54 +0000 (20:35 -0500)]
Use rust-secp256k1 PR 282 and bitcoin_hashes PR 111 in fuzzing

3 years agoSimpleArcPeerManager type: remove outer Arc for flexibility
Valentine Wallace [Fri, 26 Feb 2021 22:58:56 +0000 (17:58 -0500)]
SimpleArcPeerManager type: remove outer Arc for flexibility

3 years agoSimpleArcChannelManager type: remove outer Arc for flexibility
Valentine Wallace [Fri, 26 Feb 2021 22:55:13 +0000 (17:55 -0500)]
SimpleArcChannelManager type: remove outer Arc for flexibility

3 years agoApply --cfg=fuzzing when fuzzing, as required by new secp256k1
Matt Corallo [Fri, 19 Feb 2021 20:07:28 +0000 (15:07 -0500)]
Apply --cfg=fuzzing when fuzzing, as required by new secp256k1

Note that rust-fuzz wrappers (including honggfuzz) already apply
this for us.

3 years agoUpdate rust-bitcoin
Matt Corallo [Fri, 15 Jan 2021 01:57:56 +0000 (20:57 -0500)]
Update rust-bitcoin

3 years agopersist: Persist ChannelMonitors in their own directory.
Valentine Wallace [Fri, 26 Feb 2021 16:33:51 +0000 (11:33 -0500)]
persist: Persist ChannelMonitors in their own directory.

3 years agoMerge pull request #791 from jkczyz/2021-01-spv-client
Matt Corallo [Fri, 26 Feb 2021 15:54:01 +0000 (07:54 -0800)]
Merge pull request #791 from jkczyz/2021-01-spv-client

SPV client utility for syncing a lightning node

3 years agoUtility for syncing a set of chain listeners
Jeffrey Czyz [Fri, 5 Feb 2021 03:20:03 +0000 (19:20 -0800)]
Utility for syncing a set of chain listeners

Add a utility for syncing a set of chain listeners to a common chain
tip. Required to use before creating an SpvClient when the chain
listener used with the client is actually a set of listeners each of
which may have had left off at a different block. This would occur when
the listeners had been persisted individually at different frequencies
(e.g., a ChainMonitor's individual ChannelMonitors).

3 years agoAdd SpvClient used to poll for the best chain tip
Jeffrey Czyz [Thu, 4 Feb 2021 01:41:03 +0000 (17:41 -0800)]
Add SpvClient used to poll for the best chain tip

Adds a lightweight client for polling one or more block sources for the
best chain tip. Notifies listeners of blocks connected or disconnected
since the last poll. Useful for keeping a Lightning node in sync with
the chain.

3 years agoAdd ChainNotifier and define ChainListener trait
Jeffrey Czyz [Mon, 1 Feb 2021 21:17:20 +0000 (13:17 -0800)]
Add ChainNotifier and define ChainListener trait

Add an interface for being notified of block connected and disconnected
events, along with a notifier for generating such events. Used while
polling block sources for a new tip in order to feed these events into
ChannelManager and ChainMonitor.

3 years agoAdd ChainPoller implementation of Poll trait
Jeffrey Czyz [Mon, 1 Feb 2021 07:43:43 +0000 (23:43 -0800)]
Add ChainPoller implementation of Poll trait

ChainPoller defines a strategy for polling a single BlockSource. It
handles validating chain data returned from the BlockSource. Thus, other
implementations of Poll must be defined in terms of ChainPoller.

3 years agoDefine a Poll trait as an adaptor on BlockSource
Jeffrey Czyz [Mon, 1 Feb 2021 07:42:27 +0000 (23:42 -0800)]
Define a Poll trait as an adaptor on BlockSource

SPV clients need to poll one or more block sources for the best chain
tip and to retrieve related chain data. The Poll trait serves as an
adaptor interface for BlockSource. Implementations may define an
appropriate polling strategy.

3 years agoMerge pull request #794 from galderz/t_opt_shutdown_anysegwit_780
Matt Corallo [Thu, 25 Feb 2021 15:34:16 +0000 (07:34 -0800)]
Merge pull request #794 from galderz/t_opt_shutdown_anysegwit_780

Add support for `opt_shutdown_anysegwit` feature #780

3 years agoAdd support for `opt_shutdown_anysegwit` feature #780
Galder Zamarreño [Fri, 5 Feb 2021 14:14:12 +0000 (15:14 +0100)]
Add support for `opt_shutdown_anysegwit` feature #780

* Implemented protocol.
* Made feature optional.
* Verify that the default value is true.
* Verify that on shutdown,
if Channel.supports_shutdown_anysegwit is enabled,
the script can be a witness program.
* Added a test that verifies that a scriptpubkey
for an unreleased segwit version is handled successfully.
* Added a test that verifies that
if node has op_shutdown_anysegwit disabled,
a scriptpubkey with an unreleased segwit version on shutdown
throws an error.
* Added peer InitFeatures to handle_shutdown
* Check if shutdown script is valid when given upfront.
* Added a test to verify that an invalid test results in error.
* Added a test to check that if a segwit script with version 0 is provided,
the updated anysegwit check detects it and returns unsupported.
* An empty script is only allowed when sent as upfront shutdown script,
so make sure that check is only done for accept/open_channel situations.
* Instead of reimplementing a variant of is_witness_script,
just call it and verify that the witness version is not 0.

3 years agoMerge pull request #803 from TheBlueMatt/2021-02-derives
Matt Corallo [Mon, 22 Feb 2021 23:31:46 +0000 (15:31 -0800)]
Merge pull request #803 from TheBlueMatt/2021-02-derives

 Standardize trait derives in network message and graph objects

3 years agoUpdate auto-generated bindings 2021-02-derives
Matt Corallo [Mon, 22 Feb 2021 16:48:24 +0000 (11:48 -0500)]
Update auto-generated bindings

3 years agoAllow cloning NetworkGraphs
Matt Corallo [Mon, 22 Feb 2021 16:17:05 +0000 (11:17 -0500)]
Allow cloning NetworkGraphs

3 years agoStandardize trait derives in network graph objects
Matt Corallo [Mon, 22 Feb 2021 16:05:54 +0000 (11:05 -0500)]
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`.

3 years agoStandardize trait derives in network message objects
Matt Corallo [Sun, 21 Feb 2021 22:28:18 +0000 (17:28 -0500)]
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`.

3 years agoMerge pull request #799 from TheBlueMatt/2021-02-chansigner-rename
Matt Corallo [Mon, 22 Feb 2021 16:44:00 +0000 (08:44 -0800)]
Merge pull request #799 from TheBlueMatt/2021-02-chansigner-rename

Rename ChannelKeys -> Sign and generic it consistently

3 years agoFurther rename `chan_keys` variables to `signers` 2021-02-chansigner-rename 2021-02-chansigner-util-fns
Matt Corallo [Sat, 20 Feb 2021 15:05:55 +0000 (10:05 -0500)]
Further rename `chan_keys` variables to `signers`

3 years agoUpdate C++ bindings demo with new struct naming
Matt Corallo [Fri, 19 Feb 2021 21:09:04 +0000 (16:09 -0500)]
Update C++ bindings demo with new struct naming

3 years agoUpdate auto-generated bindings
Matt Corallo [Fri, 19 Feb 2021 21:08:04 +0000 (16:08 -0500)]
Update auto-generated bindings

3 years agoUse ChannelSigner instead of ChanSigner for type parameters
Matt Corallo [Fri, 19 Feb 2021 02:05:47 +0000 (21:05 -0500)]
Use ChannelSigner instead of ChanSigner for type parameters

3 years agoChange Persist's Sign from an associated type to a generic param
Matt Corallo [Thu, 18 Feb 2021 21:20:43 +0000 (16:20 -0500)]
Change Persist's Sign from an associated type to a generic param

3 years agoUse `signer` instead of `keys_storage` in OnchainTx to hold `Sign`
Matt Corallo [Fri, 19 Feb 2021 02:32:58 +0000 (21:32 -0500)]
Use `signer` instead of `keys_storage` in OnchainTx to hold `Sign`

3 years agoRename ChannelKeys -> Sign and generic it consistently
Matt Corallo [Tue, 16 Feb 2021 21:30:08 +0000 (16:30 -0500)]
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`).

3 years agoMerge pull request #801 from TheBlueMatt/2021-02-789-bindings
Matt Corallo [Fri, 19 Feb 2021 20:42:17 +0000 (12:42 -0800)]
Merge pull request #801 from TheBlueMatt/2021-02-789-bindings

Bindings updates for 789

3 years agoMerge pull request #752 from valentinewallace/chanman-persistence
Matt Corallo [Fri, 19 Feb 2021 20:37:24 +0000 (12:37 -0800)]
Merge pull request #752 from valentinewallace/chanman-persistence

ChannelManager persistence

3 years agoAdd BackgroundProcessor for ChannelManager persistence and other
Valentine Wallace [Mon, 11 Jan 2021 23:03:32 +0000 (18:03 -0500)]
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.

3 years agoAdd PersistenceNotifier to ChannelManager
Valentine Wallace [Thu, 19 Nov 2020 17:53:16 +0000 (12:53 -0500)]
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.

3 years agoFix Windows persistence
Valentine Wallace [Thu, 18 Feb 2021 20:45:47 +0000 (15:45 -0500)]
Fix Windows persistence

Windows started giving 'Access is denied' errors after
a few rounds of persistence. This seems to fix it.

3 years agoAbstract out disk-writing utilities from FilesystemPersister
Valentine Wallace [Thu, 19 Nov 2020 16:26:21 +0000 (11:26 -0500)]
Abstract out disk-writing utilities from FilesystemPersister

3 years agoMake logger macros public
Valentine Wallace [Wed, 2 Dec 2020 22:18:17 +0000 (17:18 -0500)]
Make logger macros public

These will be used in upcoming commits for the BackgroundProcessor
to log.

3 years agoMerge pull request #762 from valentinewallace/chan-reserve-fuzz-failure
Matt Corallo [Fri, 19 Feb 2021 19:57:46 +0000 (11:57 -0800)]
Merge pull request #762 from valentinewallace/chan-reserve-fuzz-failure

Don't include below-dust inbound HTLCs in commit tx fee calculation

3 years agoUpdate C bindings demos for new KeysManager API 2021-02-789-bindings
Matt Corallo [Fri, 19 Feb 2021 01:33:41 +0000 (20:33 -0500)]
Update C bindings demos for new KeysManager API

3 years ago- bindings updates
Matt Corallo [Fri, 19 Feb 2021 19:02:20 +0000 (14:02 -0500)]
- bindings updates

3 years ago[bindings] Handle unnamed enum variants
Matt Corallo [Fri, 19 Feb 2021 18:54:45 +0000 (13:54 -0500)]
[bindings] Handle unnamed enum variants

3 years agoAdd a no-bindings-map comment to `std::io::ErrorKind` in DecodeErr
Matt Corallo [Fri, 19 Feb 2021 18:55:15 +0000 (13:55 -0500)]
Add a no-bindings-map comment to `std::io::ErrorKind` in DecodeErr

3 years ago[bindings] Correctly use access string in to-Rust container conv
Matt Corallo [Fri, 19 Feb 2021 17:51:07 +0000 (12:51 -0500)]
[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.

3 years ago- bindings updates
Matt Corallo [Fri, 19 Feb 2021 19:01:10 +0000 (14:01 -0500)]
- bindings updates

3 years ago[bindings] Ensure owned objects in Vec conversion are marked `mut`
Matt Corallo [Fri, 19 Feb 2021 18:59:13 +0000 (13:59 -0500)]
[bindings] Ensure owned objects in Vec conversion are marked `mut`

3 years agoSwitch from slice to slice-of-refs for spend_spendable_outputs
Matt Corallo [Fri, 19 Feb 2021 18:08:54 +0000 (13:08 -0500)]
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.

3 years agoEnsure build_commitment_tx and next_local/remote_tx_fee agree on the fee
Valentine Wallace [Fri, 5 Feb 2021 18:09:23 +0000 (13:09 -0500)]
Ensure build_commitment_tx and next_local/remote_tx_fee agree on the fee

3 years agoDon't include below-dust inbound HTLCs in commit tx fee calculation
Valentine Wallace [Fri, 4 Dec 2020 21:05:10 +0000 (16:05 -0500)]
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.

3 years agoMerge pull request #795 from TheBlueMatt/2021-02-features-bindings
Matt Corallo [Thu, 18 Feb 2021 17:54:59 +0000 (09:54 -0800)]
Merge pull request #795 from TheBlueMatt/2021-02-features-bindings

Map Features objects in bindings

3 years agoMerge pull request #789 from TheBlueMatt/2021-02-chansigner-util-fns
Matt Corallo [Thu, 18 Feb 2021 17:37:00 +0000 (09:37 -0800)]
Merge pull request #789 from TheBlueMatt/2021-02-chansigner-util-fns

Add util fn for creating a Transaction from spendable outputs

3 years agoUpdate auto-generated bindings 2021-02-features-bindings
Matt Corallo [Thu, 18 Feb 2021 17:31:29 +0000 (12:31 -0500)]
Update auto-generated bindings

3 years ago[bindings] Silence c-bindings-gen compile warnings
Matt Corallo [Thu, 11 Feb 2021 21:18:47 +0000 (16:18 -0500)]
[bindings] Silence c-bindings-gen compile warnings

3 years ago[bindings] Handle `impl Clone` like `impl ::core::clone::Clone`
Matt Corallo [Thu, 11 Feb 2021 21:14:58 +0000 (16:14 -0500)]
[bindings] Handle `impl Clone` like `impl ::core::clone::Clone`

3 years ago[bindings] Drop manual implementations of Features conversion
Matt Corallo [Thu, 11 Feb 2021 17:57:14 +0000 (12:57 -0500)]
[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.

3 years ago[bindings] Handle generic-ized impl blocks by concretizing them
Matt Corallo [Thu, 11 Feb 2021 16:47:51 +0000 (11:47 -0500)]
[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.

3 years ago[bindings] Resolve type aliases mapped as opaque types
Matt Corallo [Thu, 11 Feb 2021 16:39:21 +0000 (11:39 -0500)]
[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.

3 years ago[bindings] Track structs impling traits, incl priv traits
Matt Corallo [Thu, 11 Feb 2021 16:38:31 +0000 (11:38 -0500)]
[bindings] Track structs impling traits, incl priv traits

3 years ago[bindings] Allow resolution of private types in some cases
Matt Corallo [Thu, 11 Feb 2021 16:34:16 +0000 (11:34 -0500)]
[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.

3 years agoDrop a useless import and use `Self` in return values in Features
Matt Corallo [Thu, 11 Feb 2021 15:23:41 +0000 (10:23 -0500)]
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.

3 years ago[bindings] Use new ImportResolver during first AST pass
Matt Corallo [Tue, 9 Feb 2021 03:19:48 +0000 (22:19 -0500)]
[bindings] Use new ImportResolver during first AST pass

This removes some redundant logic and ensures we handle more
import-resolution cases in both contexts.

3 years ago[bindings] Track all declared types in ImportResolver construction
Matt Corallo [Tue, 9 Feb 2021 02:09:48 +0000 (21:09 -0500)]
[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.

3 years ago[bindings] Extract import resolution logic into a separate struct
Matt Corallo [Mon, 8 Feb 2021 21:14:53 +0000 (16:14 -0500)]
[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.

3 years agoUpdate demo C++ bindings example for new bindings
Matt Corallo [Sun, 7 Feb 2021 05:58:49 +0000 (00:58 -0500)]
Update demo C++ bindings example for new bindings

3 years agoGen bindings with rustc --pretty=expanded instead of reading files
Matt Corallo [Sun, 7 Feb 2021 05:58:36 +0000 (00:58 -0500)]
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.