From 2bc37db61a85586fbc42777a3c20564b626f7d2b Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Tue, 17 Nov 2020 12:50:41 +0100 Subject: [PATCH] lnwallet: export HTLC generating methods --- lnwallet/channel.go | 12 ++++++------ lnwallet/transactions.go | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 25f72a37..792e5c59 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -3022,7 +3022,7 @@ func genRemoteHtlcSigJobs(keyRing *CommitmentKeyRing, Hash: txHash, Index: uint32(htlc.remoteOutputIndex), } - sigJob.Tx, err = createHtlcTimeoutTx( + sigJob.Tx, err = CreateHtlcTimeoutTx( chanType, op, outputAmt, htlc.Timeout, uint32(remoteChanCfg.CsvDelay), keyRing.RevocationKey, keyRing.ToLocalKey, @@ -3075,7 +3075,7 @@ func genRemoteHtlcSigJobs(keyRing *CommitmentKeyRing, Hash: txHash, Index: uint32(htlc.remoteOutputIndex), } - sigJob.Tx, err = createHtlcSuccessTx( + sigJob.Tx, err = CreateHtlcSuccessTx( chanType, op, outputAmt, uint32(remoteChanCfg.CsvDelay), keyRing.RevocationKey, keyRing.ToLocalKey, ) @@ -4119,7 +4119,7 @@ func genHtlcSigValidationJobs(localCommitmentView *commitment, htlcFee := HtlcSuccessFee(chanType, feePerKw) outputAmt := htlc.Amount.ToSatoshis() - htlcFee - successTx, err := createHtlcSuccessTx( + successTx, err := CreateHtlcSuccessTx( chanType, op, outputAmt, uint32(localChanCfg.CsvDelay), keyRing.RevocationKey, keyRing.ToLocalKey, @@ -4173,7 +4173,7 @@ func genHtlcSigValidationJobs(localCommitmentView *commitment, htlcFee := HtlcTimeoutFee(chanType, feePerKw) outputAmt := htlc.Amount.ToSatoshis() - htlcFee - timeoutTx, err := createHtlcTimeoutTx( + timeoutTx, err := CreateHtlcTimeoutTx( chanType, op, outputAmt, htlc.Timeout, uint32(localChanCfg.CsvDelay), keyRing.RevocationKey, keyRing.ToLocalKey, @@ -5689,7 +5689,7 @@ func newOutgoingHtlcResolution(signer input.Signer, // With the fee calculated, re-construct the second level timeout // transaction. - timeoutTx, err := createHtlcTimeoutTx( + timeoutTx, err := CreateHtlcTimeoutTx( chanType, op, secondLevelOutputAmt, htlc.RefundTimeout, csvDelay, keyRing.RevocationKey, keyRing.ToLocalKey, ) @@ -5827,7 +5827,7 @@ func newIncomingHtlcResolution(signer input.Signer, // taking into account the fee rate used. htlcFee := HtlcSuccessFee(chanType, feePerKw) secondLevelOutputAmt := htlc.Amt.ToSatoshis() - htlcFee - successTx, err := createHtlcSuccessTx( + successTx, err := CreateHtlcSuccessTx( chanType, op, secondLevelOutputAmt, csvDelay, keyRing.RevocationKey, keyRing.ToLocalKey, ) diff --git a/lnwallet/transactions.go b/lnwallet/transactions.go index 3c37cd8d..861fdebc 100644 --- a/lnwallet/transactions.go +++ b/lnwallet/transactions.go @@ -35,7 +35,7 @@ var ( TimelockShift = uint32(1 << 29) ) -// createHtlcSuccessTx creates a transaction that spends the output on the +// CreateHtlcSuccessTx creates a transaction that spends the output on the // commitment transaction of the peer that receives an HTLC. This transaction // essentially acts as an off-chain covenant as it's only permitted to spend // the designated HTLC output, and also that spend can _only_ be used as a @@ -45,7 +45,7 @@ var ( // In order to spend the HTLC output, the witness for the passed transaction // should be: // * <0> -func createHtlcSuccessTx(chanType channeldb.ChannelType, +func CreateHtlcSuccessTx(chanType channeldb.ChannelType, htlcOutput wire.OutPoint, htlcAmt btcutil.Amount, csvDelay uint32, revocationKey, delayKey *btcec.PublicKey) (*wire.MsgTx, error) { @@ -85,7 +85,7 @@ func createHtlcSuccessTx(chanType channeldb.ChannelType, return successTx, nil } -// createHtlcTimeoutTx creates a transaction that spends the HTLC output on the +// CreateHtlcTimeoutTx creates a transaction that spends the HTLC output on the // commitment transaction of the peer that created an HTLC (the sender). This // transaction essentially acts as an off-chain covenant as it spends a 2-of-2 // multi-sig output. This output requires a signature from both the sender and @@ -101,7 +101,7 @@ func createHtlcSuccessTx(chanType channeldb.ChannelType, // NOTE: The passed amount for the HTLC should take into account the required // fee rate at the time the HTLC was created. The fee should be able to // entirely pay for this (tiny: 1-in 1-out) transaction. -func createHtlcTimeoutTx(chanType channeldb.ChannelType, +func CreateHtlcTimeoutTx(chanType channeldb.ChannelType, htlcOutput wire.OutPoint, htlcAmt btcutil.Amount, cltvExpiry, csvDelay uint32, revocationKey, delayKey *btcec.PublicKey) (*wire.MsgTx, error) {