mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-27 15:31:31 +00:00
ln: initialize genesis with object, fix method name typo, use depth_target_to_fee
This commit is contained in:
parent
bb4aa1e135
commit
478e484c54
2 changed files with 10 additions and 10 deletions
|
@ -35,8 +35,6 @@ from .lnrouter import new_onion_packet, OnionHopsDataSingle, OnionPerHop, decode
|
|||
from .lnaddr import lndecode
|
||||
from .lnhtlc import UpdateAddHtlc, HTLCStateMachine, RevokeAndAck, SettleHtlc
|
||||
|
||||
REV_GENESIS = bytes.fromhex(bitcoin.rev_hex(constants.net.GENESIS))
|
||||
|
||||
def channel_id_from_funding_tx(funding_txid, funding_index):
|
||||
funding_txid_bytes = bytes.fromhex(funding_txid)[::-1]
|
||||
i = int.from_bytes(funding_txid_bytes, 'big') ^ funding_index
|
||||
|
@ -284,6 +282,7 @@ def aiosafe(f):
|
|||
class Peer(PrintError):
|
||||
|
||||
def __init__(self, lnworker, host, port, pubkey, request_initial_sync=False):
|
||||
self.REV_GENESIS = bytes.fromhex(bitcoin.rev_hex(constants.net.GENESIS))
|
||||
self.exception = None # set by aiosafe
|
||||
self.host = host
|
||||
self.port = port
|
||||
|
@ -538,7 +537,7 @@ class Peer(PrintError):
|
|||
msg = gen_msg(
|
||||
"open_channel",
|
||||
temporary_channel_id=temp_channel_id,
|
||||
chain_hash=REV_GENESIS,
|
||||
chain_hash=self.REV_GENESIS,
|
||||
funding_satoshis=funding_sat,
|
||||
push_msat=push_msat,
|
||||
dust_limit_satoshis=local_config.dust_limit_sat,
|
||||
|
@ -745,7 +744,7 @@ class Peer(PrintError):
|
|||
bitcoin_signature_2=bitcoin_sigs[1],
|
||||
len=0,
|
||||
#features not set (defaults to zeros)
|
||||
chain_hash=REV_GENESIS,
|
||||
chain_hash=self.REV_GENESIS,
|
||||
short_channel_id=chan.short_channel_id,
|
||||
node_id_1=node_ids[0],
|
||||
node_id_2=node_ids[1],
|
||||
|
@ -787,7 +786,7 @@ class Peer(PrintError):
|
|||
chan_ann = gen_msg("channel_announcement",
|
||||
len=0,
|
||||
#features not set (defaults to zeros)
|
||||
chain_hash=REV_GENESIS,
|
||||
chain_hash=self.REV_GENESIS,
|
||||
short_channel_id=chan.short_channel_id,
|
||||
node_id_1=node_ids[0],
|
||||
node_id_2=node_ids[1],
|
||||
|
@ -1026,10 +1025,7 @@ class Peer(PrintError):
|
|||
# TODO force close if initiator does not update_fee enough
|
||||
return
|
||||
|
||||
# TODO should use target_to_fee from master
|
||||
# target_to_fee(10*1000000) # 10 MB
|
||||
feerate_per_kvbyte = self.network.config.depth_to_fee(10)
|
||||
feerate_per_kw = max(253, feerate_per_kvbyte // 4)
|
||||
feerate_per_kw = self.current_feerate_per_kw()
|
||||
self.print_error("current feerate", chan.remote_state.feerate)
|
||||
self.print_error("new feerate", feerate_per_kw)
|
||||
if feerate_per_kw < chan.remote_state.feerate / 2:
|
||||
|
@ -1043,3 +1039,7 @@ class Peer(PrintError):
|
|||
|
||||
self.send_message(gen_msg("update_fee", channel_id=chan.channel_id, feerate_per_kw=feerate_per_kw))
|
||||
self.lnworker.save_channel(chan)
|
||||
|
||||
def current_feerate_per_kw(self):
|
||||
feerate_per_kvbyte = self.network.config.depth_target_to_fee(10*1000000) # 10 MB
|
||||
return max(253, feerate_per_kvbyte // 4)
|
||||
|
|
|
@ -143,7 +143,7 @@ class HTLCStateMachine(PrintError):
|
|||
|
||||
self.state = 'DISCONNECTED'
|
||||
|
||||
def get_funding_addres(self):
|
||||
def get_funding_address(self):
|
||||
script = funding_output_script(self.local_config, self.remote_config)
|
||||
return redeem_script_to_address('p2wsh', script)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue