|
|
@ -6,12 +6,12 @@ import (
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/btcsuite/btcd/btcec"
|
|
|
|
"github.com/btcsuite/btcd/btcec/v2"
|
|
|
|
|
|
|
|
"github.com/btcsuite/btcd/btcutil"
|
|
|
|
"github.com/btcsuite/btcd/chaincfg"
|
|
|
|
"github.com/btcsuite/btcd/chaincfg"
|
|
|
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
|
|
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
|
|
|
"github.com/btcsuite/btcd/txscript"
|
|
|
|
"github.com/btcsuite/btcd/txscript"
|
|
|
|
"github.com/btcsuite/btcd/wire"
|
|
|
|
"github.com/btcsuite/btcd/wire"
|
|
|
|
"github.com/btcsuite/btcutil"
|
|
|
|
|
|
|
|
"github.com/lightninglabs/loop/test"
|
|
|
|
"github.com/lightninglabs/loop/test"
|
|
|
|
"github.com/lightningnetwork/lnd/input"
|
|
|
|
"github.com/lightningnetwork/lnd/input"
|
|
|
|
"github.com/lightningnetwork/lnd/keychain"
|
|
|
|
"github.com/lightningnetwork/lnd/keychain"
|
|
|
@ -156,6 +156,10 @@ func TestHtlcV2(t *testing.T) {
|
|
|
|
Privkeys: []*btcec.PrivateKey{receiverPrivKey},
|
|
|
|
Privkeys: []*btcec.PrivateKey{receiverPrivKey},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prevOutFetcher := txscript.NewCannedPrevOutputFetcher(
|
|
|
|
|
|
|
|
htlc.PkScript, int64(htlcValue),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
signTx := func(tx *wire.MsgTx, pubkey *btcec.PublicKey,
|
|
|
|
signTx := func(tx *wire.MsgTx, pubkey *btcec.PublicKey,
|
|
|
|
signer *input.MockSigner) (input.Signature, error) {
|
|
|
|
signer *input.MockSigner) (input.Signature, error) {
|
|
|
|
|
|
|
|
|
|
|
@ -167,8 +171,10 @@ func TestHtlcV2(t *testing.T) {
|
|
|
|
WitnessScript: htlc.Script(),
|
|
|
|
WitnessScript: htlc.Script(),
|
|
|
|
Output: htlcOutput,
|
|
|
|
Output: htlcOutput,
|
|
|
|
HashType: txscript.SigHashAll,
|
|
|
|
HashType: txscript.SigHashAll,
|
|
|
|
SigHashes: txscript.NewTxSigHashes(tx),
|
|
|
|
SigHashes: txscript.NewTxSigHashes(
|
|
|
|
InputIndex: 0,
|
|
|
|
tx, prevOutFetcher,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
InputIndex: 0,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return signer.SignOutputRaw(tx, signDesc)
|
|
|
|
return signer.SignOutputRaw(tx, signDesc)
|
|
|
@ -306,7 +312,7 @@ func TestHtlcV2(t *testing.T) {
|
|
|
|
return txscript.NewEngine(
|
|
|
|
return txscript.NewEngine(
|
|
|
|
htlc.PkScript, sweepTx, 0,
|
|
|
|
htlc.PkScript, sweepTx, 0,
|
|
|
|
txscript.StandardVerifyFlags, nil,
|
|
|
|
txscript.StandardVerifyFlags, nil,
|
|
|
|
nil, int64(htlcValue))
|
|
|
|
nil, int64(htlcValue), prevOutFetcher)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
assertEngineExecution(t, testCase.valid, newEngine)
|
|
|
|
assertEngineExecution(t, testCase.valid, newEngine)
|
|
|
|