MCPcopy Create free account
hub / github.com/ElementsProject/elements / default_sigmsg

Function default_sigmsg

test/functional/feature_taproot.py:238–264  ·  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 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
266def default_sighash(ctx):
267 """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