lnwallet: assert that P2TR addrs are used for change outputs

This commit is contained in:
Olaoluwa Osuntokun 2022-11-22 11:36:37 +01:00 committed by Oliver Gugger
parent 51f131b019
commit 7090ff22d7
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

View File

@ -2562,7 +2562,9 @@ func testCreateSimpleTx(r *rpctest.Harness, w *lnwallet.LightningWallet,
// _very_ similar to the one we just created being sent. The
// only difference is that the dry run tx is not signed, and
// that the change output position might be different.
tx, sendErr := w.SendOutputs(outputs, feeRate, minConfs, labels.External)
tx, sendErr := w.SendOutputs(
outputs, feeRate, minConfs, labels.External,
)
switch {
case test.valid && sendErr != nil:
t.Fatalf("got unexpected error when sending tx: %v",
@ -2647,6 +2649,16 @@ func testCreateSimpleTx(r *rpctest.Harness, w *lnwallet.LightningWallet,
if err := assertSimilarTx(createTx.Tx, tx); err != nil {
t.Fatalf("transactions not similar: %v", err)
}
// Now that we know both transactions were essentially
// identical, we'll make sure that a P2TR addr was used as the
// change output, which is the current default.
changeTxOut := createTx.Tx.TxOut[createTx.ChangeIndex]
changeScriptType, _, _, err := txscript.ExtractPkScriptAddrs(
changeTxOut.PkScript, &w.Cfg.NetParams,
)
require.NoError(t, err)
require.Equal(t, changeScriptType, txscript.WitnessV1TaprootTy)
}
}