btcsuite / btcd

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

stat : no such file or directory. I don't konw the reason #2141

Open yangyile1990 opened 8 months ago

yangyile1990 commented 8 months ago
package main

import (
    "github.com/btcsuite/btcd/rpcclient"
)

func main() {
    cfg := &rpcclient.ConnConfig{
        Host:         "go.getblock.io/0371879beb44418680721ddd4cd53f81", // 第三方 DOGE币节点的RPC地址
        User:         "",                                                // 留空或设置为一个空字符串
        Pass:         "",                                                // 留空或设置为一个空字符串
        DisableTLS:   true,                                              // DOGE币节点默认不使用TLS
        HTTPPostMode: true,                                              // DOGE币节点只支持HTTP POST模式
    }
    client, err := rpcclient.New(cfg, nil)
    if err != nil {
        panic(err)
    }

    err = client.Ping()
    if err != nil {
        panic(err)
    }
}

panic: stat : no such file or directory. why?

guggero commented 8 months ago

A panic gives you a stack trace that tells you exactly where something panics and why. Without that information, we cannot help you.

cl1ckname commented 8 months ago

I've encountered this error when I specified an incorrect host path (such as /wallet/:walletName, where walletName does not exist) when connecting to a bitcoind node. rpcclient simply proxies this error from the node. Check the connection host

yemmyharry commented 8 months ago

Since you're using panic, the runtime should print the file and line number where the panic originated. The error message you showed doesn't explicitly indicate the source of error. You can as well use the log.Fatalf function to print the stack trace along with the panic error message.

pustovalov commented 7 months ago

Hi,

Not all providers require authentication through a password or a cookie. Given the following configuration:

cfg := &rpcclient.ConnConfig{
  Host:         "go.getblock.io/0371879beb44418680721ddd4cd53f81",
  User:         "",
  Pass:         "",
  DisableTLS:   true,
  HTTPPostMode: true,
}

https://github.com/btcsuite/btcd/blob/2f4ff8447d51872bc2704bd31fe3b13bfb9a0143/rpcclient/infrastructure.go#L1276-L1284

getAuth() will call config.retrieveCookie() and because there's no config.CookiePath there will be an error

st, err := os.Stat(config.CookiePath)
fmt.Println("err111", err)
err111 stat : no such file or directory