Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--batch: command not found #55

Open
marissia opened this issue May 15, 2021 · 32 comments
Open

--batch: command not found #55

marissia opened this issue May 15, 2021 · 32 comments

Comments

@marissia
Copy link

Dear dearest author, I need your help and I cant resolve it alone, I was try cygwin and followed all instruction, used command
bitcoin-tool --batch --input-file 1mix.txt --input-format hex --input-type private-key --network bitcoin --public-key-compression auto --output-type address --output-format base58check --output-file r.txt
also
./bitcoin-tool --batch --input-file 1mix.txt --input-format hex --input-type private-key --network bitcoin --public-key-compression auto --output-type address --output-format base58check --output-file r.txt
-bash: ./bitcoin-tool: No such file or directory, but directory exits. I removed ./bitcoin-tool or bitcoin-tool and used command
--batch --input-file 1mix.txt --input-format hex --input-type private-key --network bitcoin --public-key-compression auto --output-type address --output-format base58check --output-file r.txt
I see --batch: command not found
I removed --batch and I see --input-file: command not found
and no results. What I do wrong?? I removed cygwin and installed ubuntu on win10 and same result. Command keys=99999 ; openssl rand $[32*keys] | xxd -p -c32 > hexkeys working good without any one mistake. which command I have to add on terminal to convert these hex keys to addresses??
Cygwin path to folder cd /cygdrive/c/bitcoin-tool/
Ubuntu path C:\Users\Diana\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState\rootfs\home\didi\bitcoin-tool if I am right? it is a right path? how I can add new file to folder to convert ,maybe wrong path?
I am girl but not stupid but here I feel I miss some small word in command, please help , I stay 1 week like this.

@matja
Copy link
Owner

matja commented May 15, 2021

I don't have a Windows machine to check, but this may help:

Ubuntu

enter:

sudo apt install git make gcc libssl-dev

git clone https://github.com/matja/bitcoin-tool

cd bitcoin-tool

make

If it compiles successfully, then you can run ./bitcoin-tool

Cygwin

Download and install Cygwin from https://cygwin.com/install.html

On the "Select Packages" step, select "view" as "full"
in the "Search" box, for each of these:

  • make
  • mingw64-x86_64-gcc-core
  • libssl-devel
  • git
  • in the "New" column, change from "Skip" to the latest version available.

Click "Next" to install packages.

Run the "Cygwin Terminal" shortcut on the desktop.

enter:

git clone https://github.com/matja/bitcoin-tool

cd bitcoin-tool

make

If it compiles successfully, then you can run ./bitcoin-tool

@marissia
Copy link
Author

I did everything by steps on cygwin . Attached picture please look.
16211640017436782738321271935774

@marissia
Copy link
Author

Uploading 16211640919513443118112234360345.jpg…
And make error. What wrong I do??

@matja
Copy link
Owner

matja commented May 16, 2021

Can you try running as ./bitcoin-tool or ./bitcoin-tool.exe? You definitely need the ./ if it is not in the $PATH , but I'm not sure if mingw-gcc automatically adds an .exe suffix or not.

@marissia
Copy link
Author

exe also no success, look please for it when I add make how many errors
Diana@HOME-PC ~/bitcoin-tool
$ make
x86_64-w64-mingw32-gcc -D OS_WINDOWS_NT -ansi -Wall -O2 -Wno-long-long -I /usr/include -c -o main.o main.c
In file included from /usr/include/sys/_pthreadtypes.h:12,
from /usr/include/sys/types.h:223,
from /usr/include/stdio.h:61,
from main.c:5:
/usr/include/sys/cpuset.h:17:30: error: expected expression before ‘/’ token
17 | #define __CPU_SETSIZE 1024 // maximum number of logical processors tracked
| ^
/usr/include/sys/cpuset.h:19:25: note: in expansion of macro ‘__CPU_SETSIZE’
19 | #define __CPU_GROUPMAX (__CPU_SETSIZE / __NCPUBITS) // maximum group number
| ^~~~~~~~~~~~~
/usr/include/sys/cpuset.h:26:21: note: in expansion of macro ‘__CPU_GROUPMAX’
26 | __cpu_mask __bits[__CPU_GROUPMAX];
| ^~~~~~~~~~~~~~
/usr/include/sys/cpuset.h:19:55: error: expected expression before ‘/’ token
19 | #define __CPU_GROUPMAX (__CPU_SETSIZE / __NCPUBITS) // maximum group number
| ^
/usr/include/sys/cpuset.h:26:21: note: in expansion of macro ‘__CPU_GROUPMAX’
26 | __cpu_mask __bits[__CPU_GROUPMAX];
| ^~~~~~~~~~~~~~
/usr/include/sys/cpuset.h:27:1: warning: no semicolon at end of struct or union
27 | } cpu_set_t;
| ^
In file included from /usr/include/errno.h:9,
from main.c:8:
/usr/include/sys/errno.h:14: warning: "errno" redefined
14 | #define errno (__errno())
|
In file included from /usr/lib/gcc/x86_64-w64-mingw32/10/include/stddef.h:1,
from /usr/include/sys/cdefs.h:47,
from /usr/include/stdio.h:35,
from main.c:5:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/stddef.h:19: note: this is the location of the previous definition
19 | #define errno (
_errno())
|
make: *** [: main.o] Error 1

