| | 1 | | using NBitcoin; |
| | 2 | |
|
| | 3 | | namespace NLightning.Infrastructure.Bitcoin.Outputs; |
| | 4 | |
|
| | 5 | | using Domain.Money; |
| | 6 | |
|
| | 7 | | public class HtlcResolutionOutput : BaseOutput |
| | 8 | | { |
| 0 | 9 | | public override ScriptType ScriptType => ScriptType.P2WSH; |
| | 10 | |
|
| 0 | 11 | | public PubKey RevocationPubKey { get; } |
| 0 | 12 | | public PubKey LocalDelayedPubKey { get; } |
| 0 | 13 | | public ulong ToSelfDelay { get; } |
| | 14 | |
|
| | 15 | | public HtlcResolutionOutput(LightningMoney amount, PubKey localDelayedPubKey, PubKey revocationPubKey, |
| | 16 | | ulong toSelfDelay) |
| 0 | 17 | | : base(amount, GenerateHtlcOutputScript(revocationPubKey, localDelayedPubKey, toSelfDelay)) |
| | 18 | | { |
| 0 | 19 | | RevocationPubKey = revocationPubKey; |
| 0 | 20 | | LocalDelayedPubKey = localDelayedPubKey; |
| 0 | 21 | | ToSelfDelay = toSelfDelay; |
| 0 | 22 | | } |
| | 23 | |
|
| | 24 | | private static Script GenerateHtlcOutputScript(PubKey localDelayedPubKey, PubKey revocationPubKey, |
| | 25 | | ulong toSelfDelay) |
| | 26 | | { |
| 0 | 27 | | return new Script( |
| 0 | 28 | | OpcodeType.OP_IF, |
| 0 | 29 | | Op.GetPushOp(revocationPubKey.ToBytes()), |
| 0 | 30 | | OpcodeType.OP_ELSE, |
| 0 | 31 | | Op.GetPushOp((long)toSelfDelay), |
| 0 | 32 | | OpcodeType.OP_CHECKSEQUENCEVERIFY, |
| 0 | 33 | | OpcodeType.OP_DROP, |
| 0 | 34 | | Op.GetPushOp(localDelayedPubKey.ToBytes()), |
| 0 | 35 | | OpcodeType.OP_ENDIF, |
| 0 | 36 | | OpcodeType.OP_CHECKSIG |
| 0 | 37 | | ); |
| | 38 | | } |
| | 39 | | } |