dgpv / bsst

B'SST: Bitcoin-like Script Symbolic Tracer
Other
34 stars 5 forks source link

Maybe restrict introspected scriptpubkey and witness version when --is-miner=false ? #27

Closed dgpv closed 6 months ago

dgpv commented 9 months ago

Right now they are not restricted, but actually they will be restricted in practice.

Output witness version and scriptpubkey size will be restricted by standardness check called in IsStandardTx() Input witness version and scriptpubkey size will be restricted by VerifyWitnessProgram() checking them, and acting on SCRIPT_ERR_DISCOURAGE_UPGRADABLE_* flag values, which will be set for the non-miner.

It might be not entirely correct to add --discourage-upgradable-witness-program-flag setting, because unlike for inputs, the output witness version and scriptpubkey length restriction in the reference source do not depend on that flag, but rather on the fRequireStandard boolean variable.

Might just set these restrictions for --is-miner=false and add a note to README that SCRIPT_ERR_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM is not referenced exactly, but the behavior is modeled via --is-miner setting.

dgpv commented 9 months ago

Is this safe to do for arbitrary input ? Could it be possible that an input might be spendable regardless of the fact that its witness version and witness program size violates these restrictions ? I cannot think of any such possibilities, but need to check that to make sure.

dgpv commented 8 months ago

No need to model SCRIPT_ERR_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM. Output sciptpubkeys are also not restricted by fRequireStandard=True, because IsStandard() does not treat TxoutType::WITNESS_UNKNOWN as non-standard.

so these restrictions are only applicable for inptus in non-miner mode

dgpv commented 6 months ago

Done in https://github.com/dgpv/bsst/commit/fb13cfca6d027fe2bc5a21b1225f0576e318288d