mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
lightningd: store the htlc stubs.
These belong in the database, but for now just keep an array. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
893335244d
commit
b6d7ad0614
@ -3,7 +3,6 @@
|
||||
#include "subd.h"
|
||||
#include <bitcoin/script.h>
|
||||
#include <bitcoin/tx.h>
|
||||
#include <ccan/crypto/ripemd160/ripemd160.h>
|
||||
#include <ccan/fdpass/fdpass.h>
|
||||
#include <ccan/io/io.h>
|
||||
#include <ccan/noerr/noerr.h>
|
||||
@ -31,6 +30,7 @@
|
||||
#include <lightningd/hsm_control.h>
|
||||
#include <lightningd/key_derive.h>
|
||||
#include <lightningd/new_connection.h>
|
||||
#include <lightningd/onchain/onchain_wire.h>
|
||||
#include <lightningd/opening/gen_opening_wire.h>
|
||||
#include <lightningd/peer_htlcs.h>
|
||||
#include <lightningd/status.h>
|
||||
@ -530,6 +530,7 @@ void add_peer(struct lightningd *ld, u64 unique_id,
|
||||
= peer->next_index[REMOTE]
|
||||
= peer->num_revocations_received = 0;
|
||||
peer->next_htlc_id = 0;
|
||||
peer->htlcs = tal_arr(peer, struct htlc_stub, 0);
|
||||
wallet_shachain_init(ld->wallet, &peer->their_shachain);
|
||||
|
||||
idname = type_to_string(peer, struct pubkey, id);
|
||||
|
@ -94,6 +94,9 @@ struct peer {
|
||||
/* Reestablishment stuff: last sent commit and revocation details. */
|
||||
bool last_was_revoke;
|
||||
struct changed_htlc *last_sent_commit;
|
||||
|
||||
/* FIXME: Just leave this in the db. */
|
||||
struct htlc_stub *htlcs;
|
||||
};
|
||||
|
||||
static inline bool peer_can_add_htlc(const struct peer *peer)
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <bitcoin/tx.h>
|
||||
#include <ccan/build_assert/build_assert.h>
|
||||
#include <ccan/crypto/ripemd160/ripemd160.h>
|
||||
#include <ccan/mem/mem.h>
|
||||
#include <ccan/tal/str/str.h>
|
||||
#include <daemon/chaintopology.h>
|
||||
@ -11,6 +12,7 @@
|
||||
#include <lightningd/htlc_end.h>
|
||||
#include <lightningd/htlc_wire.h>
|
||||
#include <lightningd/lightningd.h>
|
||||
#include <lightningd/onchain/onchain_wire.h>
|
||||
#include <lightningd/pay.h>
|
||||
#include <lightningd/peer_control.h>
|
||||
#include <lightningd/peer_htlcs.h>
|
||||
@ -80,7 +82,14 @@ static void save_htlc_stub(struct lightningd *ld,
|
||||
u32 cltv_value,
|
||||
const struct sha256 *payment_hash)
|
||||
{
|
||||
/* FIXME: remember peer, side, cltv and RIPEMD160(hash) */
|
||||
size_t n = tal_count(peer->htlcs);
|
||||
tal_resize(&peer->htlcs, n+1);
|
||||
peer->htlcs[n].owner = owner;
|
||||
peer->htlcs[n].cltv_expiry = cltv_value;
|
||||
ripemd160(&peer->htlcs[n].ripemd,
|
||||
payment_hash->u.u8, sizeof(payment_hash->u));
|
||||
|
||||
/* FIXME: save to db instead! */
|
||||
}
|
||||
|
||||
static void fail_in_htlc(struct htlc_in *hin,
|
||||
|
Loading…
Reference in New Issue
Block a user