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

Function handle_validate_commitment_tx

hsmd/libhsmd.c:1900–1942  ·  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

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