I've cloned litecoin 0.21, trying to create a new coin. It was running well until block 1439. Then, miners stopped working because getblocktemplate was returning this:
CreateNewBlock: TestBlockValidity failed: bad-txns-vin-empty, Transaction check failed (tx hash 7f77894ebcb3xxxx)
In code, it's like this:
if (!tx.IsMWEBOnly()) {
if (tx.vin.empty())
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-txns-vin-empty");
I was unable to find the related transaction with getrawtransaction on a node with -txindex. Then I modified code to skip the tx.vin.empty check. getblocktemplate worked, I was able to mine but other nodes rejected it naturally. After that I was able to get the raw transaction:
{
"txid": "7f77894ebcb37xxxx",
"hash": "7f77894ebcb37xxxx",
"version": 2,
"size": 56,
"vsize": 53,
"weight": 212,
"locktime": 0,
"vin": [
],
"vout": [
{
"ismweb": false,
"value": 0.00000000,
"n": 0,
"scriptPubKey": {
"asm": "8 32a71ad39691052a88bxxxxxx",
"hex": "582032a71ad39691052a88bxxxxx",
"type": "witness_mweb_hogaddr"
}
}
]
}
Decoding script gave following results:
$ decodescript 582032a71ad39691052axxxxx
{
"asm": "8 32a71ad3969105xxxxx",
"type": "witness_mweb_hogaddr",
"p2sh": "CeRHKxxxxx"
}
$ decodescript 32a71ad39691052a88bfeb9fxxxxx
{
"asm": "[error]",
"type": "nonstandard",
"p2sh": "CaiSWTDxxxxx",
"segwit": {
"asm": "0 c0ce9f7xxxxxxxxx",
"hex": "0020c0cexxxxxxxx",
"reqSigs": 1,
"type": "witness_v0_scripthash",
"addresses": [
"mycoin1qcr8f7ut3gsy022rruydxxxxxxxxx"
],
"p2sh-segwit": "CcDNqxxxxxxxx"
}
}
Transaction vout says "ismweb": false but vin is empty and pubkey is witness_mweb_hogaddr, meaning it should be true instead?
Could this be a bug? How should I approach this issue? My best guess is editing chainparams.cpp and editing mweb activation caused this issue:
consensus.vDeployments[Consensus::DEPLOYMENT_MWEB].bit = 4;
consensus.vDeployments[Consensus::DEPLOYMENT_MWEB].nStartHeight = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_MWEB].nTimeoutHeight = 0;
Oh also, I'm getting this when sending a tx:
$ createrawtransaction "[{\"txid\":\"83e01378c82fe86a0cebb8ad063764xxxxxxx\",\"vout\":0}]" "[{\"mycoin1qjqmp2rssgkp5gdexxxxx\":100.5}]"
0200000001d67e79dd60e5dexxxxxxx
$ signrawtransactionwithwallet 0200000001d67e79dd60e5ded6xxxxxxx
Missing amount for CTxOut(nValue=100000000.00000000, scriptPubKey=0014cb0c40a27192xxxx) (code -3)
$ decodescript 0014cb0c40a27xxxx

{
"asm": "0 [error]",
"type": "nonstandard",
"p2sh": "CNaVj7QRiXN5TYxxxxx",
"segwit": {
"asm": "0 23e055958bec23xxxxxxxx",
"hex": "002023e055958bxxxxxxxxx",
"reqSigs": 1,
"type": "witness_v0_scripthash",
"addresses": [
"mycoin1qy0s9t9vtas3hycvufadz6a9e4lxxxxx"
],
"p2sh-segwit": "CSaK1duFt2Fxxxxx"
}
}
Note that I've tried with 99,999,999 coins (input minus 1 coin) and still getting the same issue so it's not about the huge fee.
And IDK if it's relevant, but some more configurations here from chainparams.cpp:
consensus.nSubsidyHalvingInterval = 840000;
consensus.BIP16Height = 0;
consensus.BIP34Height = 0;
consensus.BIP34Hash = uint256S("0xfa09d204a83a7xxxxxxxx");
consensus.BIP65Height = 0;
consensus.BIP66Height = 0;
consensus.CSVHeight = 0;
consensus.SegwitHeight = 0;
consensus.MinBIP9WarningHeight = 0; // segwit activation height + miner confirmation window
consensus.powLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.nPowTargetTimespan = 3 * 60 * 60; // 3hrs
consensus.nPowTargetSpacing = 1.5 * 60;
consensus.fPowAllowMinDifficultyBlocks = false;
consensus.fPowNoRetargeting = false;
consensus.nRuleChangeActivationThreshold = 6048; // 75% of 8064
consensus.nMinerConfirmationWindow = 480; // nPowTargetTimespan / nPowTargetSpacing * 4
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = Consensus::BIP9Deployment::NEVER_ACTIVE;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
Really appreciate the help!