[ad_1]
I am trying to do Integration Testing for an MVC C# NBitcoin based app. NBitcoin creates wallets by private key and my app stores these private keys in a database. I need to spin up a RegTest node and I need to track the balances of these private keys for the integration tests. I used this docker command to start up the node:
docker run --rm -it \
-p 18443:18443 \
-p 18444:18444 \
ruimarinho/bitcoin-core \
-printtoconsole \
-regtest=1 \
-rpcallowip=172.17.0.0/16 \
-rpcbind=0.0.0.0 \
-fallbackfee=0.001 \
-rpcauth="<MY WALLET ACCOUNT NAME>:<HASHED PASSWORD STRING>"
Then I did the following Postman commands to get the RegTest node up and running via POST requests to the url http://<MY WALLET ACCOUNT NAME>:<ACTUAL PASSWORD STRING>@127.0.0.1:18443/
.
1. {"jsonrpc":"1.0","id":"1","method":"createwallet","params":["<NEW WALLET NAME>"]}
2. {"jsonrpc":"1.0","id":"1","method":"getnewaddress","params":[]}
3. {"jsonrpc":"1.0","id":"1","method":"generatetoaddress","params":[100, "<ADDRESS FROM STEP 2>"]}
4. {"jsonrpc":"1.0","id":"1","method":"generatetoaddress","params":[2, "<ADDRESS FROM STEP 2>"]}
5. {"jsonrpc":"1.0","id":"1","method":"sendtoaddress","params":["<NBITCOIN CREATED ADDRESS>", 2]}
6. {"jsonrpc":"1.0","id":"1","method":"generatetoaddress","params":[1, "<ADDRESS FROM STEP 2>"]}
Everything above worked, but in order to run my app’s integration tests, I need to track the wallet that the app created. NBitcoin creates wallets by private key, so I got the app created wallet’s private key and ran the following POST request in Postman.
{"jsonrpc":"1.0","id":"1","method":"importprivkey","params":["<NBITCOIN CREATED PRIVATE KEY>"]}
But the POST request failed with the following result:
{
"result": null,
"error": {
"code": -4,
"message": "This type of wallet does not support this command"
},
"id": "1"
}
From what I’ve researched about ruimarinho/bitcoin-core
, you can only import “descriptors” and not “private keys.” So how do I convert the private key to a descriptor? Or am I going about this all wrong and there’s another way to track a RegTest wallet for integration testing?
[ad_2]