Bitcoin Forum
September 24, 2018, 05:04:22 AM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: --delete please--  (Read 759 times)
mmitech
Legendary
*
Offline Offline

Activity: 1106
Merit: 1000


things you own end up owning you


View Profile
January 16, 2016, 07:22:56 PM
 #1

delete please
1537765462
Hero Member
*
Offline Offline

Posts: 1537765462

View Profile Personal Message (Offline)

Ignore
1537765462
Reply with quote  #2

1537765462
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 1526
Merit: 1654


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


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: 1526
Merit: 1654


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


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: 1526
Merit: 1654


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


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: 1526
Merit: 1654


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


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

achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 1526
Merit: 1654


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


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: 1526
Merit: 1654


3F1Y9yquzvY6RWvKbw2n2zeo9V5mvBhADU


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:  

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!