Bitcoin Forum

Bitcoin => Project Development => Topic started by: supermoney on May 23, 2018, 01:18:47 PM



Title: [Solved+Fix] Issue with mined coins of my altcoin
Post by: supermoney on May 23, 2018, 01:18:47 PM
I'm facing a problem with my own altcoin when mining new blocks, I do not receive any mined coin to my coinbase address and of course Bitcoin Core keeps displaying me 0 BTC balance.

Setup:
Forked Bitcoin Core v0.16.0 (stable version), generated genesis block, reduced COINBASE_MATURITY from 100 to 1, changed PUBKEY_ADDRESS to 65 ('T') and SCRIPT_ADDRESS to 66 (alternative 'T', PS: I'm aware it looks confusing/weird especially in such test cases).

CPU Miner:
Code:
-O test:1234 -o http://127.0.0.1:15621/ --coinbase-addr=ToNdTui9QonxKutQA9W3rVTocwXYbUndf9 -a sha256d -D --no-longpoll --no-getwork --no-stratum

The block explorer I setup (bitcoin-abe (https://github.com/bitcoin-abe/bitcoin-abe)) shows the mined coins are being forwarded to some unknown address TQ32UoQrhdL5WUkK8jAjNNC1zSGbt7zQXw not owned by me.

Block #1:

https://image.prntscr.com/image/3R2xAZbhQi_1zFRpEioYgg.png
[click here for full screen image (https://image.prntscr.com/image/3R2xAZbhQi_1zFRpEioYgg.png)]



Coinbase Transaction:

https://image.prntscr.com/image/bl1g8mxTQe6b8JdiZ4uuyw.png
[click here for full screen image (https://image.prntscr.com/image/bl1g8mxTQe6b8JdiZ4uuyw.png)]



ToNdTui9QonxKutQA9W3rVTocwXYbUndf9:

https://image.prntscr.com/image/3WnxmcJrRSObbyCA8_XWKA.png
[click here for full screen image (https://image.prntscr.com/image/3WnxmcJrRSObbyCA8_XWKA.png)]



TQ32UoQrhdL5WUkK8jAjNNC1zSGbt7zQXw:

https://image.prntscr.com/image/0251zKHaSxeudcB1XSPBQw.png
[click here for full screen image (https://image.prntscr.com/image/0251zKHaSxeudcB1XSPBQw.png)]


Title: Re: Issue with mined coins of my altcoin
Post by: supermoney on May 23, 2018, 02:28:03 PM
It looks like ToNdTui9QonxKutQA9W3rVTocwXYbUndf9 is script address (P2SH) and TQ32UoQrhdL5WUkK8jAjNNC1zSGbt7zQXw is pubkey address (P2PKH).
What I don't understand is why cpuminer is sending the mined coins to that pubkey address and not to the script address I entered in coinbase-addr parameter?


Title: Re: Issue with mined coins of my altcoin
Post by: supermoney on May 24, 2018, 01:55:24 PM
[SOLVED+FIX]

I've managed to fix the issue by enabling CPU miner to read the PS2H prefix by editing util.c of CPU miner:

https://github.com/pooler/cpuminer/blob/master/util.c#L674

Change that value according to your SCRIPT_ADDRESS in chainparams.cpp of your coin's source code:

https://github.com/bitcoin/bitcoin/blob/master/src/chainparams.cpp#L141

Re-compile the CPU miner and run it. This is gonna be the success result:

https://image.prntscr.com/image/rJadNeQJQOueiylmR2jvqg.png