Skip to content

Commit

Permalink
Add command for inclusion proof
Browse files Browse the repository at this point in the history
  • Loading branch information
KonradStaniec committed Oct 2, 2024
1 parent 5774cfa commit fd84dab
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions x/btcstaking/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func GetTxCmd() *cobra.Command {
NewAddCovenantSigsCmd(),
NewBTCUndelegateCmd(),
NewSelectiveSlashingEvidenceCmd(),
NewAddBTCDelegationInclusionProofCmd(),
)

return cmd
Expand Down Expand Up @@ -315,6 +316,43 @@ func NewCreateBTCDelegationCmd() *cobra.Command {
return cmd
}

func NewAddBTCDelegationInclusionProofCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "add-btc-inclusion-proof [staking_tx_hash] [inclusion_proof]",
Args: cobra.ExactArgs(2),
Short: "Add a signature on the unbonding tx of a BTC delegation identified by a given staking tx hash. ",
Long: strings.TrimSpace(
`Add a signature on the unbonding tx of a BTC delegation identified by a given staking tx hash signed by the delegator. The signature proves that delegator wants to unbond, and Babylon will consider the BTC delegation unbonded.`, // TODO: example
),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

// get staking tx hash
stakingTxHash := args[0]

inclusionProof, err := types.NewInclusionProofFromHex(args[1])
if err != nil {
return err
}

msg := types.MsgAddBTCDelegationInclusionProof{
Signer: clientCtx.FromAddress.String(),
StakingTxHash: stakingTxHash,
StakingTxInclusionProof: inclusionProof,
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}

func NewAddCovenantSigsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "add-covenant-sigs [covenant_pk] [staking_tx_hash] [slashing_tx_sig1],[slashing_tx_sig2],... [unbonding_tx_sig] [slashing_unbonding_tx_sig1],[slashing_unbonding_tx_sig2],...",
Expand Down

0 comments on commit fd84dab

Please sign in to comment.