mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-09 23:03:15 +02:00
lnrpc+itest: implement MuSig2Cleanup RPC
This commit is contained in:
@@ -92,6 +92,10 @@ var (
|
|||||||
Entity: "signer",
|
Entity: "signer",
|
||||||
Action: "generate",
|
Action: "generate",
|
||||||
}},
|
}},
|
||||||
|
"/signrpc.Signer/MuSig2Cleanup": {{
|
||||||
|
Entity: "signer",
|
||||||
|
Action: "generate",
|
||||||
|
}},
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultSignerMacFilename is the default name of the signer macaroon
|
// DefaultSignerMacFilename is the default name of the signer macaroon
|
||||||
@@ -940,6 +944,24 @@ func (s *Server) MuSig2CombineSig(_ context.Context,
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MuSig2Cleanup removes a session from memory to free up resources.
|
||||||
|
func (s *Server) MuSig2Cleanup(_ context.Context,
|
||||||
|
in *MuSig2CleanupRequest) (*MuSig2CleanupResponse, error) {
|
||||||
|
|
||||||
|
// Check session ID length.
|
||||||
|
sessionID, err := parseMuSig2SessionID(in.SessionId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("error parsing session ID: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = s.cfg.Signer.MuSig2Cleanup(sessionID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("error cleaning up session: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &MuSig2CleanupResponse{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
// parseRawKeyBytes checks that the provided raw public key is valid and returns
|
// parseRawKeyBytes checks that the provided raw public key is valid and returns
|
||||||
// the public key. A nil public key is returned if the length of the rawKeyBytes
|
// the public key. A nil public key is returned if the length of the rawKeyBytes
|
||||||
// is zero.
|
// is zero.
|
||||||
|
@@ -906,11 +906,29 @@ func testTaprootMuSig2CombinedLeafKeySpend(ctxt context.Context, t *harnessTest,
|
|||||||
ctxt, &signrpc.MuSig2SignRequest{
|
ctxt, &signrpc.MuSig2SignRequest{
|
||||||
SessionId: sessResp3.SessionId,
|
SessionId: sessResp3.SessionId,
|
||||||
MessageDigest: sigHash,
|
MessageDigest: sigHash,
|
||||||
Cleanup: true,
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
require.NoError(t.t, err)
|
require.NoError(t.t, err)
|
||||||
|
|
||||||
|
// We manually clean up session 3, just to make sure that works as well.
|
||||||
|
_, err = alice.SignerClient.MuSig2Cleanup(
|
||||||
|
ctxt, &signrpc.MuSig2CleanupRequest{
|
||||||
|
SessionId: sessResp3.SessionId,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
require.NoError(t.t, err)
|
||||||
|
|
||||||
|
// A second call to that cleaned up session should now fail with a
|
||||||
|
// specific error.
|
||||||
|
_, err = alice.SignerClient.MuSig2Sign(
|
||||||
|
ctxt, &signrpc.MuSig2SignRequest{
|
||||||
|
SessionId: sessResp3.SessionId,
|
||||||
|
MessageDigest: sigHash,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
require.Error(t.t, err)
|
||||||
|
require.Contains(t.t, err.Error(), "not found")
|
||||||
|
|
||||||
// Luckily only one of the signers needs to combine the signature, so
|
// Luckily only one of the signers needs to combine the signature, so
|
||||||
// let's do that now.
|
// let's do that now.
|
||||||
combineReq1, err := alice.SignerClient.MuSig2CombineSig(
|
combineReq1, err := alice.SignerClient.MuSig2CombineSig(
|
||||||
|
Reference in New Issue
Block a user