Default expression for "sigmsg": depending on mode, compute BIP341, BIP143, or legacy sigmsg.
(ctx)
| 236 | assert False |
| 237 | |
| 238 | def default_sigmsg(ctx): |
| 239 | """Default expression for "sigmsg": depending on mode, compute BIP341, BIP143, or legacy sigmsg.""" |
| 240 | tx = get(ctx, "tx") |
| 241 | idx = get(ctx, "idx") |
| 242 | hashtype = get(ctx, "hashtype_actual") |
| 243 | mode = get(ctx, "mode") |
| 244 | if mode == "taproot": |
| 245 | # BIP341 signature hash |
| 246 | utxos = get(ctx, "utxos") |
| 247 | annex = get(ctx, "annex") |
| 248 | if get(ctx, "leaf") is not None: |
| 249 | codeseppos = get(ctx, "codeseppos") |
| 250 | leaf_ver = get(ctx, "leafversion") |
| 251 | script = get(ctx, "script_taproot") |
| 252 | return TaprootSignatureMsg(tx, utxos, hashtype, idx, scriptpath=True, leaf_script=script, leaf_ver=leaf_ver, codeseparator_pos=codeseppos, annex=annex) |
| 253 | else: |
| 254 | return TaprootSignatureMsg(tx, utxos, hashtype, idx, scriptpath=False, annex=annex) |
| 255 | elif mode == "witv0": |
| 256 | # BIP143 signature hash |
| 257 | scriptcode = get(ctx, "scriptcode_suffix") |
| 258 | utxos = get(ctx, "utxos") |
| 259 | return SegwitV0SignatureMsg(scriptcode, tx, idx, hashtype, utxos[idx].nValue) |
| 260 | else: |
| 261 | # Pre-segwit signature hash |
| 262 | scriptcode = get(ctx, "scriptcode_suffix") |
| 263 | return LegacySignatureMsg(scriptcode, tx, idx, hashtype)[0] |
| 264 | |
| 265 | def default_sighash(ctx): |
| 266 | """Default expression for "sighash": depending on mode, compute tagged hash or dsha256 of sigmsg.""" |
nothing calls this directly
no test coverage detected