mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-03 02:35:20 +00:00
lnbase: fix custom local to_self_delay, use node privkey derived from timestamp in online test
This commit is contained in:
parent
5d6c835e8d
commit
e7a85302e0
3 changed files with 9 additions and 7 deletions
|
@ -347,7 +347,7 @@ def overall_weight(num_htlc):
|
|||
HTLC_TIMEOUT_WEIGHT = 663
|
||||
HTLC_SUCCESS_WEIGHT = 703
|
||||
|
||||
def make_htlc_tx_output(amount_msat, local_feerate, revocationpubkey, local_delayedpubkey, success):
|
||||
def make_htlc_tx_output(amount_msat, local_feerate, revocationpubkey, local_delayedpubkey, success, to_self_delay):
|
||||
assert type(amount_msat) is int
|
||||
assert type(local_feerate) is int
|
||||
assert type(revocationpubkey) is bytes
|
||||
|
@ -355,7 +355,7 @@ def make_htlc_tx_output(amount_msat, local_feerate, revocationpubkey, local_dela
|
|||
script = bytes([opcodes.OP_IF]) \
|
||||
+ bfh(push_script(bh2u(revocationpubkey))) \
|
||||
+ bytes([opcodes.OP_ELSE]) \
|
||||
+ bitcoin.add_number_to_script(144) \
|
||||
+ bitcoin.add_number_to_script(to_self_delay) \
|
||||
+ bytes([opcodes.OP_CSV, opcodes.OP_DROP]) \
|
||||
+ bfh(push_script(bh2u(local_delayedpubkey))) \
|
||||
+ bytes([opcodes.OP_ENDIF, opcodes.OP_CHECKSIG])
|
||||
|
@ -753,7 +753,7 @@ class Peer(PrintError):
|
|||
htlc_basepoint=keypair_generator(keyfamilyhtlcbase, 0),
|
||||
delayed_basepoint=keypair_generator(keyfamilydelaybase, 0),
|
||||
revocation_basepoint=keypair_generator(keyfamilyrevocationbase, 0),
|
||||
to_self_delay=144,
|
||||
to_self_delay=143,
|
||||
dust_limit_sat=10,
|
||||
max_htlc_value_in_flight_msat=500000 * 1000,
|
||||
max_accepted_htlcs=5
|
||||
|
@ -1000,7 +1000,8 @@ class Peer(PrintError):
|
|||
local_feerate = chan.constraints.feerate,
|
||||
revocationpubkey=revocation_pubkey,
|
||||
local_delayedpubkey=remote_delayedpubkey,
|
||||
success = False) # timeout for the one offering an HTLC
|
||||
success = False, # timeout for the one offering an HTLC
|
||||
to_self_delay = chan.local_config.to_self_delay)
|
||||
preimage_script = htlcs_in_remote[0][0]
|
||||
htlc_output_txid = remote_ctx.txid()
|
||||
htlc_tx_inputs = make_htlc_tx_inputs(
|
||||
|
|
|
@ -196,7 +196,8 @@ class Test_LNBase(unittest.TestCase):
|
|||
local_feerate=local_feerate_per_kw,
|
||||
revocationpubkey=local_revocation_pubkey,
|
||||
local_delayedpubkey=local_delayedpubkey,
|
||||
success=success)
|
||||
success=success,
|
||||
to_self_delay=local_delay)
|
||||
our_htlc_tx_inputs = make_htlc_tx_inputs(
|
||||
htlc_output_txid=our_commit_tx.txid(),
|
||||
htlc_output_index=htlc_output_index,
|
||||
|
@ -256,7 +257,7 @@ class Test_LNBase(unittest.TestCase):
|
|||
success=True, cltv_timeout=0)
|
||||
|
||||
def test_find_path_for_payment(self):
|
||||
p = Peer('', 0, 'a')
|
||||
p = Peer('', 0, 'a', bitcoin.sha256('privkeyseed'))
|
||||
p.on_channel_announcement({'node_id_1': 'b', 'node_id_2': 'c', 'short_channel_id': bfh('0000000000000001')})
|
||||
p.on_channel_announcement({'node_id_1': 'b', 'node_id_2': 'e', 'short_channel_id': bfh('0000000000000002')})
|
||||
p.on_channel_announcement({'node_id_1': 'b', 'node_id_2': 'a', 'short_channel_id': bfh('0000000000000003')})
|
||||
|
|
|
@ -41,7 +41,7 @@ if __name__ == "__main__":
|
|||
wallet = Wallet(storage)
|
||||
wallet.start_threads(network)
|
||||
# start peer
|
||||
privkey = sha256('1234567890')
|
||||
privkey = sha256(str(time.time()))
|
||||
peer = Peer(host, port, pubkey, privkey, request_initial_sync=False, network=network)
|
||||
network.futures.append(asyncio.run_coroutine_threadsafe(peer.main_loop(), network.asyncio_loop))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue