def payment_request():
    """Generates a http PaymentRequest object"""

    bc = Proxy()
    btc = bc.getnewaddress()

    #   Setting the 'amount' field to 0 (zero) should prompt the user to enter
    #   the amount for us but a bug in bitcoin core qt version 0.9.1 (at time of
    #   writing) wrongly informs us that the value is too small and aborts.
    #   https://github.com/bitcoin/bitcoin/issues/3095
    #   Also there can be no leading 0's (zeros).
    btc_amount = 100000
    serialized_pubkey = btc.to_scriptPubKey()

    pdo = o.PaymentDetails()
    # pdo.network = 'test'
    pdo.outputs.add(amount=btc_amount, script=serialized_pubkey)
    pdo.time = int(time())
    pdo.memo = "String shown to user before confirming payment"
    pdo.payment_url = "http://payment_ack.url"

    pro = o.PaymentRequest()
    pro.serialized_payment_details = pdo.SerializeToString()

    sds_pr = pro.SerializeToString()

    open("sds_pr_blob", "wb").write(sds_pr)
    headers = {"Content-Type": "application/bitcoin-payment", "Accept": "application/bitcoin-paymentrequest"}
    http_response_object = urllib2.Request("file:sds_pr_blob", None, headers)

    return http_response_object
Esempio n. 2
0
def payment_request():
    """Generates a http PaymentRequest object"""

    bc = Proxy()
    btc = bc.getnewaddress()

    #   Setting the 'amount' field to 0 (zero) should prompt the user to enter
    #   the amount for us but a bug in bitcoin core qt version 0.9.1 (at time of
    #   writing) wrongly informs us that the value is too small and aborts.
    #   https://github.com/bitcoin/bitcoin/issues/3095
    #   Also there can be no leading 0's (zeros).
    btc_amount = 100000
    serialized_pubkey = btc.to_scriptPubKey()

    pdo = o.PaymentDetails()
    #pdo.network = 'test'
    pdo.outputs.add(amount=btc_amount, script=serialized_pubkey)
    pdo.time = int(time())
    pdo.memo = 'String shown to user before confirming payment'
    pdo.payment_url = 'http://payment_ack.url'

    pro = o.PaymentRequest()
    pro.serialized_payment_details = pdo.SerializeToString()

    sds_pr = pro.SerializeToString()

    open('sds_pr_blob', 'wb').write(sds_pr)
    headers = {
        'Content-Type': 'application/bitcoin-payment',
        'Accept': 'application/bitcoin-paymentrequest'
    }
    http_response_object = urllib2.Request('file:sds_pr_blob', None, headers)

    return http_response_object
Esempio n. 3
0
def get_core_priv():
    proxy = Proxy()
    address = proxy.getnewaddress()
    # address = 'tb1qntuv4la0lh072jtr6ce3avrsghnc200dgamlpq'
    proxy._call("walletpassphrase", "P@55w0rd", 5)
    wif = proxy.dumpprivkey(address)
    proxy._call("walletlock")
    print("address", address)
    return CBitcoinSecret(str(wif))
Esempio n. 4
0
class BitcoinRpc():
    bitcoin_proxy = None

    def __init__(self):
        self.bitcoin_proxy = Proxy()

    def get_new_address(self):
        return self.bitcoin_proxy.getnewaddress()

    def get_balance(self):
        return self.bitcoin_proxy.getbalance()

    def get_transaction(self, txid):
        return self.bitcoin_proxy.gettransaction(lx(txid))
Esempio n. 5
0
async def _cmd_deposit(client, message, params):
    if not params[0] == _CMD_STR_DEPOSIT:
        return

    username = str(message.author)
    userid = str(message.author.id)
    user_mention = message.author.mention

    if (len(params) >= 2):
        await client.send_message(message.channel,
                                  "{0}!使い方を調べてきなさい!".format(user_mention))
        return
    # userid でDBからaddr取得
    addr = ''
    with closing(sqlite3.connect(DBNAME)) as connection:
        cursor = connection.cursor()
        row = dbaccessor.get_user_row(cursor, userid)
        # print(row)
        if row is not None:
            addr = row[walletdb.WalletNum.ADDR.value]
            if addr == INIT_ADDR_DUMMY:
                p = Proxy()
                addr = p.getnewaddress()
                if not dbaccessor.update_address(cursor, userid, addr):
                    await client.send_message(
                        message.channel, "{0}!失敗したわね!!".format(user_mention))
                    return
                connection.commit()
        else:
            await client.send_message(message.channel,
                                      "{0}!聞いたこと無い名前ね!".format(user_mention))
            return

    ################################
    ad_src = "**address**\r\n{0}\r\n".format(addr)
    disp_msg = ad_src
    await _disp_rep_msg(client, message, username, '', disp_msg)
    ################################
    return