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

Function sign_last_tx

lightningd/peer_control.c:220–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218}
219
220static void sign_last_tx(struct channel *channel,
221 struct bitcoin_tx *last_tx,
222 struct bitcoin_signature *last_sig)
223{
224 struct lightningd *ld = channel->peer->ld;
225 struct bitcoin_signature sig;
226 u8 *msg, **witness;
227
228 u64 commit_index = channel->next_index[LOCAL] - 1;
229
230 assert(!last_tx->wtx->inputs[0].witness);
231 msg = towire_hsmd_sign_commitment_tx(tmpctx,
232 &channel->peer->id,
233 channel->dbid,
234 last_tx,
235 &channel->channel_info
236 .remote_fundingkey,
237 commit_index);
238
239 if (!wire_sync_write(ld->hsm_fd, take(msg)))
240 fatal("Could not write to HSM: %s", strerror(errno));
241
242 msg = wire_sync_read(tmpctx, ld->hsm_fd);
243 if (!fromwire_hsmd_sign_commitment_tx_reply(msg, &sig))
244 fatal("HSM gave bad sign_commitment_tx_reply %s",
245 tal_hex(tmpctx, msg));
246
247 witness =
248 bitcoin_witness_2of2(last_tx, last_sig,
249 &sig, &channel->channel_info.remote_fundingkey,
250 &channel->local_funding_pubkey);
251
252 bitcoin_tx_input_set_witness(last_tx, 0, take(witness));
253}
254
255static void remove_sig(struct bitcoin_tx *signed_tx)
256{

Callers 2

sign_and_send_lastFunction · 0.85
json_sign_last_txFunction · 0.85

Calls 8

tal_hexFunction · 0.85
bitcoin_witness_2of2Function · 0.85
fatalFunction · 0.70
wire_sync_writeFunction · 0.50
wire_sync_readFunction · 0.50

Tested by

no test coverage detected