-
Notifications
You must be signed in to change notification settings - Fork 2.2k
walletrpc: add raw_tx field to BumpFee response #10323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -293,9 +293,13 @@ reader of a payment request. | |
| [removed](https://github.com/lightningnetwork/lnd/pull/9967) meaning that any | ||
| test network scripts that rely on bootstrapping being disabled will need to | ||
| explicitly define the `--nobootstrap` flag. Bootstrapping will now also be | ||
| [deterministic](https://github.com/lightningnetwork/lnd/pull/10003) on local | ||
| [deterministic](https://github.com/lightningnetwork/lnd/pull/10003) on local | ||
| test networks so that bootstrapping behaviour can be tested for. | ||
|
|
||
| * [Increased wallet sync timeout](https://github.com/lightningnetwork/lnd/pull/10323) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be put in 0.21 |
||
| in integration tests from 30 seconds to 120 seconds to reduce test flakiness | ||
| in CI environments, particularly for the neutrino backend wallet sync tests. | ||
|
|
||
| ## Database | ||
|
|
||
| * Add missing [sql index](https://github.com/lightningnetwork/lnd/pull/10155) | ||
|
|
||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1241,11 +1241,25 @@ message BumpFeeRequest { | |||||||||||||||||||||||
| // fee function that the sweeper will use to bump the fee rate. When the | ||||||||||||||||||||||||
| // deadline is reached, ALL the budget will be spent as fees. | ||||||||||||||||||||||||
| uint32 deadline_delta = 8; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||
| Optional. Whether to include the raw transaction hex in the response. This | ||||||||||||||||||||||||
| is useful for cases where the transaction does not propagate and the caller | ||||||||||||||||||||||||
| wants to manually broadcast it. | ||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||
|
Comment on lines
+1245
to
+1249
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment for
Suggested change
|
||||||||||||||||||||||||
| bool include_raw_tx = 9; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| message BumpFeeResponse { | ||||||||||||||||||||||||
| // The status of the bump fee operation. | ||||||||||||||||||||||||
| string status = 1; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /* | ||||||||||||||||||||||||
| The raw transaction hex of the sweeping transaction. This field is only | ||||||||||||||||||||||||
| populated if include_raw_tx was set to true in the request and the sweep | ||||||||||||||||||||||||
| transaction was successfully created. | ||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||
| string raw_tx = 2; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| message BumpForceCloseFeeRequest { | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ import ( | |
| "context" | ||
| "encoding/base64" | ||
| "encoding/binary" | ||
| "encoding/hex" | ||
| "errors" | ||
| "fmt" | ||
| "maps" | ||
|
|
@@ -1151,27 +1152,59 @@ func (w *WalletKit) BumpFee(ctx context.Context, | |
| return nil, err | ||
| } | ||
|
|
||
| var ( | ||
| resultChan chan sweep.Result | ||
| status string | ||
| ) | ||
|
|
||
| // If this input exists, we will update its params. | ||
| if existing { | ||
| _, err = w.cfg.Sweeper.UpdateParams(*op, params) | ||
| resultChan, err = w.cfg.Sweeper.UpdateParams(*op, params) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| status = "Successfully registered rbf-tx with sweeper" | ||
| } else { | ||
| // Otherwise, create a new sweeping request for this input. | ||
| resultChan, err = w.sweepNewInput( | ||
| op, uint32(currentHeight), params, | ||
| ) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| status = "Successfully registered CPFP-tx with the sweeper" | ||
| } | ||
|
|
||
| return &BumpFeeResponse{ | ||
| Status: "Successfully registered rbf-tx with sweeper", | ||
| }, nil | ||
| response := &BumpFeeResponse{ | ||
| Status: status, | ||
| } | ||
|
|
||
| // Otherwise, create a new sweeping request for this input. | ||
| err = w.sweepNewInput(op, uint32(currentHeight), params) | ||
| if err != nil { | ||
| return nil, err | ||
| // If the caller requested the raw transaction, wait for the sweep | ||
| // result and extract the transaction hex. | ||
| if in.IncludeRawTx { | ||
| select { | ||
| case result := <-resultChan: | ||
| if result.Err != nil { | ||
| return nil, fmt.Errorf("sweep failed: %w", | ||
| result.Err) | ||
| } | ||
|
|
||
| if result.Tx != nil { | ||
| var buf bytes.Buffer | ||
| err := result.Tx.Serialize(&buf) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to "+ | ||
| "serialize tx: %w", err) | ||
|
Comment on lines
+1196
to
+1197
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This string concatenation is unnecessary as the line is not exceeding the length limit. Combining it into a single string improves readability.1 return nil, fmt.Errorf("failed to serialize tx: %w", err)Style Guide ReferencesFootnotes
|
||
| } | ||
| response.RawTx = hex.EncodeToString(buf.Bytes()) | ||
| } | ||
|
|
||
| case <-ctx.Done(): | ||
| return nil, ctx.Err() | ||
| } | ||
| } | ||
|
|
||
| return &BumpFeeResponse{ | ||
| Status: "Successfully registered CPFP-tx with the sweeper", | ||
| }, nil | ||
| return response, nil | ||
| } | ||
|
|
||
| // getWaitingCloseChannel returns the waiting close channel in case it does | ||
|
|
@@ -1343,7 +1376,7 @@ func (w *WalletKit) BumpForceCloseFee(_ context.Context, | |
| // | ||
| // NOTE: if the budget is not set, the default budget ratio is used. | ||
| func (w *WalletKit) sweepNewInput(op *wire.OutPoint, currentHeight uint32, | ||
| params sweep.Params) error { | ||
| params sweep.Params) (chan sweep.Result, error) { | ||
|
|
||
| log.Debugf("Attempting to sweep outpoint %s", op) | ||
|
|
||
|
|
@@ -1356,12 +1389,12 @@ func (w *WalletKit) sweepNewInput(op *wire.OutPoint, currentHeight uint32, | |
| // order to sweep the output. | ||
| utxo, err := w.cfg.Wallet.FetchOutpointInfo(op) | ||
| if err != nil { | ||
| return err | ||
| return nil, err | ||
| } | ||
|
|
||
| // We're only able to bump the fee of unconfirmed transactions. | ||
| if utxo.Confirmations > 0 { | ||
| return errors.New("unable to bump fee of a confirmed " + | ||
| return nil, errors.New("unable to bump fee of a confirmed " + | ||
| "transaction") | ||
| } | ||
|
|
||
|
|
@@ -1401,18 +1434,19 @@ func (w *WalletKit) sweepNewInput(op *wire.OutPoint, currentHeight uint32, | |
| witnessType = input.TaprootPubKeySpend | ||
| signDesc.HashType = txscript.SigHashDefault | ||
| default: | ||
| return fmt.Errorf("unknown input witness %v", op) | ||
| return nil, fmt.Errorf("unknown input witness %v", op) | ||
| } | ||
|
|
||
| log.Infof("[BumpFee]: bumping fee for new input=%v, params=%v", op, | ||
| params) | ||
|
|
||
| inp := input.NewBaseInput(op, witnessType, signDesc, currentHeight) | ||
| if _, err = w.cfg.Sweeper.SweepInput(inp, params); err != nil { | ||
| return err | ||
| resultChan, err := w.cfg.Sweeper.SweepInput(inp, params) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return nil | ||
| return resultChan, nil | ||
| } | ||
|
|
||
| // ListSweeps returns a list of the sweeps that our node has published. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the commit msg should start with the pkg name, like
docs:orlnwallet, and we usually update release note in a single commit. also I don't know whatDelete CLAUDE.mdmeant in the commit body.