Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

StackOverflow Point

StackOverflow Point Navigation

  • Web Stories
  • Badges
  • Tags
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Web Stories
  • Badges
  • Tags
Home/ Questions/Q 185426
Alex Hales
  • 0
Alex HalesTeacher
Asked: June 9, 20222022-06-09T22:13:17+00:00 2022-06-09T22:13:17+00:00

asp.net mvc – How Do I Import A RegTest Bitcoin Private Key Into A Descriptor Wallet for An NBitcoin C# MVC App

  • 0

[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]

  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Related Questions

  • xcode - Can you build dynamic libraries for iOS and ...

    • 0 Answers
  • bash - How to check if a process id (PID) ...

    • 325 Answers
  • database - Oracle: Changing VARCHAR2 column to CLOB

    • 295 Answers
  • What's the difference between HEAD, working tree and index, in ...

    • 292 Answers
  • Amazon EC2 Free tier - how many instances can I ...

    • 0 Answers

Stats

  • Questions : 43k

Subscribe

Login

Forgot Password?

Footer

Follow

© 2022 Stackoverflow Point. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.