diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c87a0a41bd..c50abd91441 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - fix(spcli): send SettleDealPayments msg to f05 for `lotus-miner actor settle-deal` ([filecoin-project/lotus#13142](https://github.com/filecoin-project/lotus/pull/13142)) - feat: ExpectedRewardForPower builtin utility function and `lotus-shed miner expected-reward` CLI command ([filecoin-project/lotus#13138](https://github.com/filecoin-project/lotus/pull/13138)) - feat(gateway): add CORS headers if --cors is provided ([filecoin-project/lotus#13145](https://github.com/filecoin-project/lotus/pull/13145)) +- feat(spcli): make settle-deal optionally take deal id ranges ([filecoin-project/lotus#13146](https://github.com/filecoin-project/lotus/pull/13146)) # Node v1.33.0 / 2025-05-08 The Lotus v1.33.0 release introduces experimental v2 APIs with F3 awareness, featuring a new TipSet selection mechanism that significantly enhances how applications interact with the Filecoin blockchain. This release candidate also adds F3-aware Ethereum APIs via the /v2 endpoint. All of the /v2 APIs implement intelligent fallback mechanisms between F3 and Expected Consensus and are exposed through the Lotus Gateway. diff --git a/cli/spcli/actor.go b/cli/spcli/actor.go index 52f693feaaa..6a3aab4bb2b 100644 --- a/cli/spcli/actor.go +++ b/cli/spcli/actor.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" "strconv" + "strings" "github.com/docker/go-units" cbor "github.com/ipfs/go-ipld-cbor" @@ -39,7 +40,7 @@ import ( func ActorDealSettlementCmd(getActor ActorAddressGetter) *cli.Command { return &cli.Command{ Name: "settle-deal", - Usage: "Settle deals manually, if dealIds are not provided all deals will be settled", + Usage: "Settle deals manually, if dealIds are not provided all deals will be settled. Deal IDs can be specified as individual numbers or ranges (e.g., '123 124 125-200 220')", ArgsUsage: "[...dealIds]", Flags: []cli.Flag{ &cli.IntFlag{ @@ -70,12 +71,40 @@ func ActorDealSettlementCmd(getActor ActorAddressGetter) *cli.Command { // if no deal ids are provided, get all the deals for the miner if dealsIdArgs := cctx.Args().Slice(); len(dealsIdArgs) != 0 { for _, d := range dealsIdArgs { - dealId, err = strconv.ParseUint(d, 10, 64) - if err != nil { - return xerrors.Errorf("Error parsing deal id: %w", err) + // Check if it's a range (e.g., "125-200") + if strings.Contains(d, "-") { + parts := strings.Split(d, "-") + if len(parts) != 2 { + return xerrors.Errorf("Invalid range format: %s (expected format: start-end)", d) + } + + start, err := strconv.ParseUint(strings.TrimSpace(parts[0]), 10, 64) + if err != nil { + return xerrors.Errorf("Error parsing start of range %s: %w", d, err) + } + + end, err := strconv.ParseUint(strings.TrimSpace(parts[1]), 10, 64) + if err != nil { + return xerrors.Errorf("Error parsing end of range %s: %w", d, err) + } + + if start > end { + return xerrors.Errorf("Invalid range %s: start must be less than or equal to end", d) + } + + // Add all deal IDs in the range (inclusive) + for id := start; id <= end; id++ { + dealIDs = append(dealIDs, id) + } + } else { + // Parse as a single deal ID + dealId, err = strconv.ParseUint(d, 10, 64) + if err != nil { + return xerrors.Errorf("Error parsing deal id: %w", err) + } + + dealIDs = append(dealIDs, dealId) } - - dealIDs = append(dealIDs, dealId) } } else { if dealIDs, err = GetMinerAllDeals(ctx, api, maddr, types.EmptyTSK); err != nil { diff --git a/documentation/en/cli-lotus-miner.md b/documentation/en/cli-lotus-miner.md index 39d40b19919..3940b5652cb 100644 --- a/documentation/en/cli-lotus-miner.md +++ b/documentation/en/cli-lotus-miner.md @@ -209,7 +209,7 @@ USAGE: COMMANDS: set-addresses, set-addrs set addresses that your miner can be publicly dialed on - settle-deal Settle deals manually, if dealIds are not provided all deals will be settled + settle-deal Settle deals manually, if dealIds are not provided all deals will be settled. Deal IDs can be specified as individual numbers or ranges (e.g., '123 124 125-200 220') withdraw withdraw available balance to beneficiary repay-debt pay down a miner's debt set-peer-id set the peer id of your miner @@ -246,7 +246,7 @@ OPTIONS: ``` NAME: - lotus-miner actor settle-deal - Settle deals manually, if dealIds are not provided all deals will be settled + lotus-miner actor settle-deal - Settle deals manually, if dealIds are not provided all deals will be settled. Deal IDs can be specified as individual numbers or ranges (e.g., '123 124 125-200 220') USAGE: lotus-miner actor settle-deal [command options] [...dealIds]