英文:
bitcoind `listunspenttransactions` throws "Wallet file not specified" error
问题
I am using btcd rpcClient. In a nutshell, what I am doing, is loading a wallet, listing unspent tx and then unloading the wallet.
Here is a sample code:
import (
"github.com/btcsuite/btcd/rpcclient"
)
connCfg := &rpcclient.ConnConfig{
Host: "url:port",
User: "username",
Pass: "password",
HTTPPostMode: true, // Bitcoin core only supports HTTP POST mode
DisableTLS: true, // Bitcoin core does not provide TLS by default,
}
client, err := rpcclient.New(connCfg, nil)
if err != nil {
return nil, err
}
_, _ := btcClient.LoadWallet("walletname")
_, err := btcClient.ListUnspent()
fmt.Println(err)
btcClient.UnloadWallet(&farmName)
This worked completely fine on a signet node. After that I try it on a mainnet node (seemingly with the same configuration, same node version and same method of creating the wallet) and I get the following error:
"code":-19,"message":"Wallet file not specified (must request wallet RPC through /wallet/<filename> uri-path)."
I tried reproducing the problem with curl and again, on the mainnet node, this works, but on the mainnet node, I get the same error:
curl --user user:password --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "loadwallet", "params": ["walletname"] }' -H 'content-type: text/plain;' http://url:port/
curl --user user:password --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "listunspent"}' -H 'content-type: text/plain;' http://url:port/
curl --user user:password --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "unloadwallet", "params": ["walletname"] }' -H 'content-type: text/plain;' http://url:port/
Responses I get:
{"result":{"name":"walletname","warning":""},"error":null,"id":"curltest"}
{"result":null,"error":{"code":-19,"message":"Wallet file not specified (must request wallet RPC through /wallet/<filename> uri-path)."},"id":"curltest"}
{"result":{"warning":""},"error":null,"id":"curltest"}
英文:
I am using btcd rpcClient. In a nutshell, what I am doing, is loading a wallet, listing unspent tx and then unloading the wallet.
Here is a sample code:
import (
"github.com/btcsuite/btcd/rpcclient"
)
connCfg := &rpcclient.ConnConfig{
Host: "url:port",
User: "username",
Pass: "password",
HTTPPostMode: true, // Bitcoin core only supports HTTP POST mode
DisableTLS: true, // Bitcoin core does not provide TLS by default,
}
client, err := rpcclient.New(connCfg, nil)
if err != nil {
return nil, err
}
_, _ := btcClient.LoadWallet("walletname")
_, err := btcClient.ListUnspent()
fmt.Println(err)
btcClient.UnloadWallet(&farmName)
This worked completely fine on a signet node. After that I try it on a mainnet node (seemingly with the same configuration, same node version and same method of creating the wallet) and I get the following error:
`"code":-19,"message":"Wallet file not specified (must request wallet RPC through /wallet/<filename> uri-path)."
I tried reproducing tge problem with curl and again, on the signet node this works, but on mainet node, I get the same error:
curl --user user:password --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "loadwallet", "params": ["walletname"] }' -H 'content-type: text/plain;' http://url:port/
curl --user user:password --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "listunspent"}' -H 'content-type: text/plain;' http://url:port/
curl --user user:password --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "unloadwallet", "params": ["walletname"] }' -H 'content-type: text/plain;' http://url:port/
Responses I get:
{"result":{"name":"walletname","warning":""},"error":null,"id":"curltest"}
{"result":null,"error":{"code":-19,"message":"Wallet file not specified (must request wallet RPC through /wallet/<filename> uri-path)."},"id":"curltest"}
{"result":{"warning":""},"error":null,"id":"curltest"}
答案1
得分: 1
问题在于比特币守护程序启动时默认加载了一个钱包。当我加载我想要使用的钱包时,加载的钱包计数变为2。当没有指定钱包的情况下执行RPC查询时,它们会尝试使用已加载的钱包,但仅当已加载的钱包只有一个时才会这样做。由于我加载了2个钱包,它要求我指定要使用哪一个。
在签名节点上,出于某种原因,默认钱包没有加载,这就是为什么我在那里没有遇到同样的问题的原因。
可以使用listwallets方法检查已加载的钱包。
英文:
The problem was that there was a wallet that was loading by default on the bitcoin daemon startup. When I was loading the wallet that I wanted to work with, the loaded wallet count was becoming equal to 2. When the RPC queries are done without a specified wallet, they try to use the loaded wallet, but only if the loaded wallet is only one. Since I had 2 loaded wallets, it wanted me to specify which one to use.
On the signed node, the default wallet was not loading for some reason and that is why I wasn't getting the same problem there.
One can check the loaded wallets with the listwallets method.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论