@@ -379,6 +379,36 @@ Value getblocktemplate(const Array& params, bool fHelp)
379
379
else
380
380
throw JSONRPCError (RPC_INVALID_PARAMETER, " Invalid mode" );
381
381
lpval = find_value (oparam, " longpollid" );
382
+
383
+ if (strMode == " proposal" )
384
+ {
385
+ const Value& dataval = find_value (oparam, " data" );
386
+ if (dataval.type () != str_type)
387
+ throw JSONRPCError (RPC_TYPE_ERROR, " Missing data String key for proposal" );
388
+
389
+ CBlock block;
390
+ if (!DecodeHexBlk (block, dataval.get_str ()))
391
+ throw JSONRPCError (RPC_DESERIALIZATION_ERROR, " Block decode failed" );
392
+
393
+ uint256 hash = block.GetHash ();
394
+ BlockMap::iterator mi = mapBlockIndex.find (hash);
395
+ if (mi != mapBlockIndex.end ()) {
396
+ CBlockIndex *pindex = mi->second ;
397
+ if (pindex->IsValid (BLOCK_VALID_SCRIPTS))
398
+ return " duplicate" ;
399
+ if (pindex->nStatus & BLOCK_FAILED_MASK)
400
+ return " duplicate-invalid" ;
401
+ return " duplicate-inconclusive" ;
402
+ }
403
+
404
+ CBlockIndex* const pindexPrev = chainActive.Tip ();
405
+ // TestBlockValidity only supports blocks built on the current Tip
406
+ if (block.hashPrevBlock != pindexPrev->GetBlockHash ())
407
+ return " inconclusive-not-best-prevblk" ;
408
+ CValidationState state;
409
+ TestBlockValidity (state, block, pindexPrev, false , true );
410
+ return BIP22ValidationResult (state);
411
+ }
382
412
}
383
413
384
414
if (strMode != " template" )
@@ -481,6 +511,8 @@ Value getblocktemplate(const Array& params, bool fHelp)
481
511
UpdateTime (pblock, pindexPrev);
482
512
pblock->nNonce = 0 ;
483
513
514
+ static const Array aCaps = boost::assign::list_of (" proposal" );
515
+
484
516
Array transactions;
485
517
map<uint256, int64_t > setTxIndex;
486
518
int i = 0 ;
@@ -527,6 +559,7 @@ Value getblocktemplate(const Array& params, bool fHelp)
527
559
}
528
560
529
561
Object result;
562
+ result.push_back (Pair (" capabilities" , aCaps));
530
563
result.push_back (Pair (" version" , pblock->nVersion ));
531
564
result.push_back (Pair (" previousblockhash" , pblock->hashPrevBlock .GetHex ()));
532
565
result.push_back (Pair (" transactions" , transactions));
0 commit comments