-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added get_block_spends_with_conditions
- Loading branch information
1 parent
2446c61
commit b482bc7
Showing
2 changed files
with
33 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
func init() { | ||
rootCmd.AddCommand(getBlockSpendsWithConditionsCmd) | ||
} | ||
|
||
var getBlockSpendsWithConditionsCmd = &cobra.Command{ | ||
Use: "get_block_spends_with_conditions <header_hash>", | ||
Args: func(cmd *cobra.Command, args []string) error { | ||
if err := cobra.ExactArgs(1)(cmd, args); err != nil { | ||
return err | ||
} | ||
if isHex(args[0]) == true { | ||
return nil | ||
} | ||
return fmt.Errorf("invalid hex value specified: %s", args[0]) | ||
}, | ||
Short: "Retrieves every coin that was spent in a block with the returned conditions", | ||
Long: `Retrieves every coin that was spent in a block with the returned conditions`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
jsonData := map[string]interface{}{} | ||
jsonData["header_hash"] = formatHex(args[0]) | ||
makeRequest("get_block_spends_with_conditions", jsonData) | ||
}, | ||
} |