1
0

simnet/testnet support in bolt11, set max-htlc-value-in-flight

This commit is contained in:
Janus
2018-04-23 15:11:56 +02:00
committed by ThomasV
parent fd7469745e
commit 1ffaed718c
4 changed files with 36 additions and 13 deletions

View File

@@ -71,7 +71,7 @@ class TestBolt11(unittest.TestCase):
# Roundtrip
for t in tests:
o = lndecode(lnencode(t, PRIVKEY))
o = lndecode(lnencode(t, PRIVKEY), False, t.currency)
self.compare(t, o)
def test_n_decoding(self):

View File

@@ -1,16 +1,20 @@
import traceback
import sys
import json
import binascii
import asyncio
import time
from lib.bitcoin import sha256
from decimal import Decimal
from lib.constants import set_testnet, set_simnet
from lib.simple_config import SimpleConfig
from lib.network import Network
from lib.storage import WalletStorage
from lib.wallet import Wallet
from lib.lnbase import Peer, node_list
from lib.lightning_payencode.lnaddr import lnencode, LnAddr
import lib.constants as constants
if __name__ == "__main__":
if len(sys.argv) > 2:
@@ -38,8 +42,24 @@ if __name__ == "__main__":
# start peer
peer = Peer(host, port, pubkey, request_initial_sync=False, network=network)
network.futures.append(asyncio.run_coroutine_threadsafe(peer.main_loop(), network.asyncio_loop))
funding_satoshis = 200000
push_msat = 100000
# run blocking test
coro = peer.channel_establishment_flow(wallet, config)
fut = asyncio.run_coroutine_threadsafe(coro, network.asyncio_loop)
while network.asyncio_loop.is_running():
async def async_test():
RHASH = sha256(bytes.fromhex("01"*32))
await peer.channel_establishment_flow(wallet, config, funding_satoshis, push_msat)
pay_req = lnencode(LnAddr(RHASH, amount=Decimal("0.00000001")*10, tags=[('d', 'one cup of coffee')]), peer.privkey[:32])
print("payment request", pay_req)
while True:
await asyncio.sleep(1)
fut = asyncio.run_coroutine_threadsafe(async_test(), network.asyncio_loop)
while not fut.done():
time.sleep(1)
if fut.exception():
try:
raise fut.exception()
except:
traceback.print_exc()
network.stop()