Ejemplo n.º 1
0
try:
    import paymentrequest_pb2 as pb2
except ImportError:
    sys.exit("Error: could not find paymentrequest_pb2.py. Create it with 'protoc --proto_path=lib/ --python_out=lib/ lib/paymentrequest.proto'")

import bitcoin
import util
import transaction
import x509
from util import print_error

REQUEST_HEADERS = {'Accept': 'application/bitcoin-paymentrequest', 'User-Agent': 'Electrum'}
ACK_HEADERS = {'Content-Type':'application/bitcoin-payment','Accept':'application/bitcoin-paymentack','User-Agent':'Electrum'}

ca_path = requests.certs.where()
ca_list, ca_keyID = x509.load_certificates(ca_path)


# status of payment requests
PR_UNPAID  = 0
PR_EXPIRED = 1
PR_UNKNOWN = 2     # sent but not propagated
PR_PAID    = 3     # send and propagated
PR_ERROR   = 4     # could not parse

import json


def get_payment_request(url):
    u = urlparse.urlparse(url)
    if u.scheme in ['http', 'https']:
Ejemplo n.º 2
0
import rsakey

from bitcoin import TYPE_ADDRESS

REQUEST_HEADERS = {
    'Accept': 'application/bitcoin-paymentrequest',
    'User-Agent': 'Electrum'
}
ACK_HEADERS = {
    'Content-Type': 'application/bitcoin-payment',
    'Accept': 'application/bitcoin-paymentack',
    'User-Agent': 'Electrum'
}

ca_path = requests.certs.where()
ca_list, ca_keyID = x509.load_certificates(ca_path)

# status of payment requests
PR_UNPAID = 0
PR_EXPIRED = 1
PR_UNKNOWN = 2  # sent but not propagated
PR_PAID = 3  # send and propagated


def get_payment_request(url):
    u = urlparse.urlparse(url)
    if u.scheme in ['http', 'https']:
        response = requests.request('GET', url, headers=REQUEST_HEADERS)
        data = response.content
        print_error('fetched payment request', url, len(data))
    elif u.scheme == 'file':
Ejemplo n.º 3
0
try:
    import paymentrequest_pb2
except ImportError:
    sys.exit("Error: could not find paymentrequest_pb2.py. Create it with 'protoc --proto_path=lib/ --python_out=lib/ lib/paymentrequest.proto'")

import bitcoin
import util
import transaction
import x509


REQUEST_HEADERS = {'Accept': 'application/bitcoin-paymentrequest', 'User-Agent': 'Electrum'}
ACK_HEADERS = {'Content-Type':'application/bitcoin-payment','Accept':'application/bitcoin-paymentack','User-Agent':'Electrum'}

ca_path = requests.certs.where()
ca_list = x509.load_certificates(ca_path)


class PaymentRequest:
    def __init__(self, config):
        self.config = config
        self.outputs = []
        self.error = ""
        self.dir_path = os.path.join( self.config.path, 'requests')
        if not os.path.exists(self.dir_path):
            os.mkdir(self.dir_path)

    def read(self, url):
        self.url = url
        u = urlparse.urlparse(url)
        self.domain = u.netloc
Ejemplo n.º 4
0
def load_ca_list():
    global ca_list, ca_keyID
    if ca_list is None:
        ca_list, ca_keyID = x509.load_certificates(ca_path)
Ejemplo n.º 5
0
def load_ca_list():
    global ca_list, ca_keyID
    if ca_list is None:
        ca_list, ca_keyID = x509.load_certificates(ca_path)
Ejemplo n.º 6
0
import util
import transaction
import x509

REQUEST_HEADERS = {
    'Accept': 'application/bitcoin-paymentrequest',
    'User-Agent': 'Electrum'
}
ACK_HEADERS = {
    'Content-Type': 'application/bitcoin-payment',
    'Accept': 'application/bitcoin-paymentack',
    'User-Agent': 'Electrum'
}

ca_path = requests.certs.where()
ca_list = x509.load_certificates(ca_path)


class PaymentRequest:
    def __init__(self, config):
        self.config = config
        self.outputs = []
        self.error = ""
        self.dir_path = os.path.join(self.config.path, 'requests')
        if not os.path.exists(self.dir_path):
            os.mkdir(self.dir_path)

    def read(self, url):
        self.url = url
        u = urlparse.urlparse(url)
        self.domain = u.netloc