Skip to content

Commit fdd58cf

Browse files
committed
Fixed reading password from STDIN for keyring-backend
1 parent 2e6abac commit fdd58cf

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pkg/keyring/keyring.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package keyring
22

33
import (
44
"fmt"
5+
"io"
6+
"os"
57

68
"github.com/cosmos/cosmos-sdk/codec"
79
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
@@ -70,12 +72,18 @@ func InitKeyring(backend, dir string) (keyring.Keyring, error) {
7072
cryptocodec.RegisterInterfaces(interfaceRegistry)
7173
cdc := codec.NewProtoCodec(interfaceRegistry)
7274

75+
// Create keyring with proper stdin handling
76+
var stdin io.Reader = os.Stdin
77+
if backendType == "test" {
78+
stdin = nil // Only use nil for test backend
79+
}
80+
7381
// Create keyring
7482
kr, err := keyring.New(
7583
KeyringServiceName,
7684
backendType,
7785
dir,
78-
nil, //Using nil for stdin to avoid interactive prompts when using test backend
86+
stdin,
7987
cdc,
8088
)
8189
if err != nil {

0 commit comments

Comments
 (0)