RPC interface for accessing auxpow data

Namecoin, NMControl
Post Reply
domob
Posts: 1129
Joined: Mon Jun 24, 2013 11:27 am
Contact:

RPC interface for accessing auxpow data

Post by domob »

For a project I'm working on (more in the future), I need to access the auxpow (if present) of blocks over the RPC interface. Since Namecoin Core's "getblock" is based on Bitcoin with no extensions so far, it does (of course) not give access to the auxpow. Of course, I can just request the raw block data and pick out the part that is the auxpow - this is probably what I'm going to do.

However, I think it makes sense to provide an RPC interface to the auxpow of a block. IMHO, "getblock" (in verbose mode - JSON output) should return the auxpow as part of the block somehow. Here are two possibilities I see:

1) Return the full auxpow as raw hex string. Would help to make the data returned "complete", but I'm not sure if it is that helpful. After all, the hex string can be gotten from the raw block hex relatively easily as well.
2) Try to return data split into pieces in the JSON output. This makes it simpler to use in client applications, and is consistent with the rest of the block also being in JSON format.

Of course, also 1+2 could be done. What do you think, which is better? I'm going to implement it for Namecoin Core.

For 2, the question is also how the JSON format of an auxpow should look like. I suggest the following:

Code: Select all

{
  "tx": <JSON of the PoW block's coinbase, like "getrawtransaction ... 1">,
  "index": 0, // This must be 0, could leave out.
  "merklebranch": [...], // Merkle branch of coinbase tx.
  "chainindex": n, // Index in the Merkle tree of auxpow chains.
  "chainmerklebranch": [...], // Corresponding Merkle branch.
  "parentblock": "..." // Raw hex of parent block header (where PoW is done)
}
Does this make sense?
BTC: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | NMC: NCdomobcmcmVdxC5yxMitojQ4tvAtv99pY
BM-GtQnWM3vcdorfqpKXsmfHQ4rVYPG5pKS
Use your Namecoin identity as OpenID: https://nameid.org/

domob
Posts: 1129
Joined: Mon Jun 24, 2013 11:27 am
Contact:

Re: RPC interface for accessing auxpow data

Post by domob »

Proposal: https://github.com/domob1812/namecore/tree/auxpow-json

With this, the auxpow of block 200,000 looks like this:

Code: Select all

"auxpow" : {
        "tx" : {
            "hex" : "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff5703dff204e4b883e5bda9e7a59ee4bb99e9b1bcfabe6d6d356d64a20fac1368d78b4ba4a5b8e27255bae8cf3c80e103097398d375e1340510000000000000004f99243aff0b00404d696e6564206279206e65696d656e67ffffffff01ab41c295000000001976a914c825a1ecf2a6830c4401620c3a16f1995057c2ab88ac00000000",
            "txid" : "152c9d0325f1d27e441c24e763d3719a91b7b79f6ffad51aa0fa3148468b1683",
            "version" : 1,
            "locktime" : 0,
            "vin" : [
                {
                    "coinbase" : "03dff204e4b883e5bda9e7a59ee4bb99e9b1bcfabe6d6d356d64a20fac1368d78b4ba4a5b8e27255bae8cf3c80e103097398d375e1340510000000000000004f99243aff0b00404d696e6564206279206e65696d656e67",
                    "sequence" : 4294967295
                }
            ],
            "vout" : [
                {
                    "value" : 25.12535979,
                    "n" : 0,
                    "scriptPubKey" : {
                        "asm" : "OP_DUP OP_HASH160 c825a1ecf2a6830c4401620c3a16f1995057c2ab OP_EQUALVERIFY OP_CHECKSIG",
                        "hex" : "76a914c825a1ecf2a6830c4401620c3a16f1995057c2ab88ac",
                        "reqSigs" : 1,
                        "type" : "pubkeyhash",
                        "addresses" : [
                            "NEpeRmS775fnti8TDgJA28m8KLEfNNRZvT"
                        ]
                    }
                }
            ],
            "blockhash" : "0000000000000000183e0cfc43ebb003724588e3ed9bee2d2f4a40dbcb4e5c14"
        },
        "index" : 0,
        "chainindex" : 11,
        "merklebranch" : [
            "a965c40043a877f19aff55cdb7b4aeb6758eb1d0d50354bbc56487da417d87f6",
            "00c55a17c3902d4fffbb73cf105f9ea1878fa35c28a2e3e8fcf6cd012ccd07b5",
            "73fe25f370dfd405e76b60f7cb449020e61a21badf98a3874e8388a72a4bc938",
            "8e5e3f91e7f83f1b8e8fefdaedd58400cff181a6915105c297e8ad0e22bc50db",
            "05354f432d97fa96f9df91db3f1076ddadafd6d1dd07edd3f8fbade41600e271",
            "fca389690b311eb7956a89aec770e5a1f83a4ce5986ada7cb64c51938d023616",
            "7df17af53f9d6eee0a6e0b5f10767fc2968defff48d842549069902b60eea42b",
            "bfe8968c0f8be6e24e35763a86d532e4b001553a40964e5f30f6227d49a1e880",
            "0b868f467910e8c13cd37768d2dd862266feb9ed5b102c772720b4d71b362af5",
            "de4b60b438ed8911e4ec7b49d7cfebc49e522f124e75d0cd57cca50f84cd224c"
        ],
        "chainmerklebranch" : [
            "000000000000000000000000000000000000000000000000000000000000000a",
            "c3fddb1013f670f8fce68b8526c18adae3a7af32881050d5fbe270c048d81c67",
            "9d2ed3d67aadc96a850915606c88516cdd831f5ff10b92ca5927709d94c77e9f",
            "008e33cde7fe18e179b242069d862f522e0aa076b4ff5d89ac983e69c50c7067"
        ],
        "parentblock" : "02000000160ff099d70aa2a465b98d0fcfa4dc857163162f1e8e63100000000000000000878c3efb32dfd9a435faea0f929d5fcb3474437ffbbc2eab76a5b59ad9adeb1c555e345493b81f18627b8c93"
    },
