|
@ -580,18 +580,9 @@ class Peer(Logger): |
|
|
funding_index = funding_tx.outputs().index(funding_output) |
|
|
funding_index = funding_tx.outputs().index(funding_output) |
|
|
# remote commitment transaction |
|
|
# remote commitment transaction |
|
|
channel_id, funding_txid_bytes = channel_id_from_funding_tx(funding_txid, funding_index) |
|
|
channel_id, funding_txid_bytes = channel_id_from_funding_tx(funding_txid, funding_index) |
|
|
chan_dict = { |
|
|
outpoint = Outpoint(funding_txid, funding_index) |
|
|
"node_id": self.pubkey, |
|
|
constraints = ChannelConstraints(capacity=funding_sat, is_initiator=True, funding_txn_minimum_depth=funding_txn_minimum_depth) |
|
|
"channel_id": channel_id, |
|
|
chan_dict = self.create_channel_storage(channel_id, outpoint, local_config, remote_config, constraints) |
|
|
"short_channel_id": None, |
|
|
|
|
|
"funding_outpoint": Outpoint(funding_txid, funding_index), |
|
|
|
|
|
"remote_config": remote_config, |
|
|
|
|
|
"local_config": local_config, |
|
|
|
|
|
"constraints": ChannelConstraints(capacity=funding_sat, is_initiator=True, funding_txn_minimum_depth=funding_txn_minimum_depth), |
|
|
|
|
|
"remote_update": None, |
|
|
|
|
|
"state": channel_states.PREOPENING.name, |
|
|
|
|
|
"revocation_store": {}, |
|
|
|
|
|
} |
|
|
|
|
|
chan = Channel(chan_dict, |
|
|
chan = Channel(chan_dict, |
|
|
sweep_address=self.lnworker.sweep_address, |
|
|
sweep_address=self.lnworker.sweep_address, |
|
|
lnworker=self.lnworker, |
|
|
lnworker=self.lnworker, |
|
@ -609,6 +600,21 @@ class Peer(Logger): |
|
|
chan.open_with_first_pcp(remote_per_commitment_point, remote_sig) |
|
|
chan.open_with_first_pcp(remote_per_commitment_point, remote_sig) |
|
|
return chan, funding_tx |
|
|
return chan, funding_tx |
|
|
|
|
|
|
|
|
|
|
|
def create_channel_storage(self, channel_id, outpoint, local_config, remote_config, constraints): |
|
|
|
|
|
chan_dict = { |
|
|
|
|
|
"node_id": self.pubkey.hex(), |
|
|
|
|
|
"channel_id": channel_id.hex(), |
|
|
|
|
|
"short_channel_id": None, |
|
|
|
|
|
"funding_outpoint": outpoint, |
|
|
|
|
|
"remote_config": remote_config, |
|
|
|
|
|
"local_config": local_config, |
|
|
|
|
|
"constraints": constraints, |
|
|
|
|
|
"remote_update": None, |
|
|
|
|
|
"state": channel_states.PREOPENING.name, |
|
|
|
|
|
"revocation_store": {}, |
|
|
|
|
|
} |
|
|
|
|
|
return chan_dict |
|
|
|
|
|
|
|
|
async def on_open_channel(self, payload): |
|
|
async def on_open_channel(self, payload): |
|
|
# payload['channel_flags'] |
|
|
# payload['channel_flags'] |
|
|
if payload['chain_hash'] != constants.net.rev_genesis_bytes(): |
|
|
if payload['chain_hash'] != constants.net.rev_genesis_bytes(): |
|
@ -647,12 +653,7 @@ class Peer(Logger): |
|
|
remote_balance_sat = funding_sat * 1000 - push_msat |
|
|
remote_balance_sat = funding_sat * 1000 - push_msat |
|
|
remote_dust_limit_sat = int.from_bytes(payload['dust_limit_satoshis'], byteorder='big') # TODO validate |
|
|
remote_dust_limit_sat = int.from_bytes(payload['dust_limit_satoshis'], byteorder='big') # TODO validate |
|
|
remote_reserve_sat = self.validate_remote_reserve(payload['channel_reserve_satoshis'], remote_dust_limit_sat, funding_sat) |
|
|
remote_reserve_sat = self.validate_remote_reserve(payload['channel_reserve_satoshis'], remote_dust_limit_sat, funding_sat) |
|
|
chan_dict = { |
|
|
remote_config = RemoteConfig( |
|
|
"node_id": self.pubkey, |
|
|
|
|
|
"channel_id": channel_id, |
|
|
|
|
|
"short_channel_id": None, |
|
|
|
|
|
"funding_outpoint": Outpoint(funding_txid, funding_idx), |
|
|
|
|
|
"remote_config": RemoteConfig( |
|
|
|
|
|
payment_basepoint=OnlyPubkeyKeypair(payload['payment_basepoint']), |
|
|
payment_basepoint=OnlyPubkeyKeypair(payload['payment_basepoint']), |
|
|
multisig_key=OnlyPubkeyKeypair(payload['funding_pubkey']), |
|
|
multisig_key=OnlyPubkeyKeypair(payload['funding_pubkey']), |
|
|
htlc_basepoint=OnlyPubkeyKeypair(payload['htlc_basepoint']), |
|
|
htlc_basepoint=OnlyPubkeyKeypair(payload['htlc_basepoint']), |
|
@ -667,13 +668,10 @@ class Peer(Logger): |
|
|
htlc_minimum_msat=int.from_bytes(payload['htlc_minimum_msat'], 'big'), # TODO validate |
|
|
htlc_minimum_msat=int.from_bytes(payload['htlc_minimum_msat'], 'big'), # TODO validate |
|
|
next_per_commitment_point=payload['first_per_commitment_point'], |
|
|
next_per_commitment_point=payload['first_per_commitment_point'], |
|
|
current_per_commitment_point=None, |
|
|
current_per_commitment_point=None, |
|
|
), |
|
|
) |
|
|
"local_config": local_config, |
|
|
constraints = ChannelConstraints(capacity=funding_sat, is_initiator=False, funding_txn_minimum_depth=min_depth) |
|
|
"constraints": ChannelConstraints(capacity=funding_sat, is_initiator=False, funding_txn_minimum_depth=min_depth), |
|
|
outpoint = Outpoint(funding_txid, funding_idx) |
|
|
"remote_update": None, |
|
|
chan_dict = self.create_channel_storage(channel_id, outpoint, local_config, remote_config, constraints) |
|
|
"state": channel_states.PREOPENING.name, |
|
|
|
|
|
"revocation_store": {}, |
|
|
|
|
|
} |
|
|
|
|
|
chan = Channel(chan_dict, |
|
|
chan = Channel(chan_dict, |
|
|
sweep_address=self.lnworker.sweep_address, |
|
|
sweep_address=self.lnworker.sweep_address, |
|
|
lnworker=self.lnworker, |
|
|
lnworker=self.lnworker, |
|
|