Author

Topic: --delete please-- (Read 853 times)

staff
Activity: 3374
Merit: 6530
Just writing some code
January 16, 2016, 05:16:14 PM
#7
Back to the previous code you provided, where do I put the first part ?

Code:
boolean hasAddr = false;
BOOST_FOREACH(const CTxOut& txout, tx.vout)
    if(txout.scriptPubKey == )
         hasAddr = true;

and the second part should be something like this:

Code:
if(!hasAddr || nHeight > "some block height in the future")
     return state.DoS(100, false, REJECT_INVALID, "bad-cb-address");
Those go right after
Code:
if (tx.IsCoinBase())
    {
on line 779 here: https://github.com/bitcoin/bitcoin/blob/dd1304ec216c7d4bdb302195e184b15503819f67/src/main.cpp#L779
staff
Activity: 3374
Merit: 6530
Just writing some code
January 16, 2016, 04:48:31 PM
#6
neither am I Smiley , I edited my post above, it would be easier to add a signature/message to the coinbase like pools do, then check if the block have my signature, what do you think ? could you drop a code that achieve that ?
I think I can do that. I will get back to you in a few minutes

Excellent, thank you.
Sorry, but it looks like I can't do it. Bitcoin's CScript is a lot harder to deal with than I thought and my C++ just isn't good enough to do this. I do know how the whole process would go though.

You would need to get the bytes of the script and the bytes of the string you expect to find. Then compare the two byte arrays and see if the script bytes contains the string bytes. If they do, then the block is good, otherwise, it is bad.
staff
Activity: 3374
Merit: 6530
Just writing some code
January 16, 2016, 04:26:34 PM
#5
neither am I Smiley , I edited my post above, it would be easier to add a signature/message to the coinbase like pools do, then check if the block have my signature, what do you think ? could you drop a code that achieve that ?
I think I can do that. I will get back to you in a few minutes
staff
Activity: 3374
Merit: 6530
Just writing some code
January 16, 2016, 04:20:49 PM
#4
No. It would actually be around here: https://github.com/bitcoin/bitcoin/blob/dd1304ec216c7d4bdb302195e184b15503819f67/src/main.cpp#L2923 where it checks the block. You need to add something there to check a parameter to see if it is yours. If you add something to the coinbase transaction, then you would need to add something here: https://github.com/bitcoin/bitcoin/blob/dd1304ec216c7d4bdb302195e184b15503819f67/src/main.cpp#L778 in the coinbase check to check the coinbase script for your parameter.

Thanks, Yes I just tried the previous and it didn't work, so should I add my address as a condition it I reject the blocks ? how do I go about that ? can you drop some code here ?
Here is some code, although I don't know if it will work. I am not too great at c++

Code:
boolean hasAddr = false;
BOOST_FOREACH(const CTxOut& txout, tx.vout)
    if(txout.scriptPubKey == )
         hasAddr = true;

if(!hasAddr)
     return state.DoS(100, false, REJECT_INVALID, "bad-cb-address");
where is a CScript that you need to build yourself. It must be the script that you expect to see in an output of a coinbase transaction.
staff
Activity: 3374
Merit: 6530
Just writing some code
January 16, 2016, 03:54:02 PM
#3
I am looking at the source code and I want to know how can a person reject all blocks except the ones mined by himself, I want to be still able to add transaction to my blocks but reject all other mined blocks except mine, where do I need to look in the source code ?
It probably would happen somewhere around here: https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L4912 when the block is received and processed or here: https://github.com/bitcoin/bitcoin/blob/dd1304ec216c7d4bdb302195e184b15503819f67/src/main.cpp#L3190 where the block is processed to check the block for a certain parameter that indicates that the block was mined by you.


Excellent, so instead
Code:
else if (strCommand == NetMsgType::BLOCK && !fImporting && !fReindex)


will be like this?

Code:
else if (strCommand == NetMsgType::BLOCK)
No. It would actually be around here: https://github.com/bitcoin/bitcoin/blob/dd1304ec216c7d4bdb302195e184b15503819f67/src/main.cpp#L2923 where it checks the block. You need to add something there to check a parameter to see if it is yours. If you add something to the coinbase transaction, then you would need to add something here: https://github.com/bitcoin/bitcoin/blob/dd1304ec216c7d4bdb302195e184b15503819f67/src/main.cpp#L778 in the coinbase check to check the coinbase script for your parameter.
staff
Activity: 3374
Merit: 6530
Just writing some code
January 16, 2016, 03:42:31 PM
#2
I am looking at the source code and I want to know how can a person reject all blocks except the ones mined by himself, I want to be still able to add transaction to my blocks but reject all other mined blocks except mine, where do I need to look in the source code ?
It probably would happen somewhere around here: https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L4912 when the block is received and processed or here: https://github.com/bitcoin/bitcoin/blob/dd1304ec216c7d4bdb302195e184b15503819f67/src/main.cpp#L3190 where the block is processed to check the block for a certain parameter that indicates that the block was mined by you.
legendary
Activity: 1148
Merit: 1001
things you own end up owning you
January 16, 2016, 03:22:56 PM
#1
delete please
Jump to: