bitcoin-core / btcdeb

Bitcoin Script Debugger

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Examples in btcdeb/doc/btcdeb.md cause an assert abort now?

aglynnej opened this issue · comments

commented

Hi,

This happens since the miniscript support was added in February.
Looks like the p2pkh sequence is recognised and a fake key is created for it by the new code.
Then msenv.cpp re-parses the script (with a new fake address)
And then bombs out at the assert (line 286) when the new hex string of the script doesn't match the old script sans fake key.
The assert is protected by a check for if (COMPILER_CTX.fake_sigs.size() == 0) but this is still true.

The examples all work fine for me if I comment out the assert at line 286 of msenv.cpp.
Including the signature checking example.

I've pasted in what I see on the command line below.

Thanks,
Alan

$ btcdeb '[OP_DUP OP_HASH160 897c81ac37ae36f7bc5b91356cfb0138bfacb3c1 OP_EQUALVERIFY OP_CHECKSIG]' 3045022100c7d8e302908fdc601b125c2734de63ed3bf54353e13a835313c2a2aa5e8f21810220131fad73787989d7fbbdbbd8420674f56bdf61fed5dc2653c826a4789c68501101 03b05bdbdf395e495a61add92442071e32703518b8fca3fc34149db4b56c93be42
btcdeb 0.2.19 -- type btcdeb -h for start up options
unknown key ID 897c81ac37ae36f7bc5b91356cfb0138bfacb3c1: returning fake key
assertion hit: strings different after MSEnv reparsed:
76a914897c81ac37ae36f7bc5b91356cfb0138bfacb3c188ac
76a9141ff85df01e3c8c56fff01c28072dc7bb9d48bfc288ac
btcdeb: msenv.cpp:286: MSEnv::MSEnv(const CScript&, bool): Assertion `HexStr(script) == HexStr(m_script)' failed.
Aborted

Thanks for the detailed report! The assertion was triggering because the compiler context would encounter unknown pubkey-hashes and replace them internally with known ones. I've replaced the assertion with a simple warning, and added an additional condition that there are no auto-generated keys for this to show.

Let me know if the latest master works for you!

commented

Yes - all good now.
The example commands work great again (and don't show me the warning now as you intended).
I see the unknown key ID reported and key generation message which helpfully explains why I then see the generated c:pk_h in the output.

Thanks for your hard work!