コード例 #1
0
def in_mem_chan_keys():
    sk = SecretKey(get_random_sk_bytes())
    commitment_seed = get_random_sk_bytes()
    channel_value_satoshis = pow(2, 64) - 1
    key_derivation_params = (0, 1)

    return InMemoryChannelKeys(sk, sk, sk, sk, sk, commitment_seed,
                               channel_value_satoshis, key_derivation_params)
コード例 #2
0
ファイル: test_peer_handler.py プロジェクト: sr-gi/ldk-python
def peer_manager(channel_message_handler, routing_message_handler):
    our_node_secret = SecretKey(get_random_sk_bytes())
    ephemeral_random_data = get_random_bytes(32)
    logger = LDKLogger(Logger())

    return PeerManager(channel_message_handler, routing_message_handler,
                       our_node_secret, ephemeral_random_data, logger)
コード例 #3
0
ファイル: test_chan_utils.py プロジェクト: sr-gi/ldk-python
def holder_commitment_tx_data(tx):
    counterparty_sk = SecretKey(get_random_sk_bytes())

    counterparty_pk = PublicKey.from_secret_key(counterparty_sk)
    counterparty_sig = counterparty_sk.sign(tx.hex())
    holder_pk = PublicKey(get_random_pk_bytes())
    keys = TxCreationKeys(
        PublicKey(get_random_pk_bytes()),
        PublicKey(get_random_pk_bytes()),
        PublicKey(get_random_pk_bytes()),
        PublicKey(get_random_pk_bytes()),
        PublicKey(get_random_pk_bytes()),
    )
    feerate_kw = 1000

    # HTLC DATA
    offered = True
    amount_msat = 500000
    cltv_expiry = 30
    payment_hash = PaymentHash(get_random_bytes(32))
    tx_out_index = None

    htlc_out = HTLCOutputInCommitment(offered, amount_msat, cltv_expiry, payment_hash, tx_out_index)
    htlc_data = [(htlc_out, None)]

    return Transaction.from_bytes(tx), counterparty_sig, holder_pk, counterparty_pk, keys, feerate_kw, htlc_data
コード例 #4
0
def test_in_memory_channel_keys_getters():
    funding_key = SecretKey(get_random_sk_bytes())
    revocation_base_key = SecretKey(get_random_sk_bytes())
    payment_key = SecretKey(get_random_sk_bytes())
    delayed_payment_base_key = SecretKey(get_random_sk_bytes())
    htlc_base_key = SecretKey(get_random_sk_bytes())
    commitment_seed = get_random_sk_bytes()
    channel_value_satoshis = pow(2, 64) - 1
    key_derivation_params = (0, 1)

    in_mem_chan_keys = InMemoryChannelKeys(
        funding_key,
        revocation_base_key,
        payment_key,
        delayed_payment_base_key,
        htlc_base_key,
        commitment_seed,
        channel_value_satoshis,
        key_derivation_params,
    )

    assert in_mem_chan_keys.funding_key == funding_key
    assert in_mem_chan_keys.revocation_base_key == revocation_base_key
    assert in_mem_chan_keys.payment_key == payment_key
    assert in_mem_chan_keys.delayed_payment_base_key == delayed_payment_base_key
    assert in_mem_chan_keys.htlc_base_key == htlc_base_key
    assert in_mem_chan_keys.commitment_seed == commitment_seed
コード例 #5
0
def test_public_key_from_sk():
    sk = SecretKey(get_random_sk_bytes())
    assert isinstance(PublicKey.from_secret_key(sk), PublicKey)
コード例 #6
0
def test_secret_key_cmp():
    sk_bytes = get_random_sk_bytes()
    assert SecretKey(sk_bytes) == SecretKey(sk_bytes)
    assert SecretKey(get_random_sk_bytes()) != SecretKey(sk_bytes)
コード例 #7
0
def test_secret_key_str():
    sk_bytes = get_random_sk_bytes()
    assert str(SecretKey(sk_bytes)) == sk_bytes.hex()
コード例 #8
0
def test_secret_key_sign():
    message = "test message"
    sk = SecretKey(get_random_sk_bytes())
    sig = sk.sign(message)
    assert isinstance(sig, Signature)
コード例 #9
0
def test_secret_key_serialize():
    sk_bytes = get_random_sk_bytes()
    assert SecretKey(sk_bytes).serialize() == sk_bytes
コード例 #10
0
def test_secret_key_init():
    assert isinstance(SecretKey(get_random_sk_bytes()), SecretKey)
コード例 #11
0
def keys_manager():
    seed = get_random_sk_bytes()
    network = Network.mainnet()
    s_time_sec, s_time_nsec = str(time.time()).split(".")

    return KeysManager(seed, network, int(s_time_sec), int(s_time_nsec))