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