Bitcoin Forum
January 21, 2019, 05:09:58 PM *
News: Latest Bitcoin Core release: 0.17.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: An altcoin that sends some of the block reward to the developer wallets  (Read 243 times)
Oskii
Newbie
*
Offline Offline

Activity: 200
Merit: 0


View Profile WWW
December 04, 2017, 10:53:16 AM
 #1

I'm developing an altcoin for learning purposes, and I'm experimenting with the bitcoin source code so that I can learn the ins and outs of this stuff.

My latest challenge to myself is to develop and altcoin that gives some of the mining reward to a developer wallet whenever any miner successfully mines the block.
I'm thinking the mining reward should be 50 coins, 49 of those will go to the miner, but 1 of those coins will go into the developer wallet, lets say.

Poking around with the code lead me to `miner.cpp`, around line 190.

  
Code:
CMutableTransaction coinbaseTx;
    coinbaseTx.vin.resize(1);
    coinbaseTx.vin[0].prevout.SetNull();
    coinbaseTx.vout.resize(1);
    coinbaseTx.vout[0].scriptPubKey = scriptPubKeyIn;
    coinbaseTx.vout[0].nValue = nFees + GetBlockSubsidy(nHeight, chainparams.GetConsensus());
    coinbaseTx.vin[0].scriptSig = CScript() << nHeight << OP_0;
    pblock->vtx[0] = MakeTransactionRef(std::move(coinbaseTx));
    pblocktemplate->vchCoinbaseCommitment = GenerateCoinbaseCommitment(*pblock, pindexPrev, chainparams.GetConsensus());
    pblocktemplate->vTxFees[0] = -nFees;

It seems as though I would need to add a new output to
Code:
coinbaseTx.vout
which would be the 1 coin output given to the developer.

Is this correct?

If so, how would I set up this new output? I can't simply add the public key of the developer wallet somewhere as I need to generate a scriptPubKey to do this. However, I'm not sure exactly how this would be done.

I am assuming that I would have to change the
Code:
coinbaseTx.vout.resize(1)
to  
Code:
coinbaseTx.vout.resize(2)
, then add the new output in there. I'm assuming I would have to decrease the value of the first output that is given to the miner as the block reward. Am I correct in assuming that scriptPubKeyIn is the miners scriptPubKey?

I'm sure that I would also have to change the consensus rules to check that new blocks entering the network indeed give an output of 1 coin to the developers, as part of the coinbase reward. If they do not include this in they coinbase transaction, then they would surely be rejected.

I'm not really sure how to add this new output on the coinbase transaction, to a fixed wallet. Any help would be greatly appreciated -

happy to donate a few satoshis to someone who gives me an answer I can use BTC  Grin Grin Grin
1548090598
Hero Member
*
Offline Offline

Posts: 1548090598

View Profile Personal Message (Offline)

Ignore
1548090598
Reply with quote  #2

1548090598
Report to moderator
1548090598
Hero Member
*
Offline Offline

Posts: 1548090598

View Profile Personal Message (Offline)

Ignore
1548090598
Reply with quote  #2

1548090598
Report to moderator
1548090598
Hero Member
*
Offline Offline

Posts: 1548090598

View Profile Personal Message (Offline)

Ignore
1548090598
Reply with quote  #2

1548090598
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1548090598
Hero Member
*
Offline Offline

Posts: 1548090598

View Profile Personal Message (Offline)

Ignore
1548090598
Reply with quote  #2

1548090598
Report to moderator
Oskii
Newbie
*
Offline Offline

Activity: 200
Merit: 0


View Profile WWW
December 04, 2017, 01:40:13 PM
 #2

I've actually managed to do this now, but I the problem is the validation tests fail. Any ideas which validation rules this may have broken. Turns out the validation file is 4000 lines long, yikes.
Pages: [1]
  Print  
 
Jump to:  

Bitcointalk.org is not available or authorized for sale. Do not believe any fake listings.
Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!