mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-03 03:29:50 +02:00
itest: add test when signing without UTXO data
Adds a testcase in the itest suite which tests that psbt input data needs its corresponding UTXO data when signing.
This commit is contained in:
parent
4da26fb65a
commit
b649b552e6
@ -1009,17 +1009,28 @@ func assertPsbtSpend(ht *lntest.HarnessTest, alice *node.HarnessNode,
|
|||||||
packet, err := psbt.NewFromUnsignedTx(pendingTx)
|
packet, err := psbt.NewFromUnsignedTx(pendingTx)
|
||||||
require.NoError(ht, err)
|
require.NoError(ht, err)
|
||||||
|
|
||||||
|
// We first try to sign the psbt without the necessary input data
|
||||||
|
// which should fail with the expected error.
|
||||||
|
var buf bytes.Buffer
|
||||||
|
err = packet.Serialize(&buf)
|
||||||
|
require.NoError(ht, err)
|
||||||
|
|
||||||
|
signReq := &walletrpc.SignPsbtRequest{FundedPsbt: buf.Bytes()}
|
||||||
|
err = alice.RPC.SignPsbtErr(signReq)
|
||||||
|
require.ErrorContains(ht, err, "input (index=0) doesn't specify "+
|
||||||
|
"any UTXO info", "error does not match")
|
||||||
|
|
||||||
// Now let's add the meta information that we need for signing.
|
// Now let's add the meta information that we need for signing.
|
||||||
packet.Inputs[0].WitnessUtxo = utxo
|
packet.Inputs[0].WitnessUtxo = utxo
|
||||||
packet.Inputs[0].NonWitnessUtxo = prevTx
|
packet.Inputs[0].NonWitnessUtxo = prevTx
|
||||||
decorateUnsigned(packet)
|
decorateUnsigned(packet)
|
||||||
|
|
||||||
// That's it, we should be able to sign the PSBT now.
|
// That's it, we should be able to sign the PSBT now.
|
||||||
var buf bytes.Buffer
|
buf.Reset()
|
||||||
err = packet.Serialize(&buf)
|
err = packet.Serialize(&buf)
|
||||||
require.NoError(ht, err)
|
require.NoError(ht, err)
|
||||||
|
|
||||||
signReq := &walletrpc.SignPsbtRequest{FundedPsbt: buf.Bytes()}
|
signReq = &walletrpc.SignPsbtRequest{FundedPsbt: buf.Bytes()}
|
||||||
signResp := alice.RPC.SignPsbt(signReq)
|
signResp := alice.RPC.SignPsbt(signReq)
|
||||||
|
|
||||||
// Let's make sure we have a partial signature.
|
// Let's make sure we have a partial signature.
|
||||||
|
@ -263,6 +263,19 @@ func (h *HarnessRPC) SignPsbt(
|
|||||||
return resp
|
return resp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SignPsbtErr makes a RPC call to the node's WalletKitClient and asserts
|
||||||
|
// an error returned.
|
||||||
|
func (h *HarnessRPC) SignPsbtErr(req *walletrpc.SignPsbtRequest) error {
|
||||||
|
ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
_, err := h.WalletKit.SignPsbt(ctxt, req)
|
||||||
|
require.Errorf(h, err, "%s: expect sign psbt to return an error",
|
||||||
|
h.Name)
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// ImportTapscript makes a RPC call to the node's WalletKitClient and asserts.
|
// ImportTapscript makes a RPC call to the node's WalletKitClient and asserts.
|
||||||
//
|
//
|
||||||
//nolint:lll
|
//nolint:lll
|
||||||
|
Loading…
x
Reference in New Issue
Block a user