mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
lnwallet: for PsbtIntent return the internal key in the POutput
We also add a new assertion to the itests to ensure the field is being properly set.
This commit is contained in:
parent
0a7139c9ca
commit
39b1080166
@ -177,6 +177,17 @@ func runPsbtChanFunding(ht *lntest.HarnessTest, carol, dave *node.HarnessNode,
|
||||
},
|
||||
)
|
||||
|
||||
// If this is a taproot channel, then we'll decode the PSBT to assert
|
||||
// that an internal key is included.
|
||||
if commitType == lnrpc.CommitmentType_SIMPLE_TAPROOT {
|
||||
decodedPSBT, err := psbt.NewFromRawBytes(
|
||||
bytes.NewReader(tempPsbt), false,
|
||||
)
|
||||
require.NoError(ht, err)
|
||||
|
||||
require.Len(ht, decodedPSBT.Outputs[0].TaprootInternalKey, 32)
|
||||
}
|
||||
|
||||
// Let's add a second channel to the batch. This time between Carol and
|
||||
// Alice. We will publish the batch TX once this channel funding is
|
||||
// complete.
|
||||
|
@ -6,11 +6,13 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcec/v2/schnorr"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/btcutil/psbt"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/fn"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
)
|
||||
@ -208,7 +210,18 @@ func (i *PsbtIntent) FundingParams() (btcutil.Address, int64, *psbt.Packet,
|
||||
}
|
||||
}
|
||||
packet.UnsignedTx.TxOut = append(packet.UnsignedTx.TxOut, out)
|
||||
packet.Outputs = append(packet.Outputs, psbt.POutput{})
|
||||
|
||||
var pOut psbt.POutput
|
||||
|
||||
// If this is a MuSig2 channel, we also need to communicate the internal
|
||||
// key to the caller. Otherwise, they cannot verify the construction of
|
||||
// the P2TR output script.
|
||||
pOut.TaprootInternalKey = fn.MapOptionZ(
|
||||
i.TaprootInternalKey(), schnorr.SerializePubKey,
|
||||
)
|
||||
|
||||
packet.Outputs = append(packet.Outputs, pOut)
|
||||
|
||||
return addr, out.Value, packet, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user