electrum icon indicating copy to clipboard operation
electrum copied to clipboard

argparse not consistent

Open AbdussamadA opened this issue 10 years ago • 26 comments

The deseed command line option doesn't work. The error message is "Remove the existing wallet first!". This happens in both 2.6.4 and 2.7.1

AbdussamadA avatar Oct 05 '16 07:10 AbdussamadA

indeed. is there still a use case for that command? I would rather like to remove it

ecdsa avatar Oct 05 '16 08:10 ecdsa

it makes it easy to create watching only wallets. but of course it's your choice to keep it around or not.

AbdussamadA avatar Oct 05 '16 08:10 AbdussamadA

well, if it was broken since the 2.6.4 release and nobody complained, I suppose it's not really used. if you need to create a watching only wallet from the command line, you can do like this:

MPK=$(electrum getmpk)
electrum -w watching_only restore $MPK

ecdsa avatar Oct 05 '16 08:10 ecdsa

I'm sure it can be done with grep and cut. But what you've written above won't work for a number of reasons. For one the output of getmpk is json. Second -w usually has to go after commands now.

AbdussamadA avatar Oct 05 '16 08:10 AbdussamadA

I guess I'll close this since you've decided to deprecate the deseed command.

AbdussamadA avatar Oct 05 '16 08:10 AbdussamadA

this commit should make it work with pipes: e0ba4a967c112bcd59382fc10ce6accd7a67fce3

electrum getmpk | electrum -w watching_only restore -

ecdsa avatar Oct 05 '16 08:10 ecdsa

are you on OSX ? on linux -w does not have to go after commands.

ecdsa avatar Oct 05 '16 08:10 ecdsa

and no, the output of getmpk is not json, unless you are using an old version

ecdsa avatar Oct 05 '16 08:10 ecdsa

indeed you are right. these were problems in 2.6.4. my bad.

AbdussamadA avatar Oct 05 '16 08:10 AbdussamadA

no I just checked even in 2.7.1 some commands don't like -w before the command. create and restore for example.

AbdussamadA avatar Oct 05 '16 08:10 AbdussamadA

are you on OSX or linux?

ecdsa avatar Oct 05 '16 08:10 ecdsa

linux. opensuse is running 2.6.4. debian vm running 2.7.1

AbdussamadA avatar Oct 05 '16 08:10 AbdussamadA

debian install is jessie (8)

AbdussamadA avatar Oct 05 '16 08:10 AbdussamadA

do the other commands accept -w before the command? what happens with create and restore, do they throw an error?

ecdsa avatar Oct 05 '16 08:10 ecdsa

deseed command removed here: df6dae90d6ecc54f990d0cbfe116708c96d57fd5

ecdsa avatar Oct 05 '16 08:10 ecdsa

This is the error that I get on create and restore:

electrum -w test7 create
Error: Remove the existing wallet first!

test7 doesn't exist. it thinks i mean the default wallet file. getseed and getmasterprivate also don't work with -w ahead of the command. they all give output based on the default wallet file rather than the one specified in -w. I bet there are others like these too. Is there some common command line parsing function where this bug might be?

AbdussamadA avatar Oct 05 '16 08:10 AbdussamadA

it uses a python module called argparse. do you have the version of argparse that comes originally with python?

ecdsa avatar Oct 05 '16 09:10 ecdsa

do you have the version of argparse that comes originally with python?

how would i go about finding this out?

AbdussamadA avatar Oct 05 '16 09:10 AbdussamadA

run python:

>>> import argparse
>>> argparse._version__

mine is 1.1

ecdsa avatar Oct 05 '16 09:10 ecdsa

1.1 here too. python version is 2.7.9

AbdussamadA avatar Oct 05 '16 09:10 AbdussamadA