conradoqg / naivecoin

A cryptocurrency implementation in less than 1500 lines of code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Transaction fee destination

Andrewsopoku opened this issue · comments

Once again great work.
I would want to change the transaction fee destination from the miner's address to the receiver's address. Please how do i go about that.

Hey!

When you mine a new block you can inform the reward address. So the miner is who decides which address should receive the reward.

Best

Transaction fees can just be put to zero.

EDIT: Response to your response below.
@conradoqg I think we both mis-understood. I was saying just do not have a fee, therefore there is no fee, causing the same result (the whole transaction going to the receiver's address). I am not having any issues with this code, actually quite enjoying it. Added all kinds of toys to it.

@Andrewsopoku
Hey, I added the property feeAddress (as optional) to the mine endpoint, commit 088a6bb.

@MarcGodard Could you give me more details about how is that happening and where? Thanks!

I think I'm not getting your goal. Is this the line you are talking about?

let rejectedTransactions = 0;

Usually, the miner has his own address because he is the one spending time and energy to mine the block.

I see now. I think you would need to change a couple of things:

  • The miner selects the transactions that it wants to mine, so you could create a list of output transactions addresses and split the fee value by all output addresses (proportionally or not). You may want to remove the change transaction (the money that the sender receives back as a change).
  • You will need to change the transaction check to enable multiple fee transactions (eg 1 for each output transaction)

Anyway, it's possible to do that and I think you have all information you need. If you want more information tell me that I can give you some source references.

Best

Hi Conrad, do you believe that this code is ready for production ?

Hey. No, I don't believe it's ready for production. Check the // INFO comments, most of them should be implemented before putting something like naivechain to production IMO.