|
|
@ -27,12 +27,7 @@ class HTLCManager: |
|
|
|
# note: "htlc_id" keys in dict are str! but due to json_db magic they can *almost* be treated as int... |
|
|
|
log[LOCAL] = deepcopy(initial) |
|
|
|
log[REMOTE] = deepcopy(initial) |
|
|
|
log['unacked_local_updates2'] = {} |
|
|
|
|
|
|
|
if 'unfulfilled_htlcs' not in log: |
|
|
|
log['unfulfilled_htlcs'] = {} # htlc_id -> onion_packet |
|
|
|
if 'fail_htlc_reasons' not in log: |
|
|
|
log['fail_htlc_reasons'] = {} # htlc_id -> error_bytes, failure_message |
|
|
|
log[LOCAL]['unacked_updates'] = {} |
|
|
|
|
|
|
|
# maybe bootstrap fee_updates if initial_feerate was provided |
|
|
|
if initial_feerate is not None: |
|
|
@ -209,7 +204,7 @@ class HTLCManager: |
|
|
|
fee_update.ctn_local = self.ctn_latest(LOCAL) + 1 |
|
|
|
|
|
|
|
# no need to keep local update raw msgs anymore, they have just been ACKed. |
|
|
|
self.log['unacked_local_updates2'].pop(self.log[REMOTE]['ctn'], None) |
|
|
|
self.log[LOCAL]['unacked_updates'].pop(self.log[REMOTE]['ctn'], None) |
|
|
|
|
|
|
|
@with_lock |
|
|
|
def _update_maybe_active_htlc_ids(self) -> None: |
|
|
@ -276,21 +271,21 @@ class HTLCManager: |
|
|
|
"""We need to be able to replay unacknowledged updates we sent to the remote |
|
|
|
in case of disconnections. Hence, raw update and commitment_signed messages |
|
|
|
are stored temporarily (until they are acked).""" |
|
|
|
# self.log['unacked_local_updates2'][ctn_idx] is a list of raw messages |
|
|
|
# self.log[LOCAL]['unacked_updates'][ctn_idx] is a list of raw messages |
|
|
|
# containing some number of updates and then a single commitment_signed |
|
|
|
if is_commitment_signed: |
|
|
|
ctn_idx = self.ctn_latest(REMOTE) |
|
|
|
else: |
|
|
|
ctn_idx = self.ctn_latest(REMOTE) + 1 |
|
|
|
l = self.log['unacked_local_updates2'].get(ctn_idx, []) |
|
|
|
l = self.log[LOCAL]['unacked_updates'].get(ctn_idx, []) |
|
|
|
l.append(raw_update_msg.hex()) |
|
|
|
self.log['unacked_local_updates2'][ctn_idx] = l |
|
|
|
self.log[LOCAL]['unacked_updates'][ctn_idx] = l |
|
|
|
|
|
|
|
@with_lock |
|
|
|
def get_unacked_local_updates(self) -> Dict[int, Sequence[bytes]]: |
|
|
|
#return self.log['unacked_local_updates2'] |
|
|
|
#return self.log[LOCAL]['unacked_updates'] |
|
|
|
return {int(ctn): [bfh(msg) for msg in messages] |
|
|
|
for ctn, messages in self.log['unacked_local_updates2'].items()} |
|
|
|
for ctn, messages in self.log[LOCAL]['unacked_updates'].items()} |
|
|
|
|
|
|
|
##### Queries re HTLCs: |
|
|
|
|
|
|
|