-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2668 from nspcc-dev/cli-signing-improvements
CLI signing improvements
- Loading branch information
Showing
13 changed files
with
556 additions
and
79 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
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
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,42 @@ | ||
package util | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/nspcc-dev/neo-go/cli/options" | ||
"github.com/nspcc-dev/neo-go/cli/paramcontext" | ||
"github.com/urfave/cli" | ||
) | ||
|
||
func sendTx(ctx *cli.Context) error { | ||
args := ctx.Args() | ||
if len(args) == 0 { | ||
return cli.NewExitError("missing input file", 1) | ||
} else if len(args) > 1 { | ||
return cli.NewExitError("only one input file is accepted", 1) | ||
} | ||
|
||
pc, err := paramcontext.Read(args[0]) | ||
if err != nil { | ||
return cli.NewExitError(err, 1) | ||
} | ||
|
||
tx, err := pc.GetCompleteTransaction() | ||
if err != nil { | ||
return cli.NewExitError(fmt.Errorf("failed to complete transaction: %w", err), 1) | ||
} | ||
|
||
gctx, cancel := options.GetTimeoutContext(ctx) | ||
defer cancel() | ||
|
||
c, err := options.GetRPCClient(gctx, ctx) | ||
if err != nil { | ||
return cli.NewExitError(fmt.Errorf("failed to create RPC client: %w", err), 1) | ||
} | ||
res, err := c.SendRawTransaction(tx) | ||
if err != nil { | ||
return cli.NewExitError(fmt.Errorf("failed to submit transaction to RPC node: %w", err), 1) | ||
} | ||
fmt.Fprintln(ctx.App.Writer, res.StringLE()) | ||
return nil | ||
} |
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
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
Oops, something went wrong.