diff --git a/src/lib/bitcoin/bitcoind/bitcoindService.spec.ts b/src/lib/bitcoin/bitcoind/bitcoindService.spec.ts index b02aa40860..48925b7c85 100644 --- a/src/lib/bitcoin/bitcoind/bitcoindService.spec.ts +++ b/src/lib/bitcoin/bitcoind/bitcoindService.spec.ts @@ -32,6 +32,18 @@ describe('BitcoindService', () => { mockProto.generateToAddress = jest.fn().mockResolvedValue(['blockhash1']); }); + // Adding Test case for selecting default wallet and not create a new one + it('should initialize the client with an explicit empty wallet path', () => { + bitcoindService.createClient(node); + // getInst() retrieves the first instance of BitcoinCore created + // We check if it was initialized with the 'wallet' property set to '' + expect(mockBitcoin).toHaveBeenCalledWith( + expect.objectContaining({ + wallet: '', + }), + ); + }); + it('should create a default wallet', async () => { mockProto.listWallets = jest.fn().mockResolvedValue([]); await bitcoindService.createDefaultWallet(node); diff --git a/src/lib/bitcoin/bitcoind/bitcoindService.ts b/src/lib/bitcoin/bitcoind/bitcoindService.ts index 00ff128308..da9c6354cc 100644 --- a/src/lib/bitcoin/bitcoind/bitcoindService.ts +++ b/src/lib/bitcoin/bitcoind/bitcoindService.ts @@ -17,6 +17,8 @@ class BitcoindService implements BitcoinService { host: `http://127.0.0.1:${node.ports.rpc}`, username: bitcoinCredentials.user, password: bitcoinCredentials.pass, + // default wallet to resolve multi-wallet conflict + wallet: '', logger: this.log(), // use a long timeout due to the time it takes to mine a lot of blocks timeout: 5 * 60 * 1000,