Diana@HOME-PC ~/bitcoin-tool
$ ./bitcoin-tool.exe --input-file 1mix.txt --input-format hex --input-type private-key --network bitcoin --public-key-compression auto --output-type address --output-format base58check --output-file r.txt
-bash: ./bitcoin-tool.exe: No such file or directory

Diana@HOME-PC ~/bitcoin-tool
$ ./bitcoin-tool --input-file 1mix.txt --input-format hex --input-type private-key --network bitcoin -- batch --public-key-compression auto --output-type address --output-format base58check --output-file r.txt
-bash: ./bitcoin-tool: No such file or directory

Diana@HOME-PC ~/bitcoin-tool
$ keys=999999 ; openssl rand $[32*keys] | xxd -p -c32 > hexkeys3

Diana@HOME-PC ~/bitcoin-tool
$
but I can generate keys easy, cant convert only . Maybe problem with make command?

@marissia
Copy link
Author

ubuntu now : Looking like works but
didi@HOME-PC:~/bitcoin-tool$ ./bitcoin-tool --input-type private-key --input-format hex --input-file hexkeys3.txt --output-type address --batch --output-format base58check > OUTPUTFILE.TXT
Failed to open file [hexkeys3.txt] (Permission denied) . what I have to do, why no permission?

@matja
Copy link
Owner

matja commented May 16, 2021

The user ID you're using in Ubuntu may be different than that which you're using in Windows - perhaps sudo chmod 644 hexkeys3.txt would work?

@marissia
Copy link
Author

do maybe wrong folder I use? How I can know exactly path to folder with script?
sudo chmod 644 hexkeys3.txt asked password, added and back to didi@HOME-PC:~/bitcoin-tool$

@marissia
Copy link
Author

I generated new keys by command keys=99999 ; openssl rand $[32*keys] | xxd -p -c32 > hexkeys4
and in same time converted to addresses it works!!
after convert to addresses
./bitcoin-tool
--batch
--input-file hexkeys4
--input-format hex
--input-type private-key
--network bitcoin
--public-key-compression compressed
--output-type address
--output-format base58check irs works!
but now if Iwant add my own keys to folder, where is that folder located ?how I can find it ?

@matja
Copy link
Owner

matja commented May 16, 2021

With that command - remember not to use any of those addresses, because the random keys it uses are not saved anywhere.

It sounds like you're using WSL so the path you had in the first comment (C:\Users\Diana\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState\rootfs\home) I think would be where you can copy files from Windows to the Ubuntu file-system and vice-versa.

Also - please also run make test to run all the test, it should say all tests passed at the end if all is good.

@marissia
Copy link
Author

I finished successfully with keys generated by bitcoin tools and I see this folder with ready addresses, added new file with my own keys:
./bitcoin-tool --input-type private-key --input-format hex --input-file 1mix.txt --public-key-compression compressed --output-type address --batch --network bitcoin --output-format base58check > r2.txt
Failed to open file [1mix.txt] (Permission denied) Again , maybe I have to change permissions to this folder but how I dont know.
Everything works now exept my own file, what solution ?

@marissia
Copy link
Author

can I generate keys start from and end, not random? for example begin from 0000000000000000000000000000000000000000000000000000000100000000 and end 00000000000000000000000000000000000000000000000000000001ffffffff by this command keys=99999 ; openssl rand $[32*keys] | xxd -p -c32 > hexkeys.txt what to change? can I do it ??

@matja
Copy link
Owner

matja commented May 16, 2021

what does ls -l show as the owner and mode of the file? perhaps you can chmod 644 the file to make it readable, or chown it to your user?

You can generate input like that with :

for ((i=0x100000000;i<0x1ffffffff;i++));do printf "%064x\n" $i;done

