Exemplo n.º 1
0
    def sign_transaction(self, tx, master_password, path=''):
        """
        Args:
            tx: hex transaction to sign
            master_password: master password for BIP32 wallets. Can be either a
                master_secret or a wif
            path (Optional[str]): optional path to the leaf address of the
                BIP32 wallet. This allows us to retrieve private key for the
                leaf address if one was used to construct the transaction.
        Returns:
            signed transaction

        .. note:: Only BIP32 hierarchical deterministic wallets are currently
            supported.

        """
        netcode = 'XTN' if self.testnet else 'BTC'

        # TODO review
        # check if its a wif
        try:
            BIP32Node.from_text(master_password)
            return bitcoin.signall(tx, master_password)
        except (AttributeError, EncodingError):
            # if its not get the wif from the master secret
            return bitcoin.signall(tx, BIP32Node.from_master_secret(master_password, netcode=netcode).subkey_for_path(path).wif())
    def sign_transaction(self, tx, master_password, path=''):
        """
        Args:
            tx: hex transaction to sign
            master_password: master password for BIP32 wallets. Can be either a
                master_secret or a wif
            path (Optional[str]): optional path to the leaf address of the
                BIP32 wallet. This allows us to retrieve private key for the
                leaf address if one was used to construct the transaction.
        Returns:
            signed transaction

        .. note:: Only BIP32 hierarchical deterministic wallets are currently
            supported.

        """
        netcode = 'XTN' if self.testnet else 'BTC'

        # TODO review
        # check if its a wif
        try:
            BIP32Node.from_text(master_password)
            return bitcoin.signall(tx, master_password)
        except (AttributeError, EncodingError):
            # if its not get the wif from the master secret
            return bitcoin.signall(
                tx,
                BIP32Node.from_master_secret(
                    master_password,
                    netcode=netcode).subkey_for_path(path).wif())
Exemplo n.º 3
0
    def sign_transaction(self, tx, master_password, path=''):
        # master_password can be either a master_secret or a wif
        netcode = 'XTN' if self.testnet else 'BTC'

        # check if its a wif
        try:
            BIP32Node.from_text(master_password)
            return pybitcointools.signall(tx, master_password)
        except EncodingError:
            # if its not get the wif from the master secret
            return pybitcointools.signall(tx, BIP32Node.from_master_secret(master_password, netcode=netcode).subkey_for_path(path).wif())
Exemplo n.º 4
0
 def pycoinPassword(user, password):
     # check if password is a wif. It it is return it witouth appending the email
     try:
         BIP32Node.from_text(password)
         return password
     except EncodingError:
         # backwards compatibility for collision of public wallets with same password
         if user.date_joined > datetime(2014, 12, 15).replace(tzinfo=pytz.UTC) \
                 and not user == util.mainAdminUser():
             return password + user.email
         return password
Exemplo n.º 5
0
    def sign_transaction(self, tx, master_password, path=''):
        # master_password can be either a master_secret or a wif
        netcode = 'XTN' if self.testnet else 'BTC'

        # check if its a wif
        try:
            BIP32Node.from_text(master_password)
            return pybitcointools.signall(tx, master_password)
        except EncodingError:
            # if its not get the wif from the master secret
            return pybitcointools.signall(
                tx,
                BIP32Node.from_master_secret(
                    master_password,
                    netcode=netcode).subkey_for_path(path).wif())
Exemplo n.º 6
0
def generate_revocation_addresses(config):
    key_path = config.key_path if config.key_path else ''
    # output_handle = open(config.output_file, 'w') if config.output_file else sys.stdout

    try:
        key = BIP32Node.from_text(config.extended_public_key)
    except:
        print('The extended public (or private) key seems invalid.')
        sys.exit()
    key_path_batch = key.subkey_for_path(key_path)
    for i in range(config.number_of_addresses):
        subkey = key_path_batch.subkey(i)
def generate_revocation_addresses(config):
    key_path = config.key_path if config.key_path else ''
    output_handle = open(config.output_file, 'w') if config.output_file else sys.stdout

    try:
        key = BIP32Node.from_text(config.extended_public_key)
    except:
        print('The extended public (or private) key seems invalid.')
        sys.exit()
    key_path_batch = key.subkey_for_path(key_path)
    for i in range(config.number_of_addresses):
        subkey = key_path_batch.subkey(i)
        output_handle.write("{0}\n".format(subkey.address(config.use_uncompressed)))

    if output_handle is not sys.stdout:
        output_handle.close()
Exemplo n.º 8
0
def generate_revocation_addresses(config):
    key_path = config.key_path if config.key_path else ''
    output_handle = open(config.output_file,
                         'w') if config.output_file else sys.stdout

    try:
        key = BIP32Node.from_text(config.extended_public_key)
    except:
        print('The extended public (or private) key seems invalid.')
        sys.exit()
    key_path_batch = key.subkey_for_path(key_path)
    for i in range(config.number_of_addresses):
        subkey = key_path_batch.subkey(i)
        output_handle.write("{0}\n".format(
            subkey.address(config.use_uncompressed)))

    if output_handle is not sys.stdout:
        output_handle.close()
Exemplo n.º 9
0
# change the receiving_key in config.py in the root folder.
from config import receiving_key, SATOSHIS_PER_MINUTE, BitCoreURL
from pycoin.key.BIP32Node import BIP32Node
from sqlalchemy.sql.functions import func

# logging.basicConfig(level=logging.DEBUG)
logging.basicConfig(level=logging.ERROR)

auth_app = Flask(__name__, static_folder='static')
#auth_app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/wifiportal21.db'
auth_app.config[
    'SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://wifiportal:wifiportalpw@localhost/wifiportal'

db = SQLAlchemy(auth_app)

receiving_account = BIP32Node.from_text(receiving_key)

SATOSHIS_PER_MBTC = 100 * 10**3
SATOSHIS_PER_BTC = 100 * 10**6

STATUS_NONE = 0
STATUS_PAYREQ = 1
STATUS_PAID = 2

RECEIVING = 0


class Guest(db.Model):
    uuid = db.Column(db.String(255), primary_key=True)
    mac = db.Column(db.String(17), unique=True)
    address = db.Column(db.String(40), unique=True)
Exemplo n.º 10
0
# change the receiving_key in config.py in the root folder.
from config import receiving_key, SATOSHIS_PER_MINUTE, BitCoreURL
from pycoin.key.BIP32Node import BIP32Node
from sqlalchemy.sql.functions import func

# logging.basicConfig(level=logging.DEBUG)
logging.basicConfig(level=logging.ERROR)

auth_app = Flask(__name__, static_folder='static')
#auth_app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/wifiportal21.db'
auth_app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://wifiportal:wifiportalpw@localhost/wifiportal'

db = SQLAlchemy(auth_app)

receiving_account = BIP32Node.from_text(receiving_key)


SATOSHIS_PER_MBTC = 100 * 10 ** 3
SATOSHIS_PER_BTC = 100 * 10 ** 6

STATUS_NONE = 0
STATUS_PAYREQ = 1
STATUS_PAID = 2

RECEIVING = 0

class Guest(db.Model):
    uuid = db.Column(db.String(255), primary_key=True)
    mac = db.Column(db.String(17), unique=True)
    address = db.Column(db.String(40), unique=True)