|
|
@ -517,9 +517,34 @@ class Peer(Logger): |
|
|
|
) |
|
|
|
return local_config |
|
|
|
|
|
|
|
def temporarily_reserve_funding_tx_change_address(func): |
|
|
|
# During the channel open flow, if we initiated, we might have used a change address |
|
|
|
# of ours in the funding tx. The funding tx is not part of the wallet history |
|
|
|
# at that point yet, but we should already consider this change address as 'used'. |
|
|
|
async def wrapper(self: 'Peer', *args, **kwargs): |
|
|
|
funding_tx = kwargs['funding_tx'] # type: PartialTransaction |
|
|
|
wallet = self.lnworker.wallet |
|
|
|
change_addresses = [txout.address for txout in funding_tx.outputs() |
|
|
|
if wallet.is_change(txout.address)] |
|
|
|
for addr in change_addresses: |
|
|
|
wallet.set_reserved_state_of_address(addr, reserved=True) |
|
|
|
try: |
|
|
|
return await func(self, *args, **kwargs) |
|
|
|
finally: |
|
|
|
for addr in change_addresses: |
|
|
|
self.lnworker.wallet.set_reserved_state_of_address(addr, reserved=False) |
|
|
|
return wrapper |
|
|
|
|
|
|
|
@log_exceptions |
|
|
|
async def channel_establishment_flow(self, password: Optional[str], funding_tx: 'PartialTransaction', funding_sat: int, |
|
|
|
push_msat: int, temp_channel_id: bytes) -> Tuple[Channel, 'PartialTransaction']: |
|
|
|
@temporarily_reserve_funding_tx_change_address |
|
|
|
async def channel_establishment_flow( |
|
|
|
self, *, |
|
|
|
password: Optional[str], |
|
|
|
funding_tx: 'PartialTransaction', |
|
|
|
funding_sat: int, |
|
|
|
push_msat: int, |
|
|
|
temp_channel_id: bytes |
|
|
|
) -> Tuple[Channel, 'PartialTransaction']: |
|
|
|
await asyncio.wait_for(self.initialized, LN_P2P_NETWORK_TIMEOUT) |
|
|
|
feerate = self.lnworker.current_feerate_per_kw() |
|
|
|
local_config = self.make_local_config(funding_sat, push_msat, LOCAL) |
|
|
|