Skip to content

Commit

Permalink
added include-spent-coins option to get_mempool_items_by_coin_name (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
cameroncooper authored Feb 1, 2025
1 parent 0330074 commit 5f969e4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions internal/cmd/coinset/get_mempool_items_by_coin_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ import (
"github.com/spf13/cobra"
)

var (
getMempoolItemsByCoinNameIncludeSpentCoins bool
)

func init() {
rootCmd.AddCommand(getMempoolItemsByCoinName)
getMempoolItemsByCoinNameCmd.Flags().BoolVarP(&getMempoolItemsByCoinNameIncludeSpentCoins, "include-spent-coins", "s", false, "Include items no longer in the mempool")
rootCmd.AddCommand(getMempoolItemsByCoinNameCmd)
}

var getMempoolItemsByCoinName = &cobra.Command{
var getMempoolItemsByCoinNameCmd = &cobra.Command{
Use: "get_mempool_items_by_coin_name <coin_name>",
Args: func(cmd *cobra.Command, args []string) error {
if err := cobra.ExactArgs(1)(cmd, args); err != nil {
Expand All @@ -26,6 +31,9 @@ var getMempoolItemsByCoinName = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
jsonData := map[string]interface{}{}
jsonData["coin_name"] = formatHex(args[0])
if getMempoolItemsByCoinNameIncludeSpentCoins {
jsonData["include_spent_coins"] = true
}
makeRequest("get_mempool_items_by_coin_name", jsonData)
},
}

0 comments on commit 5f969e4

Please sign in to comment.