Add RPC call to generate and verify merkle blocks #5199

pull TheBlueMatt wants to merge 4 commits into bitcoin:master from TheBlueMatt:bitcoinchain0 changing 9 files +238 −5
  1. TheBlueMatt commented at 4:53 AM on November 3, 2014: member

    (based on #5181 as it would otherwise conflict and I'm lazy.)

    Adds RPC calls to generate (and verify) merkle blocks which, though verify is less useful for Bitcoin Core, just making them more accessible so that (hopefully) they become useful for people to exchange around would be very nice.

    Full Disclosure: This is required to sidechain-related work.

  2. TheBlueMatt commented at 4:53 AM on November 3, 2014: member

    Oh, also a simple flag to getblock so you can get only the header. That one is not related to sidechains, but I needed it while debugging.

  3. in src/bitcoin-tx.cpp:None in 3364581637 outdated
       3 | @@ -4,15 +4,17 @@
       4 |  
       5 |  #include "base58.h"
       6 |  #include "clientversion.h"
       7 | +#include "core/block.h" // for MAX_BLOCK_SIZE
       8 |  #include "core/transaction.h"
       9 |  #include "core_io.h"
      10 | +#include "coins.h"
    


    Diapolo commented at 8:57 AM on November 3, 2014:

    coins should be before core ;)

  4. in src/bitcoin-tx.cpp:None in 3364581637 outdated
      13 |  #include "script/script.h"
      14 |  #include "script/sign.h"
      15 |  #include "ui_interface.h" // for _(...)
      16 |  #include "univalue/univalue.h"
      17 |  #include "util.h"
      18 | +#include "utilstrencodings.h"
    


    Diapolo commented at 8:57 AM on November 3, 2014:

    utilstrencodings should be below utilmoneystr

  5. in src/merkleblock.cpp:None in 3364581637 outdated
       0 | @@ -0,0 +1,177 @@
       1 | +// Copyright (c) 2009-2010 Satoshi Nakamoto
       2 | +// Copyright (c) 2009-2014 The Bitcoin developers
       3 | +// Distributed under the MIT software license, see the accompanying
       4 | +// file COPYING or http://www.opensource.org/licenses/mit-license.php.
       5 | +
       6 | +#include "merkleblock.h"
       7 | +
       8 | +#include "hash.h"
    


    Diapolo commented at 9:00 AM on November 3, 2014:

    core before hash

  6. in src/merkleblock.cpp:None in 3364581637 outdated
      62 | +
      63 | +uint256 CPartialMerkleTree::CalcHash(int height, unsigned int pos, const std::vector<uint256> &vTxid) {
      64 | +    if (height == 0) {
      65 | +        // hash at height 0 is the txids themself
      66 | +        return vTxid[pos];
      67 | +    } else {
    


    Diapolo commented at 9:01 AM on November 3, 2014:

    Woulnd't need an else block, right?


    TheBlueMatt commented at 6:06 PM on November 6, 2014:

    That is #5181 and is code-move-only, so I dont want to change it.


    Diapolo commented at 6:24 PM on November 6, 2014:

    Right, but most of the time these nits or improvement suggestions are not catched by anyone later on anyway ;).

  7. in src/merkleblock.h:None in 3364581637 outdated
       0 | @@ -0,0 +1,150 @@
       1 | +// Copyright (c) 2009-2010 Satoshi Nakamoto
       2 | +// Copyright (c) 2009-2014 The Bitcoin developers
       3 | +// Distributed under the MIT software license, see the accompanying
       4 | +// file COPYING or http://www.opensource.org/licenses/mit-license.php.
       5 | +
       6 | +#ifndef BITCOIN_MERKLEBLOCK_H
       7 | +#define BITCOIN_MERKLEBLOCK_H
       8 | +
       9 | +#include "serialize.h"
    


    Diapolo commented at 9:02 AM on November 3, 2014:

    Same here, ordering.

  8. in src/rpcrawtransaction.cpp:None in 3364581637 outdated
     193 | @@ -193,6 +194,112 @@ Value getrawtransaction(const Array& params, bool fHelp)
     194 |      return result;
     195 |  }
     196 |  
     197 | +Value gettxoutproof(const Array& params, bool fHelp)
     198 | +{
     199 | +    if (fHelp || (params.size() != 1 && params.size() != 2))
     200 | +        throw runtime_error(
     201 | +            "gettxoutproof \"txid\" ( block hash )\n"
    


    cozz commented at 8:47 PM on November 4, 2014:

    This looks like we require 2 arguments here, block and hash, but its only 1 blockhash, so I would remove the space between the two.


    TheBlueMatt commented at 6:10 PM on November 6, 2014:

    Done.

  9. laanwj added the label RPC on Nov 5, 2014
  10. TheBlueMatt commented at 6:11 PM on November 6, 2014: member

    Fixed all the nits that we're related to header-include (I believe we removed that from our coding standards?)

  11. sipa commented at 6:15 PM on November 6, 2014: member

    We did; #5201. Still, feel free to follow them :)

  12. Diapolo commented at 6:23 PM on November 6, 2014: none

    @TheBlueMatt You as a core dev, I really would love to see you still following that rules :).

  13. TheBlueMatt referenced this in commit acdd46d062 on Nov 8, 2014
  14. TheBlueMatt commented at 7:09 AM on November 8, 2014: member

    Fixed include ordering for includes related to this pull (others are related to #5181)

  15. TheBlueMatt force-pushed on Dec 6, 2014
  16. TheBlueMatt commented at 12:39 AM on December 6, 2014: member

    Rebased on top of the now-merged #5181, also now support multiple transactions in one proof.

  17. TheBlueMatt force-pushed on Dec 6, 2014
  18. laanwj commented at 12:07 PM on January 26, 2015: member

    Concept ACK, but this new functionality needs a test in qa/rpc-tests.

  19. TheBlueMatt commented at 2:00 AM on February 4, 2015: member

    @laanwj done.

  20. TheBlueMatt force-pushed on Feb 4, 2015
  21. TheBlueMatt force-pushed on Feb 14, 2015
  22. TheBlueMatt force-pushed on Feb 14, 2015
  23. TheBlueMatt force-pushed on Feb 14, 2015
  24. in src/rpcblockchain.cpp:None in 45e467566d outdated
     258 |              "\nIf verbose is false, returns a string that is serialized, hex-encoded data for block 'hash'.\n"
     259 |              "If verbose is true, returns an Object with information about block <hash>.\n"
     260 | +            "If header only is true (and verbose is false), limits the output to only the block header.\n"
     261 |              "\nArguments:\n"
     262 |              "1. \"hash\"          (string, required) The block hash\n"
     263 |              "2. verbose           (boolean, optional, default=true) true for a json object, false for the hex encoded data\n"
    


    laanwj commented at 11:56 AM on March 9, 2015:

    headeronly (boolean) would need to be mentioned in the arguments here.

    BTW: what about adding a getblockheader call, instead of adding a boolean argument? I'd slightly prefer that for readability/simplicity. It would only result in minimal code duplication.


    laanwj commented at 12:01 PM on April 1, 2015:
  25. TheBlueMatt force-pushed on Apr 13, 2015
  26. TheBlueMatt force-pushed on Apr 13, 2015
  27. TheBlueMatt commented at 5:46 PM on April 13, 2015: member

    Rebased, fixed an indentation error, removed the blockheader-only option (meh, people can just substring(0, 160) anyway...)

  28. TheBlueMatt force-pushed on Apr 20, 2015
  29. TheBlueMatt force-pushed on Apr 20, 2015
  30. TheBlueMatt commented at 3:53 AM on April 20, 2015: member

    Rebased. Review?

  31. TheBlueMatt force-pushed on Apr 21, 2015
  32. Add CMerkleBlock constructor for tx set + block and an empty one 30da90de8d
  33. Add RPC call to generate and verify merkle blocks 59ed61b389
  34. TheBlueMatt force-pushed on Apr 24, 2015
  35. Add merkle blocks test 352ed22c2c
  36. TheBlueMatt force-pushed on Apr 24, 2015
  37. Remove broken+useless lock/unlock log prints 1ec900a29e
  38. TheBlueMatt force-pushed on Apr 24, 2015
  39. gavinandresen commented at 2:24 PM on April 27, 2015: contributor

    Tested ACK.

  40. laanwj commented at 8:07 AM on April 28, 2015: member

    utACK

  41. laanwj merged this on Apr 28, 2015
  42. laanwj closed this on Apr 28, 2015

  43. laanwj referenced this in commit 6364408122 on Apr 28, 2015
  44. TheBlueMatt deleted the branch on Apr 30, 2015
  45. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me