btcsuite / btcd

An alternative full node bitcoin implementation written in Go (golang)
https://github.com/btcsuite/btcd/blob/master/README.md
ISC License
6.1k stars 2.31k forks source link

btcd in simnet mode showing bad cerficiate. #2032

Closed zydjohnHotmail closed 9 months ago

zydjohnHotmail commented 9 months ago

Hi: I want to test lighting network on Docker image. But I have some issues to set it up. root@60945d60a592:~/.btcd# /root/go/bin/gencerts --host=localhost --directory=/root/.btcd --force root@60945d60a592:~/.btcd# cat btcd.conf [Application Options] rpcuser=yourusername rpcpass=yourpassword simnet=1 root@60945d60a592:~/.btcd# ls -l /root/.btcd/rpc* -rw-r--r-- 1 root root 887 Sep 18 20:08 /root/.btcd/rpc.cert -rw------- 1 root root 365 Sep 18 20:08 /root/.btcd/rpc.key root@60945d60a592:~/.btcd# Then I launch btcd daemon to read the config file:

btcd --configfile=/root/.btcd/btcd.conf

2023-09-18 19:53:21.028 [INF] BTCD: Version 0.23.3-beta 2023-09-18 19:53:21.028 [INF] BTCD: Loading block database from '/root/.btcd/data/simnet/blocks_ffldb' 2023-09-18 19:53:21.049 [INF] BTCD: Block database loaded 2023-09-18 19:53:21.052 [INF] INDX: Committed filter index is enabled 2023-09-18 19:53:21.053 [INF] CHAN: Loading block index... 2023-09-18 19:53:21.053 [INF] CHAN: Chain state (height 0, hash 683e86bd5c6d110d91b94b97137ba6bfe02dbbdb8e3dff722a669b5d69d77af6, totaltx 1, work 2) 2023-09-18 19:53:21.057 [WRN] RPCS: Can't listen on [::1]:18556: listen tcp6 [::1]:18556: bind: cannot assign requested address 2023-09-18 19:53:21.057 [INF] RPCS: RPC server listening on 127.0.0.1:18556 2023-09-18 19:53:21.058 [INF] AMGR: Loaded 0 addresses from file '/root/.btcd/data/simnet/peers.json' 2023-09-18 19:53:21.058 [INF] CMGR: Server listening on 0.0.0.0:18555 2023-09-18 19:53:21.058 [INF] CMGR: Server listening on [::]:18555 2023/09/18 19:53:27 http: TLS handshake error from 127.0.0.1:48722: remote error: tls: bad certificate

2023/09/18 19:54:27 http: TLS handshake error from 127.0.0.1:36374: remote error: tls: bad certificate 2023/09/18 19:55:27 http: TLS handshake error from 127.0.0.1:50224: remote error: tls: bad certificate 2023/09/18 19:56:27 http: TLS handshake error from 127.0.0.1:51260: remote error: tls: bad certificate 2023/09/18 19:57:27 http: TLS handshake error from 127.0.0.1:50722: remote error: tls: bad certificate 2023/09/18 19:58:27 http: TLS handshake error from 127.0.0.1:34688: remote error: tls: bad certificate 2023/09/18 19:59:27 http: TLS handshake error from 127.0.0.1:49148: remote error: tls: bad certificate 2023/09/18 20:00:27 http: TLS handshake error from 127.0.0.1:48996: remote error: tls: bad certificate 2023/09/18 20:01:27 http: TLS handshake error from 127.0.0.1:42000: remote error: tls: bad certificate 2023/09/18 20:02:27 http: TLS handshake error from 127.0.0.1:56724: remote error: tls: bad certificate 2023/09/18 20:03:27 http: TLS handshake error from 127.0.0.1:48854: remote error: tls: bad certificate 2023/09/18 20:04:27 http: TLS handshake error from 127.0.0.1:49388: remote error: tls: bad certificate 2023/09/18 20:05:27 http: TLS handshake error from 127.0.0.1:51190: remote error: tls: bad certificate 2023/09/18 20:06:27 http: TLS handshake error from 127.0.0.1:55028: remote error: tls: bad certificate 2023/09/18 20:07:27 http: TLS handshake error from 127.0.0.1:54364: remote error: tls: bad certificate 2023/09/18 20:08:27 http: TLS handshake error from 127.0.0.1:50830: remote error: tls: bad certificate 2023/09/18 20:09:27 http: TLS handshake error from 127.0.0.1:48612: remote error: tls: bad certificate 2023/09/18 20:10:27 http: TLS handshake error from 127.0.0.1:40412: remote error: tls: bad certificate 2023/09/18 20:11:27 http: TLS handshake error from 127.0.0.1:40282: remote error: tls: bad certificate ...... From my experience, I can't use openssl to generate any cerficate, since I always get error: root@60945d60a592:~/.btcd# btcctl --rpcuser=rpcuser --rpcpass=regtest --rpcserver=127.0.0.1:18334 getblockchaininfo Post "https://127.0.0.1:18334": x509: cannot validate certificate for 127.0.0.1 because it doesn't contain any IP SANs The certificate generated by openssl did not have IP SAN, it is for sure, I check the certificate, and I can't find any IP SAN; but using gencerts --host=localhost --directory=/root/.btcd --force => This also failed. How to fix this? My enviroment: OS: Windows 10 (22H2); Docker desktop: version: 4.23.0 (latest); btcd version: Version 0.23.3-beta. Btcwallet: Version 0.15.1-alpha I don't know if the btcd needs specific version to work with btcwallet. Any solution for this issue? BtcdBadCertificate

guggero commented 9 months ago

You don't need to generate a certificate, btcd will do that for you. Then you have to specify that in btcwallet when connecting.

Can't listen on [::1]:18556: listen tcp6 [::1]:18556: bind: cannot assign requested address

This probably just means you don't have ipv6 networking enabled within the container but are trying to listen on an ipv6 address.

zydjohnHotmail commented 9 months ago

Hi, I don't quite understand. If I don't need generate certificate, then just using the config file: [Application Options] rpcuser=yourusername rpcpass=yourpassword simnet=1 And run btcd --configfile=/path/to/config/file? Then what I should do? I want to create an account for user Alice (or any default account), and create another account for Bob(or any none-default account), generate some blocks (I think 101 blocks will be enough to get some reward BTC tokens, right); then try to send 1BTC token from Alice's wallet address to Bob's wallet address. I think I can use btcctl to get new address, and use btcctl to transfer some tokens. But how to create wallet, I don't know if btcctl can do this or not. Do I have to use btcwallet package? And which version of btcwallet I have to install? Please advise, Thanks,

guggero commented 9 months ago

Yes, just start btcd and it will generate its own (self-signed) certificate. btcd itself doesn't have a wallet (and hence no accounts), you'll need to use an additional software for that. There is btcwallet which does work as a standalone binary (though it is designed and maintained more as a library for other software, such as lnd), see https://github.com/btcsuite/btcwallet#getting-started.

You can also use lnd as an on-chain wallet (ignoring all the Lightning features), as it might have more wallet features out of the box than the standalone btcwallet binary. See https://github.com/lightningnetwork/lnd/tree/master/docker for a docker based tutorial with btcd on simnet.

Going to convert this to a discussion as this sounds like troubleshooting and not an issue with btcd itself.