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

Cannot import testnet private key #20

Closed
arhuaco opened this issue Aug 6, 2014 · 1 comment
Closed

Cannot import testnet private key #20

arhuaco opened this issue Aug 6, 2014 · 1 comment

Comments

@arhuaco
Copy link
Contributor

arhuaco commented Aug 6, 2014

Testing with git/HEAD (without the patch I sent).

./bitcoin-cli dumpprivkey mxEP2midj7DRBW4yCxBBSs2MWcMsQfqQVw
cNkMqSEm5FsNGTPcKUaUjoVA8adAm9tezdAjsAeGfxtxjhps76M8

This is a testnet address, starts with 'c'. The first time, when the dumbwallet.key does not exists dumbwallet does a core dump.

./dumbwallet setup P-cNkMqSEm5FsNGTPcKUaUjoVA8adAm9tezdAjsAeGfxtxjhps76M8
Aborted (core dumped)

Strace:

chdir("/home/len/.pettycoin") = 0
open("dumbwallet.key", O_RDONLY) = -1 ENOENT (No such file or directory)
open("dumbwallet.key", O_WRONLY|O_CREAT|O_EXCL, 0400) = 3
write(3, "|m\32", 3) = 3
fsync(3) = 0
close(3) = 0
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
tgkill(11848, 11848, SIGABRT) = 0
--- SIGABRT (Aborted) @ 0 (0) ---
+++ killed by SIGABRT (core dumped) +++
Aborted (core dumped)

Next time it will run:

./dumbwallet setup P-cNkMqSEm5FsNGTPcKUaUjoVA8adAm9tezdAjsAeGfxtxjhps76M8
dumbwallet: Could not decode private key

Can you import this key? It's late here so I did not check where the validation fails.

I can check later today. Thanks.

@arhuaco arhuaco changed the title Cannot import testnet address Cannot import testnet private key Aug 6, 2014
@arhuaco
Copy link
Contributor Author

arhuaco commented Aug 6, 2014

For the first core dump, I found where it is dying, tal_vfmt is crashing. It all starts in pettycoin_to_base58:

            char *p_fmt;
            printf("Before tal_fmt %s, len:%d\n", p, strlen(p));
            p_fmt = tal_fmt(ctx, "P-%s", p);
            printf("After tal_fmt %s, len:%d\n", p_fmt, strlen(p_fmt));
            return p_fmt;

It prints:
Before tal_fmt mfWxJ45yp2SGCvdtV7pMpn6Xb9vCw4xU85, len:34

And then core dumps. The backtrace:

(gdb) bt
#0 0xb7fdd416 in __kernel_vsyscall ()
#1 0xb7ca120f in __GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#2 0xb7ca4855 in GI_abort () at abort.c:91
#3 0x0804f1c6 in call_error (msg=0x805de4f "Not a valid header") at ccan//ccan/tal/tal.c:84
#4 0x0804f325 in check_bounds (p=0xb7e19fe4) at ccan//ccan/tal/tal.c:156
#5 0x0804f341 in to_tal_hdr (ctx=0xb7e19ff4) at ccan//ccan/tal/tal.c:164
#6 0x0804f3c2 in to_tal_hdr_or_null (ctx=0xb7e19ff4) at ccan//ccan/tal/tal.c:177
#7 0x0804f8af in tal_alloc
(ctx=0xb7e19ff4, size=20, clear=false, label=0x805e193 "char[]") at ccan//ccan/tal/tal.c:388
#8 0x0804fa96 in tal_alloc_arr
(ctx=0xb7e19ff4, size=20, count=8, clear=false, add_count=true, label=0x805e193 "char[]")
at ccan//ccan/tal/tal.c:447
#9 0x08051dbe in tal_vfmt (ctx=0xb7e19ff4, fmt=0x805da11 "P-%s", ap=0xbfffef28 "^\357\377\277\031")
at ccan//ccan/tal/str/str.c:93
#10 0x08051c7c in tal_fmt (ctx=0xb7e19ff4, fmt=0x805da11 "P-%s") at ccan//ccan/tal/str/str.c:48
#11 0x0804cf0b in pettycoin_to_base58 (ctx=0xb7e19ff4, test_net=true, addr=0xbffff008, bitcoin_style=true) at base58.c:146
#12 0x08049ec8 in create_wallet (privkey=0xbffff2da "P-cNkMqSEm5FsNGTPcKUaUjoVA8adAm9tezdAjsAeGfxtxjhps76M8")
at dumbwallet.c:92
#13 0x0804b236 in main (argc=3, argv=0xbffff164) at dumbwallet.c:478

rustyrussell added a commit that referenced this issue Aug 7, 2014
Untested code is buggy code!

Fixes: #20
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
rustyrussell added a commit that referenced this issue Aug 7, 2014
Untested code is buggy code!

Fixes: #20
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
@arhuaco arhuaco closed this as completed Aug 7, 2014
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

1 participant