mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-13 02:11:03 +02:00
itest: refactor testTaproot
This commit is contained in:
parent
8ba5f399d3
commit
0176d58b85
@ -177,3 +177,16 @@ func (h *HarnessRPC) VerifyMessageSigner(
|
|||||||
|
|
||||||
return resp
|
return resp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ComputeInputScript makes a RPC call to the node's SignerClient and asserts.
|
||||||
|
func (h *HarnessRPC) ComputeInputScript(
|
||||||
|
req *signrpc.SignReq) *signrpc.InputScriptResp {
|
||||||
|
|
||||||
|
ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
resp, err := h.Signer.ComputeInputScript(ctxt, req)
|
||||||
|
h.NoError(err, "ComputeInputScript")
|
||||||
|
|
||||||
|
return resp
|
||||||
|
}
|
||||||
|
@ -465,4 +465,8 @@ var allTestCasesTemp = []*lntemp.TestCase{
|
|||||||
Name: "cpfp",
|
Name: "cpfp",
|
||||||
TestFunc: testCPFP,
|
TestFunc: testCPFP,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "taproot",
|
||||||
|
TestFunc: testTaproot,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
@ -1126,34 +1126,6 @@ func assertPsbtFundSignSpend(ht *lntemp.HarnessTest, alice *node.HarnessNode,
|
|||||||
ht.Miner.AssertTxInBlock(block, &finalTxHash)
|
ht.Miner.AssertTxInBlock(block, &finalTxHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
// deriveInternalKey derives a signing key and returns its descriptor, full
|
|
||||||
// derivation path and parsed public key.
|
|
||||||
func deriveInternalKeyOld(ctx context.Context, t *harnessTest,
|
|
||||||
alice *lntest.HarnessNode) (*signrpc.KeyDescriptor, *btcec.PublicKey,
|
|
||||||
[]uint32) {
|
|
||||||
|
|
||||||
// For the next step, we need a public key. Let's use a special family
|
|
||||||
// for this.
|
|
||||||
keyDesc, err := alice.WalletKitClient.DeriveNextKey(
|
|
||||||
ctx, &walletrpc.KeyReq{KeyFamily: testTaprootKeyFamily},
|
|
||||||
)
|
|
||||||
require.NoError(t.t, err)
|
|
||||||
|
|
||||||
// The DeriveNextKey returns a key from the internal 1017 scope.
|
|
||||||
fullDerivationPath := []uint32{
|
|
||||||
hdkeychain.HardenedKeyStart + keychain.BIP0043Purpose,
|
|
||||||
hdkeychain.HardenedKeyStart + harnessNetParams.HDCoinType,
|
|
||||||
hdkeychain.HardenedKeyStart + uint32(keyDesc.KeyLoc.KeyFamily),
|
|
||||||
0,
|
|
||||||
uint32(keyDesc.KeyLoc.KeyIndex),
|
|
||||||
}
|
|
||||||
|
|
||||||
parsedPubKey, err := btcec.ParsePubKey(keyDesc.RawKeyBytes)
|
|
||||||
require.NoError(t.t, err)
|
|
||||||
|
|
||||||
return keyDesc, parsedPubKey, fullDerivationPath
|
|
||||||
}
|
|
||||||
|
|
||||||
// deriveInternalKey derives a signing key and returns its descriptor, full
|
// deriveInternalKey derives a signing key and returns its descriptor, full
|
||||||
// derivation path and parsed public key.
|
// derivation path and parsed public key.
|
||||||
func deriveInternalKey(ht *lntemp.HarnessTest,
|
func deriveInternalKey(ht *lntemp.HarnessTest,
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -24,10 +24,6 @@ var allTestCases = []*testCase{
|
|||||||
name: "remote signer",
|
name: "remote signer",
|
||||||
test: testRemoteSigner,
|
test: testRemoteSigner,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "taproot",
|
|
||||||
test: testTaproot,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "taproot coop close",
|
name: "taproot coop close",
|
||||||
test: testTaprootCoopClose,
|
test: testTaprootCoopClose,
|
||||||
|
@ -8,9 +8,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
|
||||||
"github.com/btcsuite/btcd/rpcclient"
|
"github.com/btcsuite/btcd/rpcclient"
|
||||||
"github.com/btcsuite/btcd/txscript"
|
|
||||||
"github.com/btcsuite/btcd/wire"
|
"github.com/btcsuite/btcd/wire"
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
"github.com/lightningnetwork/lnd/input"
|
"github.com/lightningnetwork/lnd/input"
|
||||||
@ -468,31 +466,3 @@ func findTxAtHeight(t *harnessTest, height int32,
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// getOutputIndex returns the output index of the given address in the given
|
|
||||||
// transaction.
|
|
||||||
func getOutputIndex(t *harnessTest, miner *lntest.HarnessMiner,
|
|
||||||
txid *chainhash.Hash, addr string) int {
|
|
||||||
|
|
||||||
t.t.Helper()
|
|
||||||
|
|
||||||
// We'll then extract the raw transaction from the mempool in order to
|
|
||||||
// determine the index of the p2tr output.
|
|
||||||
tx, err := miner.Client.GetRawTransaction(txid)
|
|
||||||
require.NoError(t.t, err)
|
|
||||||
|
|
||||||
p2trOutputIndex := -1
|
|
||||||
for i, txOut := range tx.MsgTx().TxOut {
|
|
||||||
_, addrs, _, err := txscript.ExtractPkScriptAddrs(
|
|
||||||
txOut.PkScript, miner.ActiveNet,
|
|
||||||
)
|
|
||||||
require.NoError(t.t, err)
|
|
||||||
|
|
||||||
if addrs[0].String() == addr {
|
|
||||||
p2trOutputIndex = i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
require.Greater(t.t, p2trOutputIndex, -1)
|
|
||||||
|
|
||||||
return p2trOutputIndex
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user