@@ -97,12 +97,16 @@ UniValue blockheaderToJSON(const CBlockIndex* blockindex)
9797 result.pushKV (" merkleroot" , blockindex->hashMerkleRoot .GetHex ());
9898 result.pushKV (" time" , (int64_t )blockindex->nTime );
9999 result.pushKV (" mediantime" , (int64_t )blockindex->GetMedianTimePast ());
100- result.pushKV (" nonce" , (uint64_t )blockindex->nNonce );
101- result.pushKV (" bits" , strprintf (" %08x" , blockindex->nBits ));
102- result.pushKV (" difficulty" , GetDifficulty (blockindex));
103- result.pushKV (" chainwork" , blockindex->nChainWork .GetHex ());
100+ if (!g_signed_blocks) {
101+ result.pushKV (" nonce" , (uint64_t )blockindex->nNonce );
102+ result.pushKV (" bits" , strprintf (" %08x" , blockindex->nBits ));
103+ result.pushKV (" difficulty" , GetDifficulty (blockindex));
104+ result.pushKV (" chainwork" , blockindex->nChainWork .GetHex ());
105+ } else {
106+ result.pushKV (" signblock_witness_asm" , ScriptToAsmStr (blockindex->proof .solution ));
107+ result.pushKV (" signblock_witness_hex" , HexStr (blockindex->proof .solution ));
108+ }
104109 result.pushKV (" nTx" , (uint64_t )blockindex->nTx );
105-
106110 if (blockindex->pprev )
107111 result.pushKV (" previousblockhash" , blockindex->pprev ->GetBlockHash ().GetHex ());
108112 CBlockIndex *pnext = chainActive.Next (blockindex);
@@ -143,10 +147,16 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx
143147 result.pushKV (" tx" , txs);
144148 result.pushKV (" time" , block.GetBlockTime ());
145149 result.pushKV (" mediantime" , (int64_t )blockindex->GetMedianTimePast ());
146- result.pushKV (" nonce" , (uint64_t )block.nNonce );
147- result.pushKV (" bits" , strprintf (" %08x" , block.nBits ));
148- result.pushKV (" difficulty" , GetDifficulty (blockindex));
149- result.pushKV (" chainwork" , blockindex->nChainWork .GetHex ());
150+ if (!g_signed_blocks) {
151+ result.pushKV (" nonce" , (uint64_t )block.nNonce );
152+ result.pushKV (" bits" , strprintf (" %08x" , block.nBits ));
153+ result.pushKV (" difficulty" , GetDifficulty (blockindex));
154+ result.pushKV (" chainwork" , blockindex->nChainWork .GetHex ());
155+ } else {
156+ result.pushKV (" signblock_witness_asm" , ScriptToAsmStr (blockindex->proof .solution ));
157+ result.pushKV (" signblock_witness_hex" , HexStr (blockindex->proof .solution ));
158+ result.pushKV (" signblock_challenge" , HexStr (blockindex->proof .challenge ));
159+ }
150160 result.pushKV (" nTx" , (uint64_t )blockindex->nTx );
151161
152162 if (blockindex->pprev )
@@ -703,6 +713,8 @@ static UniValue getblockheader(const JSONRPCRequest& request)
703713 " \" difficulty\" : x.xxx, (numeric) The difficulty\n "
704714 " \" chainwork\" : \" 0000...1f3\" (string) Expected number of hashes required to produce the current chain (in hex)\n "
705715 " \" nTx\" : n, (numeric) The number of transactions in the block.\n "
716+ " \" signblock_witness_asm\" : \" xxxx\" , (string) ASM of sign block witness data.\n "
717+ " \" signblock_witness_hex\" : \" xxxx\" , (string) Hex of sign block witness data.\n "
706718 " \" previousblockhash\" : \" hash\" , (string) The hash of the previous block\n "
707719 " \" nextblockhash\" : \" hash\" , (string) The hash of the next block\n "
708720 " }\n "
@@ -792,6 +804,8 @@ static UniValue getblock(const JSONRPCRequest& request)
792804 " \" difficulty\" : x.xxx, (numeric) The difficulty\n "
793805 " \" chainwork\" : \" xxxx\" , (string) Expected number of hashes required to produce the chain up to this block (in hex)\n "
794806 " \" nTx\" : n, (numeric) The number of transactions in the block.\n "
807+ " \" signblock_witness_asm\" : \" xxxx\" , (string) ASM of sign block witness data.\n "
808+ " \" signblock_witness_hex\" : \" xxxx\" , (string) Hex of sign block witness data.\n "
795809 " \" previousblockhash\" : \" hash\" , (string) The hash of the previous block\n "
796810 " \" nextblockhash\" : \" hash\" (string) The hash of the next block\n "
797811 " }\n "
@@ -1198,6 +1212,8 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
11981212 " \" chainwork\" : \" xxxx\" (string) total amount of work in active chain, in hexadecimal\n "
11991213 " \" size_on_disk\" : xxxxxx, (numeric) the estimated size of the block and undo files on disk\n "
12001214 " \" pruned\" : xx, (boolean) if the blocks are subject to pruning\n "
1215+ " \" signblock_asm\" : \" xxxx\" , (string) ASM of sign block challenge data.\n "
1216+ " \" signblock_hex\" : \" xxxx\" , (string) Hex of sign block challenge data.\n "
12011217 " \" pruneheight\" : xxxxxx, (numeric) lowest-height complete block stored (only present if pruning is enabled)\n "
12021218 " \" automatic_pruning\" : xx, (boolean) whether automatic pruning is enabled (only present if pruning is enabled)\n "
12031219 " \" prune_target_size\" : xxxxxx, (numeric) the target size used by pruning (only present if automatic pruning is enabled)\n "
@@ -1235,18 +1251,30 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
12351251
12361252 LOCK (cs_main);
12371253
1254+ const CChainParams& chainparams = Params ();
1255+
12381256 UniValue obj (UniValue::VOBJ);
1239- obj.pushKV (" chain" , Params () .NetworkIDString ());
1257+ obj.pushKV (" chain" , chainparams .NetworkIDString ());
12401258 obj.pushKV (" blocks" , (int )chainActive.Height ());
12411259 obj.pushKV (" headers" , pindexBestHeader ? pindexBestHeader->nHeight : -1 );
12421260 obj.pushKV (" bestblockhash" , chainActive.Tip ()->GetBlockHash ().GetHex ());
1243- obj.pushKV (" difficulty" , (double )GetDifficulty (chainActive.Tip ()));
1261+ if (!g_signed_blocks) {
1262+ obj.pushKV (" difficulty" , (double )GetDifficulty (chainActive.Tip ()));
1263+ }
12441264 obj.pushKV (" mediantime" , (int64_t )chainActive.Tip ()->GetMedianTimePast ());
1245- obj.pushKV (" verificationprogress" , GuessVerificationProgress (Params () .TxData (), chainActive.Tip ()));
1265+ obj.pushKV (" verificationprogress" , GuessVerificationProgress (chainparams .TxData (), chainActive.Tip ()));
12461266 obj.pushKV (" initialblockdownload" , IsInitialBlockDownload ());
1247- obj.pushKV (" chainwork" , chainActive.Tip ()->nChainWork .GetHex ());
1267+ if (!g_signed_blocks) {
1268+ obj.pushKV (" chainwork" , chainActive.Tip ()->nChainWork .GetHex ());
1269+ }
12481270 obj.pushKV (" size_on_disk" , CalculateCurrentUsage ());
12491271 obj.pushKV (" pruned" , fPruneMode );
1272+ if (g_signed_blocks) {
1273+ CScript sign_block_script = chainparams.GetConsensus ().signblockscript ;
1274+ obj.pushKV (" signblock_asm" , ScriptToAsmStr (sign_block_script));
1275+ obj.pushKV (" signblock_hex" , HexStr (sign_block_script));
1276+ }
1277+
12501278 if (fPruneMode ) {
12511279 CBlockIndex* block = chainActive.Tip ();
12521280 assert (block);
0 commit comments