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

Function handle_validate_commitment_tx

hsmd/libhsmd.c:1913–1955  ·  view source on GitHub ↗

~This stub implementation is overriden by fully validating signers * that need to independently verify the peer's signatures. */

Source from the content-addressed store, hash-verified

1911/* ~This stub implementation is overriden by fully validating signers
1912 * that need to independently verify the peer's signatures. */
1913static u8 *handle_validate_commitment_tx(struct hsmd_client *c, const u8 *msg_in)
1914{
1915 struct bitcoin_tx *tx;
1916 struct hsm_htlc *htlc;
1917 u64 commit_num;
1918 u32 feerate;
1919 struct bitcoin_signature sig;
1920 struct bitcoin_signature *htlc_sigs;
1921 struct secret channel_seed;
1922 struct sha256 shaseed;
1923 struct secret *old_secret;
1924 struct pubkey next_per_commitment_point;
1925
1926 if (!fromwire_hsmd_validate_commitment_tx(tmpctx, msg_in,
1927 &tx, &htlc,
1928 &commit_num, &feerate,
1929 &sig, &htlc_sigs))
1930 return hsmd_status_malformed_request(c, msg_in);
1931
1932 /* Stub implementation */
1933
1934 /* The signatures are not checked in this stub because they
1935 * are already checked by the caller. However, the returned
1936 * old_secret and next_per_commitment_point are used.
1937 */
1938
1939 get_channel_seed(&c->id, c->dbid, &channel_seed);
1940 if (!derive_shaseed(&channel_seed, &shaseed))
1941 return hsmd_status_bad_request(c, msg_in, "bad derive_shaseed");
1942
1943 if (!per_commit_point(&shaseed, &next_per_commitment_point, commit_num + 1))
1944 return hsmd_status_bad_request_fmt(
1945 c, msg_in, "bad per_commit_point %" PRIu64, commit_num + 1);
1946
1947 /* Don't ever return the old_secret here anymore. The node should
1948 * call hsmd_revoke_commitment_tx to transactionally revoke the commitment
1949 * and return the secret ...
1950 */
1951 old_secret = NULL;
1952
1953 return towire_hsmd_validate_commitment_tx_reply(
1954 NULL, old_secret, &next_per_commitment_point);
1955}
1956
1957/* ~This stub implementation is overriden by fully validating signers
1958 * that need to independently revoke the old local commitment tx and

Callers 1

Calls 6

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

Tested by

no test coverage detected