| 1362 | } |
| 1363 | |
| 1364 | static void fulfill_our_htlc_out(struct channel *channel, struct htlc_out *hout, |
| 1365 | const struct preimage *preimage) |
| 1366 | { |
| 1367 | struct lightningd *ld = channel->peer->ld; |
| 1368 | bool we_filled = false; |
| 1369 | |
| 1370 | assert(!hout->preimage); |
| 1371 | hout->preimage = tal_dup(hout, struct preimage, preimage); |
| 1372 | htlc_out_check(hout, __func__); |
| 1373 | |
| 1374 | wallet_htlc_update(ld->wallet, hout->dbid, hout->hstate, |
| 1375 | hout->preimage, |
| 1376 | max_unsigned(channel->next_index[LOCAL], |
| 1377 | channel->next_index[REMOTE]), |
| 1378 | 0, hout->failonion, |
| 1379 | hout->failmsg, &we_filled); |
| 1380 | /* Update channel stats */ |
| 1381 | wallet_channel_stats_incr_out_fulfilled(ld->wallet, |
| 1382 | channel->dbid, |
| 1383 | hout->msat); |
| 1384 | |
| 1385 | if (hout->am_origin) |
| 1386 | payment_succeeded(ld, hout, preimage); |
| 1387 | else if (hout->in) { |
| 1388 | fulfill_htlc(hout->in, preimage); |
| 1389 | wallet_forwarded_payment_add(ld->wallet, hout->in, |
| 1390 | FORWARD_STYLE_TLV, |
| 1391 | channel_scid_or_local_alias(hout->key.channel), hout, |
| 1392 | FORWARD_SETTLED, 0); |
| 1393 | } |
| 1394 | } |
| 1395 | |
| 1396 | static bool peer_fulfilled_our_htlc(struct channel *channel, |
| 1397 | const struct fulfilled_htlc *fulfilled) |
no test coverage detected