* fix: Signature only flag bug on tx sign command 7632 * Update client/context.go Co-authored-by: Cory <cjlevinson@gmail.com> * Update client/context.go Co-authored-by: Cory <cjlevinson@gmail.com> * use named return value and closure (#8111) This is to correctly handle deferred Close() calls on writable files. * set the right 'append' logic for signing transactions * cleanup * update tx.Sign interface by adding overwrite option * Update Changelog * sign command cleanup * implementation and changelog update * fix SignTx and tx.Sign calls * fix: sign didn't write to a file * update flags description * Add tx.Sign tests * fix grpc/server_test.go * Update client/tx/tx.go Co-authored-by: Cory <cjlevinson@gmail.com> * changelog update * Add test to verify matching signatures * cli_test: add integration tests for sign CMD * add output-file flag test * add flagAmino test * Update x/auth/client/cli/tx_sign.go Co-authored-by: Alessio Treglia <alessio@tendermint.com> * Update x/auth/client/cli/tx_sign.go * update amino serialization test * TestSign: adding unit test for signing with different modes * Add test with Multi Signers into Robert's TxSign PR (#8142) * Add test with Multi Signers * remove true false * Use SIGN_MODE_DIRECT * Fix litn * Use correct pubkeys * Correct accNum and seq * Use amino * cleanups * client.Sign: raise error when signing tx with multiple signers in Direct + added more unit tests * add more tests * Update client/tx/tx_test.go Co-authored-by: Cory <cjlevinson@gmail.com> * fix TestGetBroadcastCommand_WithoutOfflineFlag * Any.UnsafeSetCachedValue * fix note packed messages in tx builder * reorder unit tests * Changelog update * cleaning / linting * cli_tes: copy validator object instead of modifying it's shared codec * x/auth cli_test: remove custom codec creation in tests * Update CHANGELOG.md * updates to CHANGELOG.md * remove unused method * add new instance of transaction builder for TestSign Co-authored-by: Cory <cjlevinson@gmail.com> Co-authored-by: SaReN <sahithnarahari@gmail.com> Co-authored-by: Alessio Treglia <alessio@tendermint.com> Co-authored-by: Amaury <amaury.martiny@protonmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
package cli
|
|
|
|
import (
|
|
"encoding/base64"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"
|
|
)
|
|
|
|
// GetEncodeCommand returns the encode command to take a JSONified transaction and turn it into
|
|
// Amino-serialized bytes
|
|
func GetEncodeCommand() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "encode [file]",
|
|
Short: "Encode transactions generated offline",
|
|
Long: `Encode transactions created with the --generate-only flag and signed with the sign command.
|
|
Read a transaction from <file>, serialize it to the Amino wire protocol, and output it as base64.
|
|
If you supply a dash (-) argument in place of an input filename, the command reads from standard input.`,
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
clientCtx := client.GetClientContextFromCmd(cmd)
|
|
|
|
tx, err := authclient.ReadTxFromFile(clientCtx, args[0])
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// re-encode it
|
|
txBytes, err := clientCtx.TxConfig.TxEncoder()(tx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// base64 encode the encoded tx bytes
|
|
txBytesBase64 := base64.StdEncoding.EncodeToString(txBytes)
|
|
|
|
return clientCtx.PrintString(txBytesBase64 + "\n")
|
|
},
|
|
}
|
|
|
|
flags.AddTxFlagsToCmd(cmd)
|
|
|
|
return cmd
|
|
}
|