Please let me know if you have any objections to pushing this code to Namecoin Core.
BTC: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | NMC: NCdomobcmcmVdxC5yxMitojQ4tvAtv99pY
BM-GtQnWM3vcdorfqpKXsmfHQ4rVYPG5pKS
Use your Namecoin identity as OpenID: https://nameid.org/

phelix
Posts: 1634
Joined: Thu Aug 18, 2011 6:59 am

Re: RPC interface for accessing auxpow data

Post by phelix »

Ugh the long lines destroy readability on this forum.

It would be great if we could make an API server offer data that proves that a significant amount of work has been piled upon a name tx.
Or do you have something different in mind?

Unfortunately I can't dive into this atm so I trust your judgement.
nx.bit - some namecoin stats
nf.bit - shortcut to this forum

phelix
Posts: 1634
Joined: Thu Aug 18, 2011 6:59 am

Re: RPC interface for accessing auxpow data

Post by phelix »

btw: I have an old messy python snippet that calculates the merkle tree from TXIDs and
hashes the block header in case you or anybody is interested. With auxpow added it should be a start.
nx.bit - some namecoin stats
nf.bit - shortcut to this forum

domob
Posts: 1129
Joined: Mon Jun 24, 2013 11:27 am
Contact:

Re: RPC interface for accessing auxpow data

Post by domob »

phelix wrote:btw: I have an old messy python snippet that calculates the merkle tree from TXIDs and
hashes the block header in case you or anybody is interested. With auxpow added it should be a start.
I've written something like this myself recently. It takes a name tx and writes out a Python script that hashes the name value together with a lot of constants to produce a Bitcoin block hash. This can be used to link Namecoin timestamps directly to Bitcoin.

But you can use it also, like you suggest, to provide "proof" that massive PoW has been put onto a name value - haven't thought about this so far! I'll publish and officially announce the project soon. Then we could try to recycle it to allow also such a proving API server.
BTC: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | NMC: NCdomobcmcmVdxC5yxMitojQ4tvAtv99pY
BM-GtQnWM3vcdorfqpKXsmfHQ4rVYPG5pKS
Use your Namecoin identity as OpenID: https://nameid.org/

domob
Posts: 1129
Joined: Mon Jun 24, 2013 11:27 am
Contact:

Re: RPC interface for accessing auxpow data

Post by domob »

Pushed the commit now.
BTC: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | NMC: NCdomobcmcmVdxC5yxMitojQ4tvAtv99pY
BM-GtQnWM3vcdorfqpKXsmfHQ4rVYPG5pKS
Use your Namecoin identity as OpenID: https://nameid.org/

Post Reply