mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-19 05:45:21 +01:00
Merge pull request #7603 from Torakushi/batch_open_channel_p2tr
funding: use p2tr by default for batch_open_channel
This commit is contained in:
commit
37911e2413
@ -74,6 +74,8 @@ https://github.com/lightningnetwork/lnd/pull/7359)
|
||||
* [Fix a bug where lnd crashes when psbt data is not fully
|
||||
available](https://github.com/lightningnetwork/lnd/pull/7529).
|
||||
|
||||
* [Put back P2TR as default change type
|
||||
in batch_open_channel](https://github.com/lightningnetwork/lnd/pull/7603).
|
||||
|
||||
# Contributors (Alphabetical Order)
|
||||
|
||||
@ -81,6 +83,7 @@ available](https://github.com/lightningnetwork/lnd/pull/7529).
|
||||
* Elle Mouton
|
||||
* hieblmi
|
||||
* Oliver Gugger
|
||||
* Pierre Beugnet
|
||||
* Tommy Volk
|
||||
* Yong Yu
|
||||
* ziggie1984
|
||||
* ziggie1984
|
||||
|
@ -320,6 +320,7 @@ func (b *Batcher) BatchFund(ctx context.Context,
|
||||
// anyway.
|
||||
firstReq := b.channels[0].fundingReq
|
||||
feeRateSatPerKVByte := firstReq.FundingFeePerKw.FeePerKVByte()
|
||||
changeType := walletrpc.ChangeAddressType_CHANGE_ADDRESS_TYPE_P2TR
|
||||
fundPsbtReq := &walletrpc.FundPsbtRequest{
|
||||
Template: &walletrpc.FundPsbtRequest_Raw{
|
||||
Raw: txTemplate,
|
||||
@ -329,6 +330,7 @@ func (b *Batcher) BatchFund(ctx context.Context,
|
||||
},
|
||||
MinConfs: firstReq.MinConfs,
|
||||
SpendUnconfirmed: firstReq.MinConfs == 0,
|
||||
ChangeType: changeType,
|
||||
}
|
||||
fundPsbtResp, err := b.cfg.WalletKitServer.FundPsbt(ctx, fundPsbtReq)
|
||||
if err != nil {
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/funding"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
@ -777,6 +778,21 @@ func testBatchChanFunding(ht *lntest.HarnessTest) {
|
||||
ht.AssertTopologyChannelOpen(alice, chanPoint2)
|
||||
ht.AssertTopologyChannelOpen(alice, chanPoint3)
|
||||
|
||||
// Check if the change type from the batch_open_channel funding is P2TR.
|
||||
rawTx := ht.Miner.GetRawTransaction(txHash)
|
||||
require.Len(ht, rawTx.MsgTx().TxOut, 4)
|
||||
|
||||
// For calculating the change output index we use the formula for the
|
||||
// sum of consecutive of integers (n(n+1)/2). All the channel point
|
||||
// indexes are known, so we just calculate the difference to get the
|
||||
// change output index.
|
||||
changeIndex := uint32(6) - (chanPoint1.OutputIndex +
|
||||
chanPoint2.OutputIndex + chanPoint3.OutputIndex)
|
||||
|
||||
ht.AssertOutputScriptClass(
|
||||
rawTx, changeIndex, txscript.WitnessV1TaprootTy,
|
||||
)
|
||||
|
||||
// With the channel open, ensure that it is counted towards Alice's
|
||||
// total channel balance.
|
||||
balRes := alice.RPC.ChannelBalance()
|
||||
|
@ -377,6 +377,20 @@ func (h *HarnessTest) AssertChannelExists(hn *node.HarnessNode,
|
||||
return channel
|
||||
}
|
||||
|
||||
// AssertOutputScriptClass checks that the specified transaction output has the
|
||||
// expected script class.
|
||||
func (h *HarnessTest) AssertOutputScriptClass(tx *btcutil.Tx,
|
||||
outputIndex uint32, scriptClass txscript.ScriptClass) {
|
||||
|
||||
require.Greater(h, len(tx.MsgTx().TxOut), int(outputIndex))
|
||||
|
||||
txOut := tx.MsgTx().TxOut[outputIndex]
|
||||
|
||||
pkScript, err := txscript.ParsePkScript(txOut.PkScript)
|
||||
require.NoError(h, err)
|
||||
require.Equal(h, pkScript.Class(), scriptClass)
|
||||
}
|
||||
|
||||
// findChannel tries to find a target channel in the node using the given
|
||||
// channel point.
|
||||
func (h *HarnessTest) findChannel(hn *node.HarnessNode,
|
||||
|
Loading…
Reference in New Issue
Block a user