From 954b2c4a67d8ce1ffaca19d10a8dbf8df5b0cc0f Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Tue, 13 Jun 2017 17:08:41 +0200 Subject: [PATCH] fix: Corrently parse non-testnet p2pkh addresses The return value of `b58check` is negative on failure, and positive values are the address version, i.e., 0 in the case of mainnet addresses. --- bitcoin/base58.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitcoin/base58.c b/bitcoin/base58.c index 159ed55da..d605117fd 100644 --- a/bitcoin/base58.c +++ b/bitcoin/base58.c @@ -61,7 +61,7 @@ static bool from_base58(u8 *version, int r = b58check(buf, sizeof(buf), base58, base58_len); *version = buf[0]; memcpy(rmd, buf + 1, sizeof(*rmd)); - return r > 0; + return r >= 0; } bool bitcoin_from_base58(bool *test_net,