0

I'm testing some wallet features on regtest. Here's the sequence so far:

cash-cli -regtest generate 101
cash-cli -regtest getbalance
500.00000000

cash-cli -regtest getnewaddress newAddress1
yeAPxkjsNk5RZnAyfHM6cjCtKM7oRUvhzX

cash-cli -regtest  sendtoaddress getrawtransaction 148b8ced78037cb8fe3b32b8814dbf6736c144448671a86da548bbdb5670750a 1
//...
{
      "value": 2.00000000,
      "valueSat": 200000000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 c3bc1c481a15343ceb27d45d950c8770b7a0be1c OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914c3bc1c481a15343ceb27d45d950c8770b7a0be1c88ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "yeAPxkjsNk5RZnAyfHM6cjCtKM7oRUvhzX"
        ]
      }
    }, 
//...

dash-cli -regtest gettxout 148b8ced78037cb8fe3b32b8814dbf6736c144448671a86da548bbdb5670750a 0 false
//returns nothing as the transaction is not confirmed. Returns result if we change flag to true

How do I set transaction as confirmed in regtest mode so that dash-cli -regtest <txid> <outid> false would return the transaction output as a valid one?

1

A transaction is confirmed by including it in a block. This means that you have to mine a block which includes the transaction. You can do this using the generate command.

| improve this answer | |
  • could you give me an example? – Ben Aug 27 '18 at 13:31
  • cash-cli -regtest generate 6 will create 6 blocks with the block reward going to your wallet. – Andrew Chow Aug 27 '18 at 13:35
  • 3
    I create and send raw transaction then use generatetoaddress to mine blocks to get confirmations but the sent transactions stays unconfirmed. Any idea why? – Fontaine Sep 19 '19 at 3:42
  • @Fontaine did you ever find out what your problem was? I have the same, currently. – schlingel Dec 10 '19 at 6:14
  • Any news on this? I'm facing the same situation. – Daniel Portugal Oct 21 at 20:57
0

I'm running bitcoind along with Bitcore-node and I was having the same problem. I sent 250 transactions to myself, but the balance I got from BWC/BWS was:

{
  "totalAmount": 166250000000,
  "lockedAmount": 0,
  "totalConfirmedAmount": 0,
  "lockedConfirmedAmount": 0,
  "availableAmount": 166250000000,
  "availableConfirmedAmount": 0,
  "byAddress": [
    {
      "address": "mvaTRJ63NJrZ3qaZW1AbfVzMsei5HCiupb",
      "path": "m/0/0",
      "amount": 166250000000
    }
  ]
}

Apparently, bitcoind will hold a cache in memory and it takes some time (or more actions) to release it, passing its contents to the database.

When you close the process (say, with CTRL+C or CMD+C), you'll see a message like this:

2020-10-22T12:23:57Z FlushStateToDisk: write coins cache to disk (250 coins, 34kB) started 
2020-10-22T12:23:57Z FlushStateToDisk: write coins cache to disk (250 coins, 34kB) completed (0.05s)

Then, Bitcore-node will sync and save everything in MongoDb. So, if you close the bitcoind process and then restart, your transactions should become confirmed.

Here's exactly what I did:

  1. Start bitcoind in regtest mode:
    bitcoind -printtoconsole -regtest -fallbackfee=0.00001

  2. Start Bitcore-node. I assume you have it configured to point to your regtest node.
    npm run node

  3. Generate 250 transactions to myself:
    bitcoin-cli -regtest generatetoaddress 250 "mvaTRJ63NJrZ3qaZW1AbfVzMsei5HCiupb"

  4. Wait for Bitcore to sync with bitcoind.

  5. Close bitcoind with CTRL+C (or CMD+C).

  6. Close Bitcore-node with CTRL+C (or CMD+C).

  7. Restart bitcoind and Bitcore-node.

  8. Boom. Using BWC and BWS to fetch the wallet's balance I now receive this:

{
 "totalAmount":166250000000,
 "lockedAmount":0,
 "totalConfirmedAmount":166250000000,
 "lockedConfirmedAmount":0,
 "availableAmount":166250000000,
 "availableConfirmedAmount":166250000000,
 "byAddress":[
  {
   "address":"mvaTRJ63NJrZ3qaZW1AbfVzMsei5HCiupb",
   "path":"m/0/0",
   "amount":166250000000
  }
 ]
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.