MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / default_sigmsg

Function default_sigmsg

test/functional/feature_taproot.py:238–263  ·  view source on GitHub ↗

Default expression for "sigmsg": depending on mode, compute BIP341, BIP143, or legacy sigmsg.

(ctx)

Source from the content-addressed store, hash-verified

236 assert False
237
238def 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
265def default_sighash(ctx):
266 """Default expression for "sighash": depending on mode, compute tagged hash or dsha256 of sigmsg."""

Callers

nothing calls this directly

Calls 4

TaprootSignatureMsgFunction · 0.90
SegwitV0SignatureMsgFunction · 0.90
LegacySignatureMsgFunction · 0.90
getFunction · 0.85

Tested by

no test coverage detected