Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
252PSBTOutput UpdateOutput(bool has_input) const253{254CMutableTransaction tx;255if (has_input) tx.vin.emplace_back();256tx.vout.emplace_back(0, script_pubkey);257PartiallySignedTransaction psbt{tx};258UpdatePSBTOutput(provider, psbt, 0);259return psbt.outputs[0];260}261};263BOOST_AUTO_TEST_CASE(update_psbt_output_keypaths)264{265for (bool has_input : {false, true}) {266for (const auto& descriptor : {"pkh(<KEY>)", "wpkh(<KEY>)"}) {267PSBTOutputTest test{descriptor};268auto out{test.UpdateOutput(has_input)};269BOOST_CHECK(out.hd_keypaths.contains(test.pubkey));270BOOST_CHECK(out.redeem_script.empty());271BOOST_CHECK(out.witness_script.empty());272}273}274}276BOOST_AUTO_TEST_CASE(update_psbt_output_redeem_script)277{278for (bool has_input : {false, true}) {279PSBTOutputTest test{"sh(wpkh(<KEY>))"};280auto out{test.UpdateOutput(has_input)};281BOOST_CHECK(out.redeem_script == GetScriptForDestination(WitnessV0KeyHash{test.pubkey}));282BOOST_CHECK(out.hd_keypaths.contains(test.pubkey));283}284}286BOOST_AUTO_TEST_CASE(update_psbt_output_witness_script)287{288for (bool has_input : {false, true}) {289PSBTOutputTest test{"wsh(pk(<KEY>))"};290auto out{test.UpdateOutput(has_input)};291BOOST_CHECK(out.witness_script == GetScriptForRawPubKey(test.pubkey));292BOOST_CHECK(out.hd_keypaths.contains(test.pubkey));293}294}296BOOST_AUTO_TEST_CASE(update_psbt_output_miniscript_timelock)297{298for (bool has_input : {false, true}) {299PSBTOutputTest test{"wsh(and_v(v:pk(<KEY>),older(144)))"};300auto out{test.UpdateOutput(has_input)};301BOOST_CHECK(GetScriptForDestination(WitnessV0ScriptHash{out.witness_script}) == test.script_pubkey);302BOOST_CHECK(out.hd_keypaths.contains(test.pubkey));303}304}306BOOST_AUTO_TEST_CASE(update_psbt_output_taproot)307{308for (bool has_input : {false, true}) {309PSBTOutputTest test{"rawtr(<KEY>)"};310auto out{test.UpdateOutput(has_input)};311BOOST_CHECK(out.m_tap_bip32_paths.contains(XOnlyPubKey{test.pubkey}));312BOOST_CHECK(out.hd_keypaths.empty());313}314}316BOOST_AUTO_TEST_SUITE_END()
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.