sugarchain-project / yumekawa

[TEST] Yumekawa 2.0 Taproot
MIT License
6 stars 5 forks source link

Signet generate null block #37

Open decryp2kanon opened 4 years ago

decryp2kanon commented 4 years ago
$ ./src/qt/sugarchain-qt -datadir=../yumekawa-test-201012/ -server=1 -rpcuser=1 -rpcpassword=2 -printtoconsole -signet -debug=validation

2020-10-13T05:43:32Z CreateNewBlock(): block weight: 884 txs: 0 fees: 0 sigops 400
2020-10-13T05:43:32Z CheckSignetBlockSolution: Errors in block (block solution invalid)
2020-10-13T05:43:32Z BlockChecked: block hash=bdfd4816a02d45a7dbb2f215d30095f849c50d521d7f3c92947d44efd178b3bf state=bad-signet-blksig, signet block signature validation failure
2020-10-13T05:43:32Z ERROR: ProcessNewBlock: AcceptBlock FAILED (bad-signet-blksig, signet block signature validation failure)
$ ./src/sugarchain-cli -rpcuser=1 -rpcpassword=2 -generate -signet
{
  "address": "tb1qwqy85556fkpn7cc9k0zw2fc2shxsesclg8ghwm",
  "blocks": null
}
decryp2kanon commented 4 years ago
// Signet block solution checker
bool CheckSignetBlockSolution(const CBlock& block, const Consensus::Params& consensusParams)
{
    if (block.GetHash() == consensusParams.hashGenesisBlock) {
        // genesis block solution is always valid
        return true;
    }

    const CScript challenge(consensusParams.signet_challenge.begin(), consensusParams.signet_challenge.end());
    const Optional<SignetTxs> signet_txs = SignetTxs::Create(block, challenge);

    if (!signet_txs) {
        LogPrint(BCLog::VALIDATION, "CheckSignetBlockSolution: Errors in block (block solution parse failure)\n");
        return false;
    }

    const CScript& scriptSig = signet_txs->m_to_sign.vin[0].scriptSig;
    const CScriptWitness& witness = signet_txs->m_to_sign.vin[0].scriptWitness;

    TransactionSignatureChecker sigcheck(&signet_txs->m_to_sign, /*nIn=*/ 0, /*amount=*/ signet_txs->m_to_spend.vout[0].nValue);

    if (!VerifyScript(scriptSig, signet_txs->m_to_spend.vout[0].scriptPubKey, &witness, BLOCK_SCRIPT_VERIFY_FLAGS, sigcheck)) {
        LogPrint(BCLog::VALIDATION, "CheckSignetBlockSolution: Errors in block (block solution invalid)\n");
        return false;
    }
    return true;
}
decryp2kanon commented 4 years ago

https://github.com/bitcoin/bips/blob/master/bip-0325.mediawiki

decryp2kanon commented 4 years ago

https://en.bitcoin.it/wiki/Signet