Bitcoin Forum
April 26, 2024, 12:50:55 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: --delete please--  (Read 850 times)
mmitech (OP)
Legendary
*
Offline Offline

Activity: 1148
Merit: 1001


things you own end up owning you


View Profile
January 16, 2016, 07:22:56 PM
Last edit: January 19, 2016, 06:04:49 PM by mmitech
 #1

delete please
1714135855
Hero Member
*
Offline Offline

Posts: 1714135855

View Profile Personal Message (Offline)

Ignore
1714135855
Reply with quote  #2

1714135855
Report to moderator
1714135855
Hero Member
*
Offline Offline

Posts: 1714135855

View Profile Personal Message (Offline)

Ignore
1714135855
Reply with quote  #2

1714135855
Report to moderator
1714135855
Hero Member
*
Offline Offline

Posts: 1714135855

View Profile Personal Message (Offline)

Ignore
1714135855
Reply with quote  #2

1714135855
Report to moderator
You get merit points when someone likes your post enough to give you some. And for every 2 merit points you receive, you can send 1 merit point to someone else!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3374
Merit: 6535


Just writing some code


View Profile WWW
January 16, 2016, 07: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.

achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3374
Merit: 6535


Just writing some code


View Profile WWW
January 16, 2016, 07: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.

achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3374
Merit: 6535


Just writing some code


View Profile WWW
January 16, 2016, 08: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 == <your own scriptpubkey>)
         hasAddr = true;

if(!hasAddr)
     return state.DoS(100, false, REJECT_INVALID, "bad-cb-address");
where <your own scriptpubkey> 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.

achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3374
Merit: 6535


Just writing some code


View Profile WWW
January 16, 2016, 08:26:34 PM
Last edit: January 16, 2016, 08:47:57 PM by knightdk
 #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

achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3374
Merit: 6535


Just writing some code


View Profile WWW
January 16, 2016, 08: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.

achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3374
Merit: 6535


Just writing some code


View Profile WWW
January 16, 2016, 09: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 == <your own 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

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!