コード例 #1
0
ファイル: lib.py プロジェクト: StorjRND/picopayments
def _load_incomplete_connection(handle, c2h_deposit_script_hex):

    client_pubkey = scripts.get_deposit_payer_pubkey(c2h_deposit_script_hex)
    hub_pubkey = scripts.get_deposit_payee_pubkey(c2h_deposit_script_hex)
    expire_time = scripts.get_deposit_expire_time(c2h_deposit_script_hex)

    hub_conn = db.hub_connection(handle=handle)
    assert(hub_conn is not None)
    assert(not hub_conn["complete"])

    h2c = db.micropayment_channel(id=hub_conn["h2c_channel_id"])
    assert(h2c["payer_pubkey"] == hub_pubkey)
    assert(h2c["payee_pubkey"] == client_pubkey)

    c2h = db.micropayment_channel(id=hub_conn["c2h_channel_id"])
    assert(c2h["payer_pubkey"] == client_pubkey)
    assert(c2h["payee_pubkey"] == hub_pubkey)

    hub_key = db.key(pubkey=hub_pubkey)

    return hub_conn, h2c, expire_time, hub_key
コード例 #2
0
def _load_incomplete_connection(handle, c2h_deposit_script_hex):

    client_pubkey = scripts.get_deposit_payer_pubkey(c2h_deposit_script_hex)
    hub_pubkey = scripts.get_deposit_payee_pubkey(c2h_deposit_script_hex)
    expire_time = scripts.get_deposit_expire_time(c2h_deposit_script_hex)

    hub_conn = db.hub_connection(handle=handle)
    assert (hub_conn is not None)
    assert (not hub_conn["complete"])

    h2c = db.micropayment_channel(id=hub_conn["h2c_channel_id"])
    assert (h2c["payer_pubkey"] == hub_pubkey)
    assert (h2c["payee_pubkey"] == client_pubkey)

    c2h = db.micropayment_channel(id=hub_conn["c2h_channel_id"])
    assert (c2h["payer_pubkey"] == client_pubkey)
    assert (c2h["payee_pubkey"] == hub_pubkey)

    hub_key = db.key(pubkey=hub_pubkey)

    return hub_conn, h2c, expire_time, hub_key
コード例 #3
0
ファイル: lib.py プロジェクト: StorjRND/picopayments
def _send_client_funds(connection_data, quantity):
    from picopayments_hub import api

    c2h_state = connection_data["c2h_state"]
    h2c_state = connection_data["h2c_state"]

    handle = connection_data["connection"]["handle"]
    result = db.get_next_revoke_secret_hash(handle=handle)
    next_revoke_secret_hash = result["next_revoke_secret_hash"]
    deposit_script_bin = h2c_state["deposit_script"]
    hub_pubkey = scripts.get_deposit_payer_pubkey(deposit_script_bin)
    wif = db.key(pubkey=hub_pubkey)["wif"]

    result = Mpc(api).full_duplex_transfer(
        wif, get_secret, h2c_state, c2h_state, quantity,
        next_revoke_secret_hash, etc.delay_time
    )

    return {
        "c2h_revoke_secrets": result["revokes"],
        "h2c_unnotified_commit": result["commit"],
        "h2c_state": result["send_state"],
        "c2h_state": result["recv_state"]
    }
コード例 #4
0
def _send_client_funds(connection_data, quantity):
    from picopayments_hub import api

    c2h_state = connection_data["c2h_state"]
    h2c_state = connection_data["h2c_state"]

    handle = connection_data["connection"]["handle"]
    result = db.get_next_revoke_secret_hash(handle=handle)
    next_revoke_secret_hash = result["next_revoke_secret_hash"]
    deposit_script_bin = h2c_state["deposit_script"]
    hub_pubkey = scripts.get_deposit_payer_pubkey(deposit_script_bin)
    wif = db.key(pubkey=hub_pubkey)["wif"]

    result = Mpc(api).full_duplex_transfer(wif, get_secret, h2c_state,
                                           c2h_state, quantity,
                                           next_revoke_secret_hash,
                                           etc.delay_time)

    return {
        "c2h_revoke_secrets": result["revokes"],
        "h2c_unnotified_commit": result["commit"],
        "h2c_state": result["send_state"],
        "c2h_state": result["recv_state"]
    }
コード例 #5
0
ファイル: lib.py プロジェクト: StorjRND/picopayments
def get_wif(pubkey):
    return db.key(pubkey=pubkey)["wif"]
コード例 #6
0
def get_wif(pubkey):
    return db.key(pubkey=pubkey)["wif"]