| | 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(PubKey revocationPubKey, PubKey localDelayedPubKey, ulong toSelfDelay, LightningMoney am |
| 0 | 16 | | : base(GenerateHtlcOutputScript(revocationPubKey, localDelayedPubKey, toSelfDelay), amount) |
| | 17 | | { |
| 0 | 18 | | RevocationPubKey = revocationPubKey; |
| 0 | 19 | | LocalDelayedPubKey = localDelayedPubKey; |
| 0 | 20 | | ToSelfDelay = toSelfDelay; |
| 0 | 21 | | } |
| | 22 | |
|
| | 23 | | private static Script GenerateHtlcOutputScript(PubKey revocationPubKey, PubKey localDelayedPubKey, ulong toSelfDelay |
| | 24 | | { |
| 0 | 25 | | return new Script( |
| 0 | 26 | | OpcodeType.OP_IF, |
| 0 | 27 | | Op.GetPushOp(revocationPubKey.ToBytes()), |
| 0 | 28 | | OpcodeType.OP_ELSE, |
| 0 | 29 | | Op.GetPushOp((long)toSelfDelay), |
| 0 | 30 | | OpcodeType.OP_CHECKSEQUENCEVERIFY, |
| 0 | 31 | | OpcodeType.OP_DROP, |
| 0 | 32 | | Op.GetPushOp(localDelayedPubKey.ToBytes()), |
| 0 | 33 | | OpcodeType.OP_ENDIF, |
| 0 | 34 | | OpcodeType.OP_CHECKSIG |
| 0 | 35 | | ); |
| | 36 | | } |
| | 37 | | } |