0

I'm setting up a regtest scenario in which I want to send transactions which should be included in new blocks created via the generatetoaddress RPC call. However, I want to disable transaction relaying, i.e., enforcing relay through blocks only. I therefore set blocksonly=1 (but see identical results also with walletbroadcast=0).

As this seems to not only switch the relaying method, but also disable the mempool entirely, sent transactions are no more included in generated blocks. Furthermore, the balance weirdly does not seem to reflect the transaction's change, resulting in the entire UTXO being spent. Is there any way to fix this, can blocksonly play together with regtest's generatetoaddress? Or is this even a bug?

Seen behavior (with blocksonly=1):

> bitcoin-cli -regtest getbalance
3725.00000000

> for i in $(seq 1 3); do
bitcoin-cli -regtest sendtoaddress $(bitcoin-cli -regtest getnewaddress) 0.0001
bitcoin-cli -regtest getbalance
done
33a3c5ce3c9aadff9266ddd8afb97a75342cb9943ac357c40a197421e0e7e21c
3700.00000000 # SPENDING 25 BTC PER TRANSACTION
2f2e3fa350d85ccbceed977bbec2657fd76d44c14dee5efc359d70db90a2ef1e
3675.00000000 # SPENDING 25 BTC PER TRANSACTION
bf5243fca72026ce4a0806f4fbfb7f644b5e1b6a88c86aa860bb927fa97e4d10
3650.00000000 # SPENDING 25 BTC PER TRANSACTION

> bitcoin-cli -regtest generatetoaddress 1 $(bitcoin-cli -regtest getnewaddress)
[
  "5ebc90372157079c6d81abb288d447d9a8dd743cb2c597a13f8b2e45751f899c"
]

> bitcoin-cli -regtest getblock "5ebc90372157079c6d81abb288d447d9a8dd743cb2c597a13f8b2e45751f899c"
{
  "hash": "5ebc90372157079c6d81abb288d447d9a8dd743cb2c597a13f8b2e45751f899c",
  "confirmations": 1,
  "strippedsize": 216,
  "size": 252,
  "weight": 900,
  "height": 101001,
  "version": 536870912,
  "versionHex": "20000000",
  "merkleroot": "a86a1d1bd5863aff4ece31495567c19de0d3371e2d9f7a33a1ac211608b7feaa",
  "tx": [
    "a86a1d1bd5863aff4ece31495567c19de0d3371e2d9f7a33a1ac211608b7feaa" # ONLY COINBASE
  ],
  "time": 1624617257,
  "mediantime": 1624562814,
  "nonce": 1,
  "bits": "207fffff",
  "difficulty": 4.656542373906925e-10,
  "chainwork": "0000000000000000000000000000000000000000000000000000000000031514",
  "nTx": 1,
  "previousblockhash": "109f2e43eb1a23904fa99100871f60db06bfc0f5cdc857cdadbcb2d904d46d16"
}

Expected behavior (which I can reach with blocksonly=0):

> bitcoin-cli -regtest getbalance
3725.00000000

> for i in $(seq 1 3); do
bitcoin-cli -regtest sendtoaddress $(bitcoin-cli -regtest getnewaddress) 0.0001
bitcoin-cli -regtest getbalance
done
33ef9047a9297cb311eadae019ad8cc45e8faddac2239e6e67befeb27906bb27
3724.99998590
9f0f99b8c44c1fd959c90ec8c8eb1e51852d3730e6b9d61d0569d8f298a20cd2
3724.99997180
929622f196c1a73ae298a47d1d33a79d70753cb2378ec65a82aac26031334efc
3724.99995770

> bitcoin-cli -regtest generatetoaddress 1 $(bitcoin-cli -regtest getnewaddress)
[
  "5345dc46cde6fd79b003ea1a26e2b48a43c1f668b685bc15e2a090a32c016f30"
]

> bitcoin-cli -regtest getblock "5345dc46cde6fd79b003ea1a26e2b48a43c1f668b685bc15e2a090a32c016f30"

{
  "hash": "5345dc46cde6fd79b003ea1a26e2b48a43c1f668b685bc15e2a090a32c016f30",
  "confirmations": 1,
  "strippedsize": 555,
  "size": 918,
  "weight": 2583,
  "height": 101001,
  "version": 536870912,
  "versionHex": "20000000",
  "merkleroot": "f6fb198bdbba154c4b2e788baec6545ea1f4c3ea6be6c42fafd50776a2acdc96",
  "tx": [
    "81e2b4393cb6ec35cd1455242dea00fcf5af8d759c0ebe0a7fb8551224a5a9fc",
    "33ef9047a9297cb311eadae019ad8cc45e8faddac2239e6e67befeb27906bb27",
    "9f0f99b8c44c1fd959c90ec8c8eb1e51852d3730e6b9d61d0569d8f298a20cd2",
    "929622f196c1a73ae298a47d1d33a79d70753cb2378ec65a82aac26031334efc"
  ],
  "time": 1624616991,
  "mediantime": 1624562814,
  "nonce": 0,
  "bits": "207fffff",
  "difficulty": 4.656542373906925e-10,
  "chainwork": "0000000000000000000000000000000000000000000000000000000000031514",
  "nTx": 4,
  "previousblockhash": "109f2e43eb1a23904fa99100871f60db06bfc0f5cdc857cdadbcb2d904d46d16"
}

Your Answer

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

Browse other questions tagged or ask your own question.