Bitcoin Forum
November 05, 2024, 06:44:54 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: RPC command to get block tree  (Read 1187 times)
domob (OP)
Legendary
*
Offline Offline

Activity: 1135
Merit: 1170


View Profile WWW
July 02, 2014, 05:52:29 PM
 #1

Bitcoin Core has the start-up option "-printblocktree" to get information about the blockchain status, in particular, potential chain forks the client knows about.  I think it could be handy to have the possibility to access this same information also via an RPC call - this can be used from within a running daemon, and external services (web applications using the daemon internally, for instance) could use this to detect chain forks.

I've implemented something like this already for Namecoin and originally Huntercoin, see https://github.com/chronokings/huntercoin/pull/19.  This implements a simple new RPC command "getchains" (the name could be changed, obviously) with output like this:
Code:
[
    {
        "height" : 249522,
        "hash" : "458354cbd80c350045076193030d75dbcbb007d76f4960dbc6b00d560b77065d",
        "is_best" : true,
        "branch_len" : 0
    },
    {
        "height" : 249522,
        "hash" : "a18a3d1848e095297b41b9f921f5b86086c165ba9dff7e30d286c36373f334be",
        "is_best" : false,
        "branch_len" : 1,
        "branch" : [
            "7e78dc70d073a164ab66b066f2413578648b4d3ecc0d72ef9be2132faab36b82"
        ]
    },
    {
        "height" : 237894,
        "hash" : "b2274b69cf1e8ebd23c560b8b9811fe17c48720e0fb96e8f3ee5b5f5fffea27a",
        "is_best" : false,
        "branch_len" : 2,
        "branch" : [
            "28d1151f24990831e89bccfa1131a9387013ee3fdc946bf6fe8efa2d0c7a7a34",
            "c1ffb74675d2d23e087f026266d0f90096e4d1d6e7979b5638ed3be024f58543"
        ]
    },
    {
        "height" : 237865,
        "hash" : "0c0509b3d6e30663d7c96a0337d43223ce759b725a124a5892399efa37c9134b",
        "is_best" : false,
        "branch_len" : 3,
        "branch" : [
            "ddb0cb645af22155d652382ae03143401b733eb5b7981a9e9ba8b9f7632f4910",
            "ff6b5f794c08e8ca45682db3fe8ec715d31fb57159b2c90f2a0b7300b5e88b45",
            "6e60b1718f923c888f34d773eee6aa753c7f22e4405a128fc59740f98a8be61c"
        ]
    },
    {
        "height" : 87393,
        "hash" : "fef9f102dc000e0069e3042526032327bc618453b5bc0d8ca25ee5509028e628",
        "is_best" : false,
        "branch_len" : 12,
        "branch" : [
            "50926027c1fe34e43c59d8bf84a475e56bd63e62bf4a2e5756fea68ddbd00910",
            "648927b7b456d36a0a2baa68b57a51ad9878b10b1d708187acfeeb8f8b74ebe2",
            "e0872226a925cbf552557ba3f6a7d072fa6ee4f119da8719acfc5e3fb0477c1b",
            "841df107ac58c51d4ee4346b716e086368c987355cf6b854d8c423f31db4431b",
            "e28701a3bab940f3ec81cd0324ccb47cb34dfd8cc30211b23f3532cabb578d44",
            "9742dbcc4d447054a135255c720c286ff498002cda408f6c5e98d7c8fb4d3454",
            "92b463b45ec5afccfc7dc14a774b681966f9fa4740653bbf520eaa0b25d01049",
            "2c88dae0637e5977ebeb2367675c71e43c259b9ead16ed30fbb3135d989e9266",
            "8aa82978461c0dc812160ffcf4fc89a780f1d67e3a29123c318238eaa9b5facf",
            "f244148b7e02839787452481b9b76cb166718410f082b688b565644e18d3be1e",
            "91d4acdf2a641d7b545b4b73323db69eda60520ec21ba86e885e3a83f886c4e3",
            "497e0d08cef9c85e20fe7d758c3bf6010072105a6a2b33123b524e8413e45b69"
        ]
    }
]

What do you think about adding this or similar functionality also to Bitcoin Core?  Would a pull request be welcome?  I would be interested in working on a patch to implement this for Bitcoin Core.  Of course, the precise output format and other details can be discussed freely, and I will implement them as desired.

Use your Namecoin identity as OpenID: https://nameid.org/
Donations: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | NMC: NCdomobcmcmVdxC5yxMitojQ4tvAtv99pY
BM-GtQnWM3vcdorfqpKXsmfHQ4rVYPG5pKS | GPG 0xA7330737
niceWoman25
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
July 02, 2014, 08:50:05 PM
 #2

Hello Smiley

I see you can code in c++, would you do me a favor and code a RPC command to set a Hard Limit for Fee of transactions and reject all RPC sendtoaddress (and sendmany) transactions if the internally calculated Fee is higher than the previously set hardlimitfee like, lets say, 0.02 ?

I posted an thread 5 minutes earlier where i describe it more detailed:
https://bitcointalk.org/index.php?topic=675189.msg7645590#msg7645590
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!