0

I have been experimenting with cardano-cli in the past week. My goal is to find a way to automate sending transactions from multiple wallets in my Daedalus Mainnet.app.

After doing some research, I found: Bash script to send the transaction through cardano-cli. So I followed the instructions on GitHub, and everything was successful.

From here on out, sending transactions from multiple wallets is easy, as I only need to run the function daedalus-cli-send-tx numerous times with different arguments each time. Here's what I've got so far:

$ cat test.sh

#!/bin/bash
echo Please enter sender address:
read sender
echo $sender

daedalus-cli-send-tx wallet1 1000000 $sender #sending from wallet1 with 1ADA to sender
daedalus-cli-send-tx wallet2 1000000 $sender #sending from wallet2 with 1ADA to sender

And I also made a text file to redirect my input from test.sh to this input file:

$ cat input
addr1q8sypyrh63y6pgjq0ys0j7rkj2qjun6wnq4haj9d945d9cqu7krtq8wjazqvqxmtmmmyx20kuftmg0578npzdpy3vkasyjn3p3 #sender address
8736867242 #wallet1 passphrase
1932862497 #wallet2 passphrase

But when I redirect my input, here's what I get:

$ source ~/test.sh < input

Please enter sender address:
addr1q8sypyrh63y6pgjq0ys0j7rkj2qjun6wnq4haj9d945d9cqu7krtq8wjazqvqxmtmmmyx20kuftmg0578npzdpy3vkasyjn3p3
Please enter your passphrase: **********
The given encryption passphrase doesn't match the one I use to encrypt the root private key of the given wallet: 890483bc9ec5c5bfc7d612d9cad885df199c3533
Please enter your passphrase: cardano-wallet: <stdin>: hGetChar: end of file

Note that I purposely used a wrong passphrase for both transactions, but the first one actually read the input from the text file, so that isn't the problem. The problem lies in that the second transaction asked for a passphrase, yet it returned this line:

Please enter your passphrase: cardano-wallet: <stdin>: hGetChar: end of file

Even though the input textfile supplies both passphrases.

I have very little knowledge of shell script, so I am asking for help here. What is this error cardano-wallet: <stdin>: hGetChar: end of file (AFAIK it is because the input was not captured), and how do I actually automate entering my passphrase when prompt?

2 Answers 2

0

In shell scripting, for something like this you want to use expect and send. Here's an example of how we use it for cardano-faucet: https://github.com/input-output-hk/cardano-faucet/blob/master/nix/nixos/create-faucet-wallet/create-faucet-wallet.sh#L69-L70

0

Hi this is a fairly common problem in bash. It has nothing to do with Cardano-cli and can be thought of as the general problem of automating password-based authentication for applications via bash scripts.

I did something similar to this using https://stackoverflow.com/questions/67570700/how-do-i-automate-a-remote-login-with-a-bash-script

if you have any problems feel free to reach out I will happily take a look at your code and fix the bug.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.