@@ -5,7 +5,6 @@ package main
55
66import (
77 "bytes"
8- "context"
98 "encoding/base64"
109 "encoding/hex"
1110 "encoding/json"
@@ -21,7 +20,6 @@ import (
2120 "github.com/btcsuite/btcd/chaincfg/chainhash"
2221 "github.com/btcsuite/btcd/txscript"
2322 "github.com/btcsuite/btcd/wire"
24- "github.com/lightningnetwork/lnd/lnrpc"
2523 "github.com/lightningnetwork/lnd/lnrpc/walletrpc"
2624 "github.com/lightningnetwork/lnd/lnwallet/chainfee"
2725 "github.com/lightningnetwork/lnd/lnwallet/chanfunding"
@@ -431,51 +429,50 @@ var bumpForceCloseFeeCommand = cli.Command{
431429 allows the fee of a channel force closing transaction to be increased by
432430 using the child-pays-for-parent mechanism. It will instruct the sweeper
433431 to sweep the anchor outputs of the closing transaction at the requested
434- fee rate or confirmation target. The specified fee rate will be the
435- effective fee rate taking the parent fee into account.
432+ confirmation target and limit the fees to the specified budget.
436433 ` ,
437434 Flags : []cli.Flag {
438435 cli.Uint64Flag {
439436 Name : "conf_target" ,
440437 Usage : `
441- The deadline in number of blocks that the input should be spent within.
442- When not set, for new inputs, the default value (1008) is used; for
443- exiting inputs, their current values will be retained.` ,
438+ The deadline in number of blocks that the anchor output should be spent
439+ within to bump the closing transaction.` ,
444440 },
445441 cli.Uint64Flag {
446442 Name : "sat_per_byte" ,
447443 Usage : "Deprecated, use sat_per_vbyte instead." ,
448444 Hidden : true ,
449445 },
450- cli.BoolFlag {
451- Name : "force" ,
452- Usage : "Deprecated, use immediate instead." ,
453- Hidden : true ,
454- },
455446 cli.Uint64Flag {
456447 Name : "sat_per_vbyte" ,
457448 Usage : `
458- The starting fee rate, expressed in sat/vbyte, that will be used to
459- spend the input with initially. This value will be used by the
460- sweeper's fee function as its starting fee rate. When not set, the
461- sweeper will use the estimated fee rate using the target_conf as the
449+ The starting fee rate, expressed in sat/vbyte. This value will be used
450+ by the sweeper's fee function as its starting fee rate. When not set,
451+ the sweeper will use the estimated fee rate using the target_conf as the
462452 starting fee rate.` ,
463453 },
454+ cli.BoolFlag {
455+ Name : "force" ,
456+ Usage : "Deprecated, use immediate instead." ,
457+ Hidden : true ,
458+ },
464459 cli.BoolFlag {
465460 Name : "immediate" ,
466461 Usage : `
467- Whether this input will be swept immediately. When set to true, the
468- sweeper will sweep this input without waiting for the next batch.` ,
462+ Whether this cpfp transaction will be triggered immediately. When set to
463+ true, the sweeper will consider all currently pending registered sweeps
464+ and trigger new batch transactions including the sweeping of the anchor
465+ output related to the selected force close transaction.` ,
469466 },
470467 cli.Uint64Flag {
471468 Name : "budget" ,
472469 Usage : `
473- The max amount in sats that can be used as the fees. Setting this value
474- greater than the input's value may result in CPFP - one or more wallet
475- utxos will be used to pay the fees specified by the budget. If not set,
476- for new inputs, by default 50% of the input's value will be treated as
477- the budget for fee bumping; for existing inputs, their current budgets
478- will be retained .` ,
470+ The max amount in sats that can be used as the fees. For already
471+ registered anchor outputs if not set explicitly the old value will be
472+ used. For channel force closes which have no HTLCs in their commitment
473+ transaction this value has to be set to an appropriate amount to pay for
474+ the cpfp transaction of the force closed channel otherwise the fee
475+ bumping will fail .` ,
479476 },
480477 },
481478 Action : actionDecorator (bumpForceCloseFee ),
@@ -492,97 +489,42 @@ func bumpForceCloseFee(ctx *cli.Context) error {
492489
493490 // Validate the channel point.
494491 channelPoint := ctx .Args ().Get (0 )
495- _ , err := NewProtoOutPoint (channelPoint )
492+ rpcChannelPoint , err := parseChanPoint (channelPoint )
496493 if err != nil {
497494 return err
498495 }
499496
500- // Fetch all waiting close channels.
501- client , cleanUp := getClient (ctx )
502- defer cleanUp ()
503-
504- // Fetch waiting close channel commitments.
505- commitments , err := getWaitingCloseCommitments (
506- ctxc , client , channelPoint ,
507- )
508- if err != nil {
509- return err
497+ // `sat_per_byte` was deprecated we only use sats/vbyte now.
498+ if ctx .IsSet ("sat_per_byte" ) {
499+ return fmt .Errorf ("deprecated, use sat_per_vbyte instead" )
510500 }
511501
512502 // Retrieve pending sweeps.
513503 walletClient , cleanUp := getWalletClient (ctx )
514504 defer cleanUp ()
515505
516- sweeps , err := walletClient .PendingSweeps (
517- ctxc , & walletrpc.PendingSweepsRequest {},
518- )
519- if err != nil {
520- return err
521- }
522-
523- // Match pending sweeps with commitments of the channel for which a bump
524- // is requested and bump their fees.
525- commitSet := map [string ]struct {}{
526- commitments .LocalTxid : {},
527- commitments .RemoteTxid : {},
528- }
529- if commitments .RemotePendingTxid != "" {
530- commitSet [commitments .RemotePendingTxid ] = struct {}{}
531- }
532-
533- for _ , sweep := range sweeps .PendingSweeps {
534- // Only bump anchor sweeps.
535- if sweep .WitnessType != walletrpc .WitnessType_COMMITMENT_ANCHOR {
536- continue
537- }
538-
539- // Skip unrelated sweeps.
540- sweepTxID , err := chainhash .NewHash (sweep .Outpoint .TxidBytes )
541- if err != nil {
542- return err
543- }
544- if _ , match := commitSet [sweepTxID .String ()]; ! match {
545- continue
546- }
547-
548- resp , err := walletClient .BumpFee (
549- ctxc , & walletrpc.BumpFeeRequest {
550- Outpoint : sweep .Outpoint ,
551- TargetConf : uint32 (ctx .Uint64 ("conf_target" )),
552- Budget : ctx .Uint64 ("budget" ),
553- Immediate : ctx .Bool ("immediate" ),
554- SatPerVbyte : ctx .Uint64 ("sat_per_vbyte" ),
555- })
556- if err != nil {
557- return err
558- }
559-
560- // Bump fee of the anchor sweep.
561- fmt .Printf ("Bumping fee of %v:%v: %v\n " ,
562- sweepTxID , sweep .Outpoint .OutputIndex , resp .GetStatus ())
506+ // Parse immediate flag (force flag was deprecated).
507+ if ctx .IsSet ("immediate" ) && ctx .IsSet ("force" ) {
508+ return fmt .Errorf ("cannot set immediate and force flag at " +
509+ "the same time" )
563510 }
511+ immediate := ctx .Bool ("immediate" ) || ctx .Bool ("force" )
564512
565- return nil
566- }
567-
568- func getWaitingCloseCommitments (ctxc context.Context ,
569- client lnrpc.LightningClient , channelPoint string ) (
570- * lnrpc.PendingChannelsResponse_Commitments , error ) {
571-
572- req := & lnrpc.PendingChannelsRequest {}
573- resp , err := client .PendingChannels (ctxc , req )
513+ resp , err := walletClient .BumpForceCloseFee (
514+ ctxc , & walletrpc.BumpForceCloseFeeRequest {
515+ ChanPoint : rpcChannelPoint ,
516+ DeadlineDelta : uint32 (ctx .Uint64 ("conf_target" )),
517+ Budget : ctx .Uint64 ("budget" ),
518+ Immediate : immediate ,
519+ StartingFeerate : ctx .Uint64 ("sat_per_vbyte" ),
520+ })
574521 if err != nil {
575- return nil , err
522+ return err
576523 }
577524
578- // Lookup the channel commit tx hashes.
579- for _ , channel := range resp .WaitingCloseChannels {
580- if channel .Channel .ChannelPoint == channelPoint {
581- return channel .Commitments , nil
582- }
583- }
525+ fmt .Printf ("BumpForceCloseFee result: %s\n " , resp .Status )
584526
585- return nil , errors . New ( "channel not found" )
527+ return nil
586528}
587529
588530var listSweepsCommand = cli.Command {
0 commit comments