0

I wanted to test the submitblock rpc call in regtest but I seem to have some issues with the transactions I try to submit.

I have the following raw transactions:

02000000010000000000000000000000000000000000000000000000000000000000000000ffffffff03016900ffffffff0158660c2a010000001976a914a08da9e35ab58e957204703da9d48967ddd1703b88ac00000000 (coinbase tx)

02000000000101bd04d336a75e3f4cbf2bf249f529afd9d7740e0836be8384d2a392ddca161ecc0100000000fdffffff0240420f0000000000160014bf67ccfbc8e589a2192a74d2e16bc074889b425bf00ed305000000001600149f5283153368455efcd8a24faa97acb1a2c7f616024730440220249d8bcb08b183c15db2a03bcf2abde3d3e09e0d08a6f029fde2725a800de2a202201902749176353383ea8a78afa1080a84dd311453c3ebd95601c09db721cc9c250121024b162d93981a3e60448bbe4efcf57721f1e443ef280933ae7d20e90e612f5d4468000000 (tx1)

020000000001010453faefcc8f26e4734e965e3619deab009f6e4faa2971c34be334e28c67f2650000000000fdffffff0240420f00000000001600141b08d84ee1d89a0b682020d619653613737cb64cf01fe32901000000160014fe841631fe5df0584d22bdc6580c6127d25d25b302473044022073a8008fdef43bc637675114f760689439c4b94a9e59a73fe53919a6f3d4c4a302201f787059a139a6b80eceb02c49ee70ac552d3ca5713ea2c33dcfdceb38cc2850012103c7df223ee6eb22b9f183e807fc0fa3b672f62e9fc2a6316b0ca8fca24d907c7f68000000 (tx2)

02000000000101d43c09b3878100668c3c0f9bac461b092378b47deb989c819dc3f1c0cca4095f0100000000fdffffff022818eb230100000016001420184bf7efc25f9a1ecf99a9c532f5e2c93cdd1340420f000000000016001454e45729918ad5a7fa1130b0be47e6b5cfab16e20247304402200d06ed77a7b20419988d62760ee1aa2bccda92a22ddfbdd16f96319cc7862695022022730ff785e033ecfc5ffb57b6258368aba7896d9414e66c6932e4841033de40012103656e09a3a63bf08aa0ab9177edff3f87d0dbc95dd2f76fbc9ebb5f2323e8036f11000000 (tx3)

I calculated the txids for all of these tx (byte order already reversed): 6c13bf0a4bf648312d82fa454b2f4ad9a4ead32a805009d5949f981c4cf3bd3b (coinbase txid) 0773014af32002fcf11a603aa2c19503e36cb9ca87c6a8c7a8b7c7a1b7a38b11 (txid 1) 143b545dd5809658cf082cd03cb1e9e7645d95afd54d79b71c93e3d4431c46e6 (txid 2) 85e8dfe954afa4139c893dfda796d57700b059595a7986bc906637167de49060 (txid 3)

when put in order, I get the following merkle root: 5e76726c3a221c7ef39bbbc6d0ca57dd85d320ac13dda01994c517b7c2fc1385

I submit the block via submitblock. from the merkle root on it looks like this: 5e76726c3a221c7ef39bbbc6d0ca57dd85d320ac13dda01994c517b7c2fc1385c03d2465ffff7f20020000000402000000010000000000000000000000000000000000000000000000000000000000000000ffffffff03016900ffffffff0158660c2a010000001976a914a08da9e35ab58e957204703da9d48967ddd1703b88ac0000000002000000000101bd04d336a75e3f4cbf2bf249f529afd9d7740e0836be8384d2a392ddca161ecc0100000000fdffffff0240420f0000000000160014bf67ccfbc8e589a2192a74d2e16bc074889b425bf00ed305000000001600149f5283153368455efcd8a24faa97acb1a2c7f616024730440220249d8bcb08b183c15db2a03bcf2abde3d3e09e0d08a6f029fde2725a800de2a202201902749176353383ea8a78afa1080a84dd311453c3ebd95601c09db721cc9c250121024b162d93981a3e60448bbe4efcf57721f1e443ef280933ae7d20e90e612f5d4468000000020000000001010453faefcc8f26e4734e965e3619deab009f6e4faa2971c34be334e28c67f2650000000000fdffffff0240420f00000000001600141b08d84ee1d89a0b682020d619653613737cb64cf01fe32901000000160014fe841631fe5df0584d22bdc6580c6127d25d25b302473044022073a8008fdef43bc637675114f760689439c4b94a9e59a73fe53919a6f3d4c4a302201f787059a139a6b80eceb02c49ee70ac552d3ca5713ea2c33dcfdceb38cc2850012103c7df223ee6eb22b9f183e807fc0fa3b672f62e9fc2a6316b0ca8fca24d907c7f6800000002000000000101d43c09b3878100668c3c0f9bac461b092378b47deb989c819dc3f1c0cca4095f0100000000fdffffff022818eb230100000016001420184bf7efc25f9a1ecf99a9c532f5e2c93cdd1340420f000000000016001454e45729918ad5a7fa1130b0be47e6b5cfab16e20247304402200d06ed77a7b20419988d62760ee1aa2bccda92a22ddfbdd16f96319cc7862695022022730ff785e033ecfc5ffb57b6258368aba7896d9414e66c6932e4841033de40012103656e09a3a63bf08aa0ab9177edff3f87d0dbc95dd2f76fbc9ebb5f2323e8036f11000000

still, I get the following error: bad-txnmrklroot

do I miss something obvious here or is it a little more complicated?

thanks in advance

1
  • I have not verified your calculations, but you should know that you shouldn't do any byte-swapping at all, anywhere, except for display (human) purposes. At the protocol level, you take the 32 bytes that come out of (double) SHA256, concatenate those 32 bytes literally with another hash to provide the input for a Merkle hashing step, and the 32-byte result of those hashes is placed literally, without any swapping, into the 80-byte block header. Oct 9, 2023 at 22:48

1 Answer 1

2

For each of your non-coinbase transactions, you have posted the byte order expected for the merkle computation. However you have the reverse byte order for your coinbase transaction. I believe you are incorrectly reversing that.

Additionally, the merkle root you have posted is also the reverse byte order of the actual merkle root. This should not be reversed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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