From 41fd16b43eb78e4461510452a2f9afefe6016d05 Mon Sep 17 00:00:00 2001 From: Richard Safier Date: Mon, 29 Apr 2024 15:24:57 -0400 Subject: [PATCH] AllPayments flag in newest LND daily gRPC, a flag is now required for DeletePayments call. version bump 1.64 --- LNUnit.LND/Grpc/lightning.proto | 52 +++++++- LNUnit.LND/Grpc/walletrpc/walletkit.proto | 125 +++++++++++++----- LNUnit.LND/LNUnit.LND.csproj | 2 +- LNUnit.Tests/AbcLightningFixtureBoltDb.cs | 2 +- .../Abstract/AbcLightningAbstractTests.cs | 7 +- LNUnit/LNUnit.csproj | 2 +- 6 files changed, 147 insertions(+), 43 deletions(-) diff --git a/LNUnit.LND/Grpc/lightning.proto b/LNUnit.LND/Grpc/lightning.proto index 079f2cd..2ad22e0 100644 --- a/LNUnit.LND/Grpc/lightning.proto +++ b/LNUnit.LND/Grpc/lightning.proto @@ -1091,6 +1091,18 @@ message LightningAddress { string host = 2; } +enum CoinSelectionStrategy { + // Use the coin selection strategy defined in the global configuration + // (lnd.conf). + STRATEGY_USE_GLOBAL_CONFIG = 0; + + // Select the largest available coins first during coin selection. + STRATEGY_LARGEST = 1; + + // Randomly select the available coins during coin selection. + STRATEGY_RANDOM = 2; +} + message EstimateFeeRequest { // The map from addresses to amounts for the transaction. map AddrToAmount = 1; @@ -1105,6 +1117,9 @@ message EstimateFeeRequest { // Whether unconfirmed outputs should be used as inputs for the transaction. bool spend_unconfirmed = 4; + + // The strategy to use for selecting coins during fees estimation. + CoinSelectionStrategy coin_selection_strategy = 5; } message EstimateFeeResponse { @@ -1145,6 +1160,9 @@ message SendManyRequest { // Whether unconfirmed outputs should be used as inputs for the transaction. bool spend_unconfirmed = 8; + + // The strategy to use for selecting coins during sending many requests. + CoinSelectionStrategy coin_selection_strategy = 9; } message SendManyResponse { // The id of the transaction @@ -1187,6 +1205,9 @@ message SendCoinsRequest { // Whether unconfirmed outputs should be used as inputs for the transaction. bool spend_unconfirmed = 9; + + // The strategy to use for selecting coins. + CoinSelectionStrategy coin_selection_strategy = 10; } message SendCoinsResponse { // The transaction ID of the transaction @@ -2115,6 +2136,9 @@ message BatchOpenChannelRequest { // An optional label for the batch transaction, limited to 500 characters. string label = 6; + + // The strategy to use for selecting coins during batch opening channels. + CoinSelectionStrategy coin_selection_strategy = 7; } message BatchOpenChannel { @@ -3330,6 +3354,9 @@ message RoutingPolicy { // Custom channel update tlv records. map custom_records = 8; + + int32 inbound_fee_base_msat = 9; + int32 inbound_fee_rate_milli_msat = 10; } /* @@ -3545,8 +3572,11 @@ message BlindedPaymentPath { // The base fee for the blinded path provided, expressed in msat. uint64 base_fee_msat = 2; - // The proportional fee for the blinded path provided, expressed in msat. - uint64 proportional_fee_msat = 3; + /* + The proportional fee for the blinded path provided, expressed in parts + per million. + */ + uint32 proportional_fee_rate = 3; /* The total CLTV delta for the blinded path provided, including the @@ -4201,6 +4231,10 @@ message DeleteAllPaymentsRequest { Only delete failed HTLCs from payments, not the payment itself. */ bool failed_htlcs_only = 2; + + // Delete all payments. NOTE: Using this option requires careful + // consideration as it is a destructive operation. + bool all_payments = 3; } message DeletePaymentResponse { @@ -4277,6 +4311,8 @@ enum FeatureBit { ANCHORS_OPT = 21; ANCHORS_ZERO_FEE_HTLC_REQ = 22; ANCHORS_ZERO_FEE_HTLC_OPT = 23; + ROUTE_BLINDING_REQUIRED = 24; + ROUTE_BLINDING_OPTIONAL = 25; AMP_REQ = 30; AMP_OPT = 31; } @@ -4306,7 +4342,15 @@ message ChannelFeeReport { // The effective fee rate in milli-satoshis. Computed by dividing the // fee_per_mil value by 1 million. double fee_rate = 4; + + // The base fee charged regardless of the number of milli-satoshis sent. + int32 inbound_base_fee_msat = 6; + + // The amount charged per milli-satoshis transferred expressed in + // millionths of a satoshi. + int32 inbound_fee_per_mil = 7; } + message FeeReportResponse { // An array of channel fee reports which describes the current fee schedule // for each channel. @@ -4357,7 +4401,11 @@ message PolicyUpdateRequest { // If true, min_htlc_msat is applied. bool min_htlc_msat_specified = 8; + + int32 inbound_base_fee_msat = 10; + int32 inbound_fee_rate_ppm = 11; } + enum UpdateFailure { UPDATE_FAILURE_UNKNOWN = 0; UPDATE_FAILURE_PENDING = 1; diff --git a/LNUnit.LND/Grpc/walletrpc/walletkit.proto b/LNUnit.LND/Grpc/walletrpc/walletkit.proto index a09fd59..b6d09c6 100644 --- a/LNUnit.LND/Grpc/walletrpc/walletkit.proto +++ b/LNUnit.LND/Grpc/walletrpc/walletkit.proto @@ -242,31 +242,34 @@ service WalletKit { rpc PendingSweeps (PendingSweepsRequest) returns (PendingSweepsResponse); /* lncli: `wallet bumpfee` - BumpFee bumps the fee of an arbitrary input within a transaction. This RPC - takes a different approach than bitcoind's bumpfee command. lnd has a - central batching engine in which inputs with similar fee rates are batched - together to save on transaction fees. Due to this, we cannot rely on - bumping the fee on a specific transaction, since transactions can change at - any point with the addition of new inputs. The list of inputs that - currently exist within lnd's central batching engine can be retrieved - through the PendingSweeps RPC. - - When bumping the fee of an input that currently exists within lnd's central - batching engine, a higher fee transaction will be created that replaces the - lower fee transaction through the Replace-By-Fee (RBF) policy. If it + BumpFee is an endpoint that allows users to interact with lnd's sweeper + directly. It takes an outpoint from an unconfirmed transaction and sends it + to the sweeper for potential fee bumping. Depending on whether the outpoint + has been registered in the sweeper (an existing input, e.g., an anchor + output) or not (a new input, e.g., an unconfirmed wallet utxo), this will + either be an RBF or CPFP attempt. + + When receiving an input, lnd’s sweeper needs to understand its time + sensitivity to make economical fee bumps - internally a fee function is + created using the deadline and budget to guide the process. When the + deadline is approaching, the fee function will increase the fee rate and + perform an RBF. + + When a force close happens, all the outputs from the force closing + transaction will be registered in the sweeper. The sweeper will then handle + the creation, publish, and fee bumping of the sweeping transactions. + Everytime a new block comes in, unless the sweeping transaction is + confirmed, an RBF is attempted. To interfere with this automatic process, + users can use BumpFee to specify customized fee rate, budget, deadline, and + whether the sweep should happen immediately. It's recommended to call + `ListSweeps` to understand the shape of the existing sweeping transaction + first - depending on the number of inputs in this transaction, the RBF + requirements can be quite different. This RPC also serves useful when wanting to perform a Child-Pays-For-Parent (CPFP), where the child transaction pays for its parent's fee. This can be done by specifying an outpoint within the low fee transaction that is under the control of the wallet. - - The fee preference can be expressed either as a specific fee rate or a delta - of blocks in which the output should be swept on-chain within. If a fee - preference is not explicitly specified, then an error is returned. - - Note that this RPC currently doesn't perform any validation checks on the - fee preference being provided. For now, the responsibility of ensuring that - the new fee preference is sufficient is delegated to the user. */ rpc BumpFee (BumpFeeRequest) returns (BumpFeeResponse); @@ -813,6 +816,9 @@ message SendOutputsRequest { // Whether unconfirmed outputs should be used as inputs for the transaction. bool spend_unconfirmed = 5; + + // The strategy to use for selecting coins during sending the outputs. + lnrpc.CoinSelectionStrategy coin_selection_strategy = 6; } message SendOutputsResponse { /* @@ -1102,33 +1108,56 @@ message PendingSweep { uint32 broadcast_attempts = 5; /* + Deprecated. The next height of the chain at which we'll attempt to broadcast the sweep transaction of the output. */ - uint32 next_broadcast_height = 6; + uint32 next_broadcast_height = 6 [deprecated = true]; - // The requested confirmation target for this output. - uint32 requested_conf_target = 8; + /* + Deprecated, use immediate. + Whether this input must be force-swept. This means that it is swept + immediately. + */ + bool force = 7 [deprecated = true]; + + /* + Deprecated, use deadline. + The requested confirmation target for this output, which is the deadline + used by the sweeper. + */ + uint32 requested_conf_target = 8 [deprecated = true]; // Deprecated, use requested_sat_per_vbyte. // The requested fee rate, expressed in sat/vbyte, for this output. uint32 requested_sat_per_byte = 9 [deprecated = true]; /* - The fee rate we'll use to sweep the output, expressed in sat/vbyte. The fee - rate is only determined once a sweeping transaction for the output is - created, so it's possible for this to be 0 before this. + The current fee rate we'll use to sweep the output, expressed in sat/vbyte. + The fee rate is only determined once a sweeping transaction for the output + is created, so it's possible for this to be 0 before this. */ uint64 sat_per_vbyte = 10; - // The requested fee rate, expressed in sat/vbyte, for this output. + // The requested starting fee rate, expressed in sat/vbyte, for this + // output. When not requested, this field will be 0. uint64 requested_sat_per_vbyte = 11; /* - Whether this input must be force-swept. This means that it is swept even - if it has a negative yield. + Whether this input will be swept immediately. */ - bool force = 7; + bool immediate = 12; + + /* + The budget for this sweep, expressed in satoshis. This is the maximum amount + that can be spent as fees to sweep this output. + */ + uint64 budget = 13; + + /* + The deadline height used for this output when perform fee bumping. + */ + uint32 deadline_height = 14; } message PendingSweepsRequest { @@ -1145,7 +1174,9 @@ message BumpFeeRequest { // The input we're attempting to bump the fee of. lnrpc.OutPoint outpoint = 1; - // The target number of blocks that the input should be spent within. + // Optional. The deadline in number of blocks that the input should be spent + // within. When not set, for new inputs, the default value (1008) is used; + // for exiting inputs, their current values will be retained. uint32 target_conf = 2; /* @@ -1156,16 +1187,35 @@ message BumpFeeRequest { uint32 sat_per_byte = 3 [deprecated = true]; /* - Whether this input must be force-swept. This means that it is swept even - if it has a negative yield. + Deprecated, use immediate. + Whether this input must be force-swept. This means that it is swept + immediately. */ - bool force = 4; + bool force = 4 [deprecated = true]; /* - The fee rate, expressed in sat/vbyte, that should be used to spend the input - with. + Optional. The starting fee rate, expressed in sat/vbyte, that will be used + to spend the input with initially. This value will be used by the sweeper's + fee function as its starting fee rate. When not set, the sweeper will use + the estimated fee rate using the `target_conf` as the starting fee rate. */ uint64 sat_per_vbyte = 5; + + /* + Optional. Whether this input will be swept immediately. When set to true, + the sweeper will sweep this input without waiting for the next batch. + */ + bool immediate = 6; + + /* + Optional. The max amount in sats that can be used as the fees. Setting this + value greater than the input's value may result in CPFP - one or more wallet + utxos will be used to pay the fees specified by the budget. If not set, for + new inputs, by default 50% of the input's value will be treated as the + budget for fee bumping; for existing inputs, their current budgets will be + retained. + */ + uint64 budget = 7; } message BumpFeeResponse { @@ -1308,6 +1358,9 @@ message FundPsbtRequest { // accounts, no change type should be provided as the coin selection key // scope will always be used to generate the change address. ChangeAddressType change_type = 8; + + // The strategy to use for selecting coins during funding the PSBT. + lnrpc.CoinSelectionStrategy coin_selection_strategy = 10; } message FundPsbtResponse { /* diff --git a/LNUnit.LND/LNUnit.LND.csproj b/LNUnit.LND/LNUnit.LND.csproj index 82c962c..8eb8686 100644 --- a/LNUnit.LND/LNUnit.LND.csproj +++ b/LNUnit.LND/LNUnit.LND.csproj @@ -6,7 +6,7 @@ enable true LNUnit.LND - 1.6.3 + 1.6.4 LNUnit LND Typed Clients diff --git a/LNUnit.Tests/AbcLightningFixtureBoltDb.cs b/LNUnit.Tests/AbcLightningFixtureBoltDb.cs index ed1fd90..c95447a 100644 --- a/LNUnit.Tests/AbcLightningFixtureBoltDb.cs +++ b/LNUnit.Tests/AbcLightningFixtureBoltDb.cs @@ -3,7 +3,7 @@ namespace LNUnit.Tests; [TestFixture("boltdb", "lightninglabs/lnd", "daily-testing-only", "/root/.lnd", true)] -[TestFixture("boltdb", "custom_lnd", "latest", "/home/lnd/.lnd", false)] +//[TestFixture("boltdb", "custom_lnd", "latest", "/home/lnd/.lnd", false)] public class AbcLightningAbstractTestsBoltDb : LNUnit.Tests.Abstract.AbcLightningAbstractTests { public AbcLightningAbstractTestsBoltDb(string dbType = "boltdb", diff --git a/LNUnit.Tests/Abstract/AbcLightningAbstractTests.cs b/LNUnit.Tests/Abstract/AbcLightningAbstractTests.cs index b6fa052..29b29e8 100644 --- a/LNUnit.Tests/Abstract/AbcLightningAbstractTests.cs +++ b/LNUnit.Tests/Abstract/AbcLightningAbstractTests.cs @@ -1065,13 +1065,16 @@ public async Task ListInvoiceAndPaymentNoDatePage() var bob = await Builder.WaitUntilAliasIsServerReady("bob"); //purge data - await bob.LightningClient.DeleteAllPaymentsAsync(new DeleteAllPaymentsRequest()); + await bob.LightningClient.DeleteAllPaymentsAsync(new DeleteAllPaymentsRequest() + { + AllPayments = true, + }); var payment = await Builder.MakeLightningPaymentFromAlias("bob", new SendPaymentRequest { PaymentRequest = invoice.PaymentRequest, FeeLimitSat = 100000000, - TimeoutSeconds = 5 + TimeoutSeconds = 5, }); Assert.That(payment.Status == Payment.Types.PaymentStatus.Succeeded); diff --git a/LNUnit/LNUnit.csproj b/LNUnit/LNUnit.csproj index 0d7195d..4492c61 100644 --- a/LNUnit/LNUnit.csproj +++ b/LNUnit/LNUnit.csproj @@ -5,7 +5,7 @@ enable enable Linux - 1.6.3 + 1.6.4 true LNUnit Lightning Network Unit Testing Framework