and use with bitcoin-tool like:

./bitcoin-tool \
--batch \
--input-type private-key \
--input-format hex \
--input-file <(for ((i=0x100000000;i<0x1ffffffff;i++));do printf "%064x\n" $i;done) \
--output-type address \
--network bitcoin \
--public-key-compression compressed \
--output-format base58check

@matja
Copy link
Owner

matja commented May 16, 2021

Note: please do not actually send any bitcoin to addresses generated like that, it is extremely insecure.

@marissia
Copy link
Author

this what I see
didi@HOME-PC:$ cd bitcoin-tool
didi@HOME-PC:
/bitcoin-tool$ ls -l
total 226865
-rw-r--r-- 1 didi didi 0 May 16 21:00 --network
-rw-r--r-- 1 didi didi 0 May 16 21:02 1mix.txt
-rw-r--r-- 1 didi didi 1326 May 15 21:22 Makefile
-rw-r--r-- 1 didi didi 11336 May 15 21:22 README.md
-rw-r--r-- 1 didi didi 1420 May 15 21:22 applog.c
-rw-r--r-- 1 didi didi 294 May 15 21:22 applog.h
-rw-r--r-- 1 didi didi 2112 May 15 22:01 applog.o
-rw-r--r-- 1 didi didi 9841 May 15 21:22 base58.c
-rw-r--r-- 1 didi didi 7753 May 15 21:22 base58.h
-rw-r--r-- 1 didi didi 11152 May 15 22:01 base58.o
-rwxr-xr-x 1 didi didi 61048 May 16 14:14 bitcoin-tool
-rw-r--r-- 1 didi didi 510 May 15 21:22 combination.c
-rw-r--r-- 1 didi didi 388 May 15 21:22 combination.h
-rw-r--r-- 1 didi didi 1976 May 15 22:01 combination.o
-rw-r--r-- 1 didi didi 766 May 15 21:22 hash.c
-rw-r--r-- 1 didi didi 1691 May 15 21:22 hash.h
-rw-r--r-- 1 didi didi 2808 May 15 22:01 hash.o
---------- 1 didi didi 231946989 May 16 15:53 hexkeys3.txt
-rw-r--r-- 1 didi didi 32 May 15 22:15 key.bin
-rw-r--r-- 1 didi didi 9027 May 15 21:22 keys.c
-rw-r--r-- 1 didi didi 6017 May 15 21:22 keys.h
-rw-r--r-- 1 didi didi 9136 May 15 22:01 keys.o
-rw-r--r-- 1 didi didi 49098 May 15 21:22 main.c
-rw-r--r-- 1 didi didi 39496 May 15 22:01 main.o
-rw-r--r-- 1 didi didi 10890 May 15 21:22 prefix.c
-rw-r--r-- 1 didi didi 853 May 15 21:22 prefix.h
-rw-r--r-- 1 didi didi 5256 May 15 22:01 prefix.o
-rw-r--r-- 1 didi didi 0 May 16 20:59 r2.txt
-rw-r--r-- 1 didi didi 804 May 15 21:22 result.c
-rw-r--r-- 1 didi didi 942 May 15 21:22 result.h
-rw-r--r-- 1 didi didi 2936 May 15 22:01 result.o
-rw-r--r-- 1 didi didi 6583 May 15 21:22 segwit_addr.c
-rw-r--r-- 1 didi didi 3754 May 15 21:22 segwit_addr.h
-rw-r--r-- 1 didi didi 4672 May 15 22:01 segwit_addr.o
-rw-r--r-- 1 didi didi 8553 May 15 21:22 sha256.c
-rw-r--r-- 1 didi didi 509 May 15 21:22 sha256.h
-rwxr-xr-x 1 didi didi 15125 May 15 21:22 tests.sh
-rw-r--r-- 1 didi didi 3208 May 15 21:22 utility.c
-rw-r--r-- 1 didi didi 3110 May 15 21:22 utility.h
-rw-r--r-- 1 didi didi 3592 May 15 22:01 utility.o
didi@HOME-PC:~/bitcoin-tool$

@matja
Copy link
Owner

matja commented May 16, 2021

Not really sure if WSL is different - but chmod u+rw hexkeys3.txt should fix it, or if that fails sudo chmod u+rw hexkeys3.txt.

@marissia
Copy link
Author

Its works after command sudo chmod u+rw hexkeys3.txt !!!
thank you tooo much for your help dear bro!!
Can I convert addresses in one time compressed and uncompressed or have to do it by 2 times?
I saw here soe command like --public-key-compression auto but it doesnt work , asking only one type

