Skip to content

Commit

Permalink
Merge pull request #3149 from oasisprotocol/tjanez/small-ledger-fixes
Browse files Browse the repository at this point in the history
go/oasis-node/cmd/common: Smaller signer-related improvements
  • Loading branch information
tjanez authored Jul 31, 2020
2 parents 3be2b46 + d3ac3f0 commit bb17ffd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changelog/3149.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
go/oasis-node/cmd/common/consensus: Print helper text about transaction review

If one uses the signer plugin and a TTY, print a helper text to notify him
that he may need to review the transaction on the device if a hardware-based
signer plugin is used.
14 changes: 11 additions & 3 deletions go/oasis-node/cmd/common/consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"github.com/oasisprotocol/oasis-core/go/common/cbor"
signerFile "github.com/oasisprotocol/oasis-core/go/common/crypto/signature/signers/file"
signerPlugin "github.com/oasisprotocol/oasis-core/go/common/crypto/signature/signers/plugin"
"github.com/oasisprotocol/oasis-core/go/common/logging"
"github.com/oasisprotocol/oasis-core/go/consensus/api/transaction"
genesisAPI "github.com/oasisprotocol/oasis-core/go/genesis/api"
Expand Down Expand Up @@ -123,9 +124,16 @@ func SignAndSaveTx(ctx context.Context, tx *transaction.Transaction) {
fmt.Printf("You are about to sign the following transaction:\n")
tx.PrettyPrint(ctx, " ", os.Stdout)

if !cmdFlags.AssumeYes() && cmdSigner.Backend() == signerFile.SignerName {
if !cmdCommon.GetUserConfirmation("\nAre you sure you want to continue? (y)es/(n)o: ") {
os.Exit(1)
switch cmdSigner.Backend() {
case signerFile.SignerName:
if !cmdFlags.AssumeYes() {
if !cmdCommon.GetUserConfirmation("\nAre you sure you want to continue? (y)es/(n)o: ") {
os.Exit(1)
}
}
case signerPlugin.SignerName:
if cmdCommon.Isatty(os.Stdin.Fd()) {
fmt.Println("\nYou may need to review the transaction on your device if you use a hardware-based signer plugin...")
}
}

Expand Down
2 changes: 1 addition & 1 deletion go/oasis-node/cmd/common/signer/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func doNewComposite(signerDir string, roles ...signature.SignerRole) (signature.
}

func init() {
Flags.StringP(CfgSigner, "s", "file", "signer backend [file, plugin, ledger, remote, composite]")
Flags.StringP(CfgSigner, "s", "file", "signer backend [file, plugin, remote, composite]")
Flags.String(cfgSignerRemoteAddress, "", "remote signer server address")
Flags.String(cfgSignerRemoteClientCert, "", "remote signer client certificate path")
Flags.String(cfgSignerRemoteClientKey, "", "remote signer client certificate key path")
Expand Down

0 comments on commit bb17ffd

Please sign in to comment.