nigiri icon indicating copy to clipboard operation
nigiri copied to clipboard

Issues using nigiri with bdk in CI

Open matthiasdebernardini opened this issue 11 months ago • 3 comments

I am trying to use nigiri as a stand in for electrum and bitcoin core rpc

I'm using bitcoincorerpc and bdk electrum client

Will the rpc endpoints that nigiri provides work with these? For example, syncing?

Do I have to mine my own blocks when I run faucet? should I sleep in between sending it and the next command?

I usually connect to my own bitcoin core rpc instance and importing descriptors and addresses works without issue, but with nigiri I have to skip them importing otherwise it fails.

Is the RPC interface different? I'm on bitcoin core version 28, so it should be the same?

matthiasdebernardini avatar Feb 06 '25 20:02 matthiasdebernardini

Will the rpc endpoints that nigiri provides work with these? For example, syncing?

Do I have to mine my own blocks when I run faucet? should I sleep in between sending it and the next command?

If you use Esplora REST endpoint POST /tx to broadcast transactions, it will automatically mine a block for you. If you are using Electrum RPC, we don't support intercepting those, so yeah you would need to manually mine a block. You can use the handy nigiri rpc -generate 1 to mine a block from the command line, or just call the POST /faucet if you need to use an HTTP client.

I usually connect to my own bitcoin core rpc instance and importing descriptors and addresses works without issue, but with nigiri I have to skip them importing otherwise it fails.

Can you please post your commands here so we can inspect them? In theory, you can use anything with nigiri rpc as you would expect with bitcoin-cli. Consider that we initialize an empty "" (legacy) wallet on nigiri start for quick start development, but if you need an extra wallet, you can import/create extra no? Try to use nigiri rpc importdescriptors and/or nigiri rpc listdescriptors as you would normally do with Bitcoin Core.

nigiri rpc listwallets
[
    ""
]

tiero avatar Feb 07 '25 11:02 tiero

Hey!

This is all I have to start up nigiri, I'm using it to connect to bitcoin core and electrum for my CI using the bdk crates for bitcoind and electrum.

      - name: Start Nigiri
        uses: vulpemventures/nigiri-github-action@v1
        
      # Add these new steps to set up Bitcoin Core wallet
      - name: Setup Bitcoin Core Wallet
        run: |
          nigiri rpc createwallet "siren"
          nigiri rpc loadwallet "siren"

Yea I create an address then fund it in my CI,

  echo "Bitcoin Address: $BITCOIN_ADDRESS
  nigiri faucet "$BITCOIN_ADDRESS"
  nigiri rpc -generate 3

which appears to be working correctly,

Bitcoin Address: bcrt1qhqek2299j487t5uzhwsnyt0evyrl7mczx2kyuxqhh2xlghwlacpqc32d38
txId: 877ab3b7cdeceb0489b717a652946c910ee625f102dcf3392f896def0afddb9d
{
    "address":  "bcrt1qehapnc53tc6qtf3qqf7rsnzu4sp59jfcfdznrg",
    "blocks":  [
        "0f54524e76c07ad51d12e4ed43ef954c5f8ccab9f9983be621f1dcc756698aa0",
        "23f27739361712cf34342610f7c945ab675eccfbc4de07eef9f671f9a5167b8e",
        "1c6dc4e5fa62a7eae113cf8c6fe78f7540456598355cadd81d6f92e5174fb898"
    ]
}

The issue I'm having is that my wallet can't get a balance from electrum, so bdk wont make a psbt (says balance is 0).

I'm connecting to electrum with this url "tcp://localhost:50000"

matthiasdebernardini avatar Feb 07 '25 15:02 matthiasdebernardini

Can you first try all these steps locally with Nigiri as CLI? My suspect is that you're not giving enough time to Electrum to sync up and index the UTXOs. Doing this process locally by hand will confirm if that's the case and if sleep time may be needed

tiero avatar Feb 08 '25 02:02 tiero