Taproot activates in about 19 days (2716 blocks), and it’d be nice if we set a good example and also support it in our MiniWallet. This PR changes the default mode from P2WSH (segwit v0 output, bech32 address) to P2TR (segwit v1 output, bech32m address) transactions type with the anyone-can-spend policy, i.e. a witness script of OP_TRUE
. The transition is actually quite painless, one only needs one extra piece in the form of a internal public key that is passed in the control block on the witness stack, in order to trigger script-path spending. To keep things simple, the lowest possible valid x-only-public key with the value of 1 was chosen as internal key.
Since many tests expect to find outputs for the default scriptPubKey of MiniWallet in the pre-mined chain of the test framework, the generation address is also changed from ADDRESS_BCRT1_P2WSH_OP_TRUE
to create_deterministic_address_bcrt1_p2tr_op_true()[0]
accordingly (see method BitcoinTestFramework._initialize_chain(...)
). Note that the pre-mined chain is cached locally, so you probably have to delete the ./test/cache
folder first for the tests to pass again.
In order to avoid unnecessary renames, the import of ADDRESS_BCRT1_P2WSH_OP_TRUE
is eliminated in rpc_blockchain.py by generating blocks directly to the MiniWallet address by using the self.generate(self.wallet, ...)
interface (see first commit).