Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: thekillingjoke on May 19, 2023, 07:12:11 PM



Title: Error when using +1 wallets in Bitcoin Core testnet (denpamusic/php-bitcoinrpc)
Post by: thekillingjoke on May 19, 2023, 07:12:11 PM
Hello everyone,

I have two wallets with Bitcoin Core testnet in the folder C:\Users' User's DataData, in the folder C:\Users' Data, in the folder C:\Users' User's Data. I use this PHP library: https://github.com/denpamusic/php-bitcoinrpc (https://github.com/denpamusic/php-bitcoinrpc)

Next, in this path is the folder named wallet and test1 with the .dat files of each wallet

If only one wallet exists, it detects it and can work without even putting 'walletdir' or 'wallet' in $config. But if there are two wallets, it does not work when I put the path in:

$config = [
    scheme' => 'http',
    'host' => 'localhost',
    'port' => 8332,
    'user' => 'user',
    'password' => 'pass',
    'walletdir' => '/wallets/wallet'
];

I have tried a thousand ways, for example: '/testnet3/wallets/wallet/wallet', '/wallets/wallet/wallet.dat' and it doesn't work either.

The error I get back is this: 'Fatal error: Uncaught Denpa\Bitcoin\Exceptions\BadRemoteCallException: Wallet file not specified (must request wallet RPC through /wallet/<filename> uri-path)'.


Title: Re: Error when using +1 wallets in Bitcoin Core testnet (denpamusic/php-bitcoinrpc)
Post by: thekillingjoke on May 19, 2023, 07:45:26 PM
Welcome to the forum
How to use -rpcwallet? (https://bitcointalk.org/index.php?topic=5238258.msg54166502#msg54166502) I think this link can help answer your question.

I'm using PHP, not -rcpwallet in CLI. I think this is not for me


Title: Re: Error when using +1 wallets in Bitcoin Core testnet (denpamusic/php-bitcoinrpc)
Post by: ABCbits on May 20, 2023, 09:56:47 AM
I have tried a thousand ways, for example: '/testnet3/wallets/wallet/wallet', '/wallets/wallet/wallet.dat' and it doesn't work either.

Does that include specify wallet filename outside config, as described on this test file?

Code:
// Source [url]https://github.com/denpamusic/php-bitcoinrpc/blob/2.2.x/tests/ClientTest.php#L103-L144[/url]
    /**
     * Test multiwallet request.
     *
     * @return void
     */
    public function testMultiWalletRequest(): void
    {
        $wallet = 'testwallet.dat';

        $response = $this->bitcoind
            ->setClient($this->mockGuzzle([$this->getBalanceResponse()]))
            ->wallet($wallet)
            ->request('getbalance');

        $this->assertEquals(self::$balanceResponse, $response->get());
        $this->assertEquals(
            $this->getHistoryRequestUri()->getPath(),
            "/wallet/$wallet"
        );
    }

    /**
     * Test async multiwallet request.
     *
     * @return void
     */
    public function testMultiWalletAsyncRequest(): void
    {
        $wallet = 'testwallet2.dat';

        $this->bitcoind
            ->setClient($this->mockGuzzle([$this->getBalanceResponse()]))
            ->wallet($wallet)
            ->requestAsync('getbalance', []);

        $this->bitcoind->wait();

        $this->assertEquals(
            $this->getHistoryRequestUri()->getPath(),
            "/wallet/$wallet"
        );
    }



--snip--
I think you are getting it wrong PHP if am not  is a programming language for web development while RPC is implemented in the web software to communicate with each other using HTTP. And checking your error message I found out it was similar to thread I linked before, but would still advice you check the thread out if it can in any way help.

PHP and any mature programming language can make RPC request just fine.