@marissia
Copy link
Author

marissia commented May 16, 2021

I try your command
./bitcoin-tool
--batch
--input-type private-key
--input-format hex
--input-file <(for ((i=0x100000000;i<0x1ffffffff;i++));do printf "%064x\n" $i;done)
--output-type address
--network bitcoin
--public-key-compression compressed
--output-format base58check
it works very good
but if I want change range for example adding some extra zero 0x10000000000 nothing happen. what i have to change and where?

@matja
Copy link
Owner

matja commented May 16, 2021

bitcoin-tool can't convert to two different compression types in one step, but you could use some shell features to do it:

# define convenient alias
alias bt='./bitcoin-tool \
--batch \
--input-type private-key \
--input-format hex \
--input-file - \
--output-type address \
--network bitcoin \
--output-format base58check'

# create named pipes for input keys and output addresses
mkfifo /tmp/hexkey /tmp/compressed /tmp/uncompressed

# create input keys, convert to addresses and write to seperate named pipes
( for ((i=0x100000000;i<0x100000005;i++));do printf "%064x\n" $i;done ) \
| tee \
  >(cat >/tmp/hexkey) \
  >(bt --public-key-compression   compressed >/tmp/compressed  ) \
  >(bt --public-key-compression uncompressed >/tmp/uncompressed) \
  >/dev/null

# merge lines of each file in order
paste /tmp/hexkey /tmp/compressed /tmp/uncompressed

# cleanup
rm /tmp/hexkey /tmp/compressed /tmp/uncompressed

output:

0000000000000000000000000000000000000000000000000000000100000000 1FJPqZKbJMP4Q44Jm5gJrnovnQBzuULQwG 1MZjW9QGUn254PG3xYkdXEDz8wM4EcuQpb
0000000000000000000000000000000000000000000000000000000100000001 1MhPuAjruNyVSeHGYiU2xELRNzfyEaSAjG 1Mm2g1a8Dsvf6csxeiEyovhSmLmkjgPz4Y
0000000000000000000000000000000000000000000000000000000100000002 1PEnQaXrSGoM7iVEhBWwychLJ9cNW8scD9 1GNSk4WxcWxmSPonMebfFRaiV2DFAGjvzi
0000000000000000000000000000000000000000000000000000000100000003 17QPwtZMKb3rJ3MAcH8taez49tQPEAYDzw 17YKAkeuFR9nnVBQUtF5yk59wbWbURv9nZ
0000000000000000000000000000000000000000000000000000000100000004 1PQFgW14hWaX4DNAvnc2wddAKYf2G8bZZu 1AMj9mwS6FcrPtsWNBtDnvm4AmsJrcGea9

@marissia
Copy link
Author

I added few zeros to input
--input-file <(for ((i=0x100000000000000000;i<0x1fffffffffffffffff;i++));do printf "%064x\n" $i;done) \
it doest work, why?
I need generate all this keys , not addresses, from 0000000000000000000000000000000000000000000000100000000000000000 to
00000000000000000000000000000000000000000000001fffffffffffffffff it is possible?
this command work --input-file <(for ((i=0x100000000;i<0x1ffffffff;i++));do printf "%064x\n" $i;done)
but output I need hex keys , help please!

@matja
Copy link
Owner

matja commented May 16, 2021

Bash integer variables are only 64-bit, that's a 68-bit range, too large for bash numbers to express.
It would take a long time anyway - my CPU can do about 2000 addresses per second so it'd take (2^68)/2000/86400/365 = 4679539338 years

@marissia
Copy link
Author

OMG )) Thanks by anyway for everything,

@marissia
Copy link
Author

marissia commented Jan 8, 2022

Dear matja i want generate random keys and as I understand I cant generate more than 67 000 000, maybe you have one new command to generate as I want? I use this command keys=67000000 ; openssl rand $[32*keys] | xxd -p -c32 > key1.txt success, but more cant rand: Value "3168000000" outside integer range, no any solution?? help pls...

@matja
Copy link
Owner

matja commented Jan 8, 2022

It's a limitation in openssl, try dd if=/dev/urandom bs=32 count=67000000 | xxd -p -c32

@marissia
Copy link
Author

marissia commented Jan 9, 2022

thank u, it work, success!!

@marissia
Copy link
Author

Dear matja ! Can I convert compressed wif private key to uncompressed wif? and any wif to hex format?? Which command is right?

@matja
Copy link
Owner

matja commented Jan 18, 2022

