MCPcopy Create free account
hub / github.com/ElementsProject/lightning / handle_revoke_commitment_tx

Function handle_revoke_commitment_tx

hsmd/libhsmd.c:1950–1984  ·  view source on GitHub ↗

~This stub implementation is overriden by fully validating signers * that need to independently revoke the old local commitment tx and * release it's secret. * Revoke the old commitment tx by disclosing its secret and also return * the next commitiment's per-commitment-point. */

Source from the content-addressed store, hash-verified

1948 * the next commitiment's per-commitment-point.
1949 */
1950static u8 *handle_revoke_commitment_tx(struct hsmd_client *c, const u8 *msg_in)
1951{
1952 u64 commit_num;
1953 struct secret channel_seed;
1954 struct sha256 shaseed;
1955 struct secret *old_secret;
1956 struct pubkey next_per_commitment_point;
1957
1958 if (!fromwire_hsmd_revoke_commitment_tx(msg_in, &commit_num))
1959 return hsmd_status_malformed_request(c, msg_in);
1960
1961 /* Stub implementation */
1962
1963 /* The signatures are not checked in this stub because they
1964 * are already checked by the caller. However, the returned
1965 * old_secret and next_per_commitment_point are used.
1966 */
1967
1968 get_channel_seed(&c->id, c->dbid, &channel_seed);
1969 if (!derive_shaseed(&channel_seed, &shaseed))
1970 return hsmd_status_bad_request(c, msg_in, "bad derive_shaseed");
1971
1972 if (!per_commit_point(&shaseed, &next_per_commitment_point, commit_num + 2))
1973 return hsmd_status_bad_request_fmt(
1974 c, msg_in, "bad per_commit_point %" PRIu64, commit_num + 2);
1975
1976 old_secret = tal(tmpctx, struct secret);
1977 if (!per_commit_secret(&shaseed, old_secret, commit_num)) {
1978 return hsmd_status_bad_request_fmt(
1979 c, msg_in, "Cannot derive secret %" PRIu64, commit_num);
1980 }
1981
1982 return towire_hsmd_revoke_commitment_tx_reply(
1983 NULL, old_secret, &next_per_commitment_point);
1984}
1985
1986/* This stub implementation is overriden by fully validating signers
1987 * that need to independently verify that the latest state is

Callers 1

Calls 7

derive_shaseedFunction · 0.85
per_commit_pointFunction · 0.85
per_commit_secretFunction · 0.85
get_channel_seedFunction · 0.70
hsmd_status_bad_requestFunction · 0.70

Tested by

no test coverage detected