| | 1 | | using NBitcoin; |
| | 2 | | using NBitcoin.Crypto; |
| | 3 | |
|
| | 4 | | namespace NLightning.Infrastructure.Bitcoin.Transactions; |
| | 5 | |
|
| | 6 | | using Domain.Money; |
| | 7 | | using Domain.Protocol.Constants; |
| | 8 | | using Outputs; |
| | 9 | |
|
| | 10 | | public abstract class BaseHtlcTransaction : BaseTransaction |
| | 11 | | { |
| 0 | 12 | | public HtlcResolutionOutput HtlcResolutionOutput { get; } |
| | 13 | |
|
| | 14 | | protected BaseHtlcTransaction(bool hasAnchorOutputs, Network network, BaseHtlcOutput htlcOutput, PubKey revocationPu |
| | 15 | | PubKey localDelayedPubKey, ulong toSelfDelay, ulong amountMilliSats) |
| 0 | 16 | | : base(hasAnchorOutputs, network, TransactionConstants.HTLC_TRANSACTION_VERSION, |
| 0 | 17 | | hasAnchorOutputs |
| 0 | 18 | | ? SigHash.Single | SigHash.AnyoneCanPay |
| 0 | 19 | | : SigHash.All, |
| 0 | 20 | | (htlcOutput.ToCoin(), new Sequence(hasAnchorOutputs ? 1 : 0))) |
| | 21 | | { |
| 0 | 22 | | HtlcResolutionOutput = new HtlcResolutionOutput(revocationPubKey, localDelayedPubKey, toSelfDelay, amountMilliSa |
| 0 | 23 | | } |
| | 24 | |
|
| | 25 | | internal override void ConstructTransaction(LightningMoney currentFeePerKw) |
| | 26 | | { |
| | 27 | | // Calculate transaction fee |
| 0 | 28 | | CalculateTransactionFee(currentFeePerKw); |
| | 29 | |
|
| 0 | 30 | | HtlcResolutionOutput.Amount -= CalculatedFee; |
| | 31 | |
|
| 0 | 32 | | AddOrderedOutputsToTransaction(); |
| | 33 | |
|
| 0 | 34 | | HtlcResolutionOutput.TxId = TxId; |
| 0 | 35 | | HtlcResolutionOutput.Index = 0; |
| 0 | 36 | | } |
| | 37 | |
|
| | 38 | | public void AppendRemoteSignatureAndSign(ECDSASignature remoteSignature, PubKey remotePubKey) |
| | 39 | | { |
| 0 | 40 | | AppendRemoteSignatureToTransaction(new TransactionSignature(remoteSignature), remotePubKey); |
| 0 | 41 | | SignTransactionWithExistingKeys(); |
| 0 | 42 | | } |
| | 43 | | } |