Yes, you'd need two commands, you can store the output or run them as a shell command substitution.

Create example compressed WIF private key from a hex key (000...001):

./bitcoin-tool \
--input $(printf "%064x" 1) \
--input-type private-key \
--input-format hex \
--output-type private-key-wif \
--output-format base58check \
--network bitcoin \
--public-key-compression compressed

KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn

Put the key in a shell variable $WIF for convenience.

Convert WIF key to a hex key, then convert hex key to uncompressed WIF key:

WIF="KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn"

./bitcoin-tool \
--input $( ./bitcoin-tool \
  --input "$WIF" \
  --input-type private-key-wif \
  --input-format base58check \
  --output-type private-key \
  --output-format hex ) \
--input-type private-key \
--input-format hex \
--output-type private-key-wif \
--output-format base58check \
--network bitcoin \
--public-key-compression uncompressed

5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf

Check the output is correct by converting the uncompressed WIF key back to hex:

./bitcoin-tool \
--input 5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf \
--input-type private-key-wif \
--input-format base58check \
--output-type private-key \
--output-format hex

0000000000000000000000000000000000000000000000000000000000000001

@marissia
Copy link
Author

how I can mass convert? ok from wif to hex only, and after easy. I try now too many variations, doesnt work. example ./bitcoin-tool --input $( ./bitcoin-tool --input-file 1.txt --input-type private-key-wif --input-format base58check --batch --output-type private-key --output-format hex) > wifsss.txt --input-type private-key --input-format hex --output-type private-key-wif --output-format base58check --batch --input-file wifsss.txt --network bitcoin --public-key-compression uncompressed > keyss.txt . what I did here i smile. please hepl me only one command, I have file with wifs, i want convert it to hex all in one time

@marissia
Copy link
Author

./bitcoin-tool --input $( ./bitcoin-tool --input-file 1.txt --input-type private-key-wif --input-format base58check --output-type private-key --output-format hex ) --input-type private-key --input-format hex --output-type private-key-wif --output-format base58check --network bitcoin --public-key-compression uncompressed --batch > wwf.txt I try by one key it work good but cant convert mass by this command

@marissia
Copy link
Author

didi@HOME-PC:/bitcoin-tool$ ./bitcoin-tool --input $( ./bitcoin-tool --input-file WIFs.txt --input-type private-key-wif --input-format base58check --output-type private-key --output-format hex ) --input-type private-key --input-format hex --output-type private-key-wif --output-format base58check --network bitcoin --public-key-compression uncompressed --batch > ww1.txt
Invalid character (ASCII 10)
Failed to decode Base58Check input (invalid format).
You can use the --fix-base58check option to change the input string until the checksum is valid, but this may return a false positive match.
unknown option "private-key"
didi@HOME-PC:
/bitcoin-tool$ ./bitcoin-tool \

--input $( ./bitcoin-tool
--input "KzifrxqQ7svgDHZffZLuhnDxuC9piZFcdVz9jmyvjxTa58iPDuiA"
--input-type private-key-wif
--input-format base58check
--output-type private-key
--output-format hex )
--input-type private-key
--input-format hex
--output-type private-key-wif
--output-format base58check
--network bitcoin
--public-key-compression uncompressed
5JcGbtAc9MbpQB6b8q7Kjmge8kJrnDHuUkiwziumoSFdVfyVDiq

@marissia
Copy link
Author

dear, Matja! I want generate some keys by command for ((i=0x01;i<0xffffff;i++));do printf "%064x\n" $i;done > keys.txt , everything good but how I can generate without zeros? if I have keys like this 00000000000000000000000000000000000000000000000000000000000fffff and I want be like fffff only? please give me command for it if possible and amount of keys for example i want only 1000000 from this range? . thank you

@matja
Copy link
Owner

matja commented May 17, 2022

You can just use %x as the printf format specifier:

$ printf "%x\n" $[0xfffff]
fffff

Or use another program like sed with a regex to remove the leading 0's, which might be useful if you want to change it in other ways:

$ printf "%064x\n" $[0xfffff] | sed 's/^0\+//'
fffff

But that example has an odd number of hex digits, which is not padded to whole number of bytes, which might confuse some tools:

$ echo fffff | xxd -r -p | hexdump -C
00000000  ff ff    |..|
00000002

= two bytes of ff, the leading f disappeared - oops.

...so you can just remove all the leading 00's which represent whole bytes:

$ printf "%064x\n" $[0xfffff] | sed 's/^\(00\)\+//'
0fffff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants