(self)
| 128 | assert_raises_rpc_error(-26, error_msg, send_to_witness, use_p2wsh=1, node=node, utxo=getutxo(txid), pubkey=self.pubkey[0], encode_p2sh=False, amount=Decimal("49.998"), sign=sign, insert_redeem_script=redeem_script) |
| 129 | |
| 130 | def run_test(self): |
| 131 | self.generate(self.nodes[0], 161) # block 161 |
| 132 | |
| 133 | self.log.info("Verify sigops are counted in GBT with pre-BIP141 rules before the fork") |
| 134 | txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1) |
| 135 | tmpl = self.nodes[0].getblocktemplate({'rules': ['segwit']}) |
| 136 | assert_equal(tmpl['sizelimit'], 1000000) |
| 137 | assert 'weightlimit' not in tmpl |
| 138 | assert_equal(tmpl['sigoplimit'], 20000) |
| 139 | assert_equal(tmpl['transactions'][0]['hash'], txid) |
| 140 | assert_equal(tmpl['transactions'][0]['sigops'], 2) |
| 141 | assert '!segwit' not in tmpl['rules'] |
| 142 | self.generate(self.nodes[0], 1) # block 162 |
| 143 | |
| 144 | balance_presetup = self.nodes[0].getbalance()['bitcoin'] |
| 145 | self.pubkey = [] |
| 146 | p2sh_ids = [] # p2sh_ids[NODE][TYPE] is an array of txids that spend to P2WPKH (TYPE=0) or P2WSH (TYPE=1) scripts to an address for NODE embedded in p2sh |
| 147 | wit_ids = [] # wit_ids[NODE][TYPE] is an array of txids that spend to P2WPKH (TYPE=0) or P2WSH (TYPE=1) scripts to an address for NODE via bare witness |
| 148 | for i in range(3): |
| 149 | key = get_generate_key() |
| 150 | self.pubkey.append(key.pubkey) |
| 151 | |
| 152 | multiscript = keys_to_multisig_script([self.pubkey[-1]]) |
| 153 | p2sh_ms_addr = self.nodes[i].createmultisig(1, [self.pubkey[-1]], 'p2sh-segwit')['address'] |
| 154 | bip173_ms_addr = self.nodes[i].createmultisig(1, [self.pubkey[-1]], 'bech32')['address'] |
| 155 | assert_equal(p2sh_ms_addr, script_to_p2sh_p2wsh(multiscript)) |
| 156 | assert_equal(bip173_ms_addr, script_to_p2wsh(multiscript)) |
| 157 | |
| 158 | p2sh_ms_desc = descsum_create(f"sh(wsh(multi(1,{key.privkey})))") |
| 159 | bip173_ms_desc = descsum_create(f"wsh(multi(1,{key.privkey}))") |
| 160 | assert_equal(self.nodes[i].deriveaddresses(p2sh_ms_desc)[0], p2sh_ms_addr) |
| 161 | assert_equal(self.nodes[i].deriveaddresses(bip173_ms_desc)[0], bip173_ms_addr) |
| 162 | |
| 163 | sh_wpkh_desc = descsum_create(f"sh(wpkh({key.privkey}))") |
| 164 | wpkh_desc = descsum_create(f"wpkh({key.privkey})") |
| 165 | assert_equal(self.nodes[i].deriveaddresses(sh_wpkh_desc)[0], key.p2sh_p2wpkh_addr) |
| 166 | assert_equal(self.nodes[i].deriveaddresses(wpkh_desc)[0], key.p2wpkh_addr) |
| 167 | |
| 168 | if self.options.descriptors: |
| 169 | res = self.nodes[i].importdescriptors([ |
| 170 | {"desc": p2sh_ms_desc, "timestamp": "now"}, |
| 171 | {"desc": bip173_ms_desc, "timestamp": "now"}, |
| 172 | {"desc": sh_wpkh_desc, "timestamp": "now"}, |
| 173 | {"desc": wpkh_desc, "timestamp": "now"}, |
| 174 | ]) |
| 175 | else: |
| 176 | # The nature of the legacy wallet is that this import results in also adding all of the necessary scripts |
| 177 | res = self.nodes[i].importmulti([ |
| 178 | {"desc": p2sh_ms_desc, "timestamp": "now"}, |
| 179 | ]) |
| 180 | assert all([r["success"] for r in res]) |
| 181 | |
| 182 | p2sh_ids.append([]) |
| 183 | wit_ids.append([]) |
| 184 | for _ in range(2): |
| 185 | p2sh_ids[i].append([]) |
| 186 | wit_ids[i].append([]) |
| 187 |
nothing calls this directly
no test coverage detected