insert htlc used for channel open

This commit is contained in:
Jesse de Wit
2024-02-19 15:05:03 +01:00
parent 04f2ee06bf
commit 5fe08773f7
7 changed files with 87 additions and 2 deletions

View File

@@ -345,3 +345,29 @@ func (s *HistoryStore) SetClnForwardOffsets(
)
return err
}
func (s *HistoryStore) AddOpenChannelHtlc(ctx context.Context, htlc *history.OpenChannelHtlc) error {
// TODO: Find an identifier equal to the forwarding_history identifier.
_, err := s.pool.Exec(ctx, `
INSERT INTO open_channel_htlcs (
nodeid
, peerid
, funding_tx_id
, funding_tx_outnum
, forward_amt_msat
, original_amt_msat
, incoming_amt_msat
, forward_time
) VALUES ($1, $2, $3, $4, $5, $6, $7)
`,
htlc.NodeId,
htlc.PeerId,
htlc.ChannelPoint.Hash[:],
htlc.ChannelPoint.Index,
int64(htlc.ForwardAmountMsat),
int64(htlc.OriginalAmountMsat),
int64(htlc.IncomingAmountMsat),
htlc.ForwardTime.UnixNano(),
)
return err
}

View File

@@ -0,0 +1 @@
DROP TABLE public.open_channel_htlcs;

View File

@@ -0,0 +1,9 @@
CREATE TABLE public.open_channel_htlcs (
nodeid bytea NOT NULL,
peerid bytea NOT NULL,
funding_tx_id bytea NOT NULL,
funding_tx_outnum bigint NOT NULL,
forward_amt_msat bigint NOT NULL,
original_amt_msat bigint NOT NULL,
forward_time bigint NOT NULL
);