lnutil: add htlc witness_script templates for anchors
extracted from https://github.com/spesmilo/electrum/pull/9628
This commit is contained in:
@@ -858,67 +858,89 @@ def make_received_htlc(
|
|||||||
return script
|
return script
|
||||||
|
|
||||||
|
|
||||||
WITNESS_TEMPLATE_OFFERED_HTLC = [
|
def witness_template_offered_htlc(anchors):
|
||||||
opcodes.OP_DUP,
|
return [
|
||||||
opcodes.OP_HASH160,
|
opcodes.OP_DUP,
|
||||||
OPPushDataGeneric(None),
|
opcodes.OP_HASH160,
|
||||||
opcodes.OP_EQUAL,
|
OPPushDataGeneric(None),
|
||||||
opcodes.OP_IF,
|
opcodes.OP_EQUAL,
|
||||||
opcodes.OP_CHECKSIG,
|
opcodes.OP_IF,
|
||||||
opcodes.OP_ELSE,
|
opcodes.OP_CHECKSIG,
|
||||||
OPPushDataGeneric(None),
|
opcodes.OP_ELSE,
|
||||||
opcodes.OP_SWAP,
|
OPPushDataGeneric(None),
|
||||||
opcodes.OP_SIZE,
|
opcodes.OP_SWAP,
|
||||||
OPPushDataGeneric(lambda x: x==1),
|
opcodes.OP_SIZE,
|
||||||
opcodes.OP_EQUAL,
|
OPPushDataGeneric(lambda x: x==1),
|
||||||
opcodes.OP_NOTIF,
|
opcodes.OP_EQUAL,
|
||||||
opcodes.OP_DROP,
|
opcodes.OP_NOTIF,
|
||||||
opcodes.OP_2,
|
opcodes.OP_DROP,
|
||||||
opcodes.OP_SWAP,
|
opcodes.OP_2,
|
||||||
OPPushDataGeneric(None),
|
opcodes.OP_SWAP,
|
||||||
opcodes.OP_2,
|
OPPushDataGeneric(None),
|
||||||
opcodes.OP_CHECKMULTISIG,
|
opcodes.OP_2,
|
||||||
opcodes.OP_ELSE,
|
opcodes.OP_CHECKMULTISIG,
|
||||||
opcodes.OP_HASH160,
|
opcodes.OP_ELSE,
|
||||||
OPPushDataGeneric(None),
|
opcodes.OP_HASH160,
|
||||||
opcodes.OP_EQUALVERIFY,
|
OPPushDataGeneric(None),
|
||||||
opcodes.OP_CHECKSIG,
|
opcodes.OP_EQUALVERIFY,
|
||||||
opcodes.OP_ENDIF,
|
opcodes.OP_CHECKSIG,
|
||||||
opcodes.OP_ENDIF,
|
opcodes.OP_ENDIF,
|
||||||
]
|
] + ([
|
||||||
|
opcodes.OP_1,
|
||||||
|
opcodes.OP_CHECKSEQUENCEVERIFY,
|
||||||
|
opcodes.OP_DROP,
|
||||||
|
] if anchors else [
|
||||||
|
]) + [
|
||||||
|
opcodes.OP_ENDIF,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
WITNESS_TEMPLATE_RECEIVED_HTLC = [
|
WITNESS_TEMPLATE_OFFERED_HTLC = witness_template_offered_htlc(anchors=False)
|
||||||
opcodes.OP_DUP,
|
WITNESS_TEMPLATE_OFFERED_HTLC_ANCHORS = witness_template_offered_htlc(anchors=True)
|
||||||
opcodes.OP_HASH160,
|
|
||||||
OPPushDataGeneric(None),
|
|
||||||
opcodes.OP_EQUAL,
|
def witness_template_received_htlc(anchors):
|
||||||
opcodes.OP_IF,
|
return [
|
||||||
opcodes.OP_CHECKSIG,
|
opcodes.OP_DUP,
|
||||||
opcodes.OP_ELSE,
|
opcodes.OP_HASH160,
|
||||||
OPPushDataGeneric(None),
|
OPPushDataGeneric(None),
|
||||||
opcodes.OP_SWAP,
|
opcodes.OP_EQUAL,
|
||||||
opcodes.OP_SIZE,
|
opcodes.OP_IF,
|
||||||
OPPushDataGeneric(lambda x: x==1),
|
opcodes.OP_CHECKSIG,
|
||||||
opcodes.OP_EQUAL,
|
opcodes.OP_ELSE,
|
||||||
opcodes.OP_IF,
|
OPPushDataGeneric(None),
|
||||||
opcodes.OP_HASH160,
|
opcodes.OP_SWAP,
|
||||||
OPPushDataGeneric(None),
|
opcodes.OP_SIZE,
|
||||||
opcodes.OP_EQUALVERIFY,
|
OPPushDataGeneric(lambda x: x==1),
|
||||||
opcodes.OP_2,
|
opcodes.OP_EQUAL,
|
||||||
opcodes.OP_SWAP,
|
opcodes.OP_IF,
|
||||||
OPPushDataGeneric(None),
|
opcodes.OP_HASH160,
|
||||||
opcodes.OP_2,
|
OPPushDataGeneric(None),
|
||||||
opcodes.OP_CHECKMULTISIG,
|
opcodes.OP_EQUALVERIFY,
|
||||||
opcodes.OP_ELSE,
|
opcodes.OP_2,
|
||||||
opcodes.OP_DROP,
|
opcodes.OP_SWAP,
|
||||||
OPPushDataGeneric(None),
|
OPPushDataGeneric(None),
|
||||||
opcodes.OP_CHECKLOCKTIMEVERIFY,
|
opcodes.OP_2,
|
||||||
opcodes.OP_DROP,
|
opcodes.OP_CHECKMULTISIG,
|
||||||
opcodes.OP_CHECKSIG,
|
opcodes.OP_ELSE,
|
||||||
opcodes.OP_ENDIF,
|
opcodes.OP_DROP,
|
||||||
opcodes.OP_ENDIF,
|
OPPushDataGeneric(None),
|
||||||
]
|
opcodes.OP_CHECKLOCKTIMEVERIFY,
|
||||||
|
opcodes.OP_DROP,
|
||||||
|
opcodes.OP_CHECKSIG,
|
||||||
|
opcodes.OP_ENDIF,
|
||||||
|
] + ([
|
||||||
|
opcodes.OP_1,
|
||||||
|
opcodes.OP_CHECKSEQUENCEVERIFY,
|
||||||
|
opcodes.OP_DROP,
|
||||||
|
] if anchors else [
|
||||||
|
]) + [
|
||||||
|
opcodes.OP_ENDIF,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
WITNESS_TEMPLATE_RECEIVED_HTLC = witness_template_received_htlc(anchors=False)
|
||||||
|
WITNESS_TEMPLATE_RECEIVED_HTLC_ANCHORS = witness_template_received_htlc(anchors=True)
|
||||||
|
|
||||||
|
|
||||||
def make_htlc_output_witness_script(
|
def make_htlc_output_witness_script(
|
||||||
|
|||||||
Reference in New Issue
Block a user