def generate(self):
     pw.setOffline()
     addr = pw.Address()
     address = addr.address.decode("utf-8")
     private_key = addr.privateKey.decode("utf-8")
     seed = addr.seed
     return CryptoCoin(address, private_key, seed)
Esempio n. 2
0
def show_run(args):
    pw.setOffline()
    if args.batch or args.batch == 0:
        foils = Foil.get_batch(db_session, args.batch)
    else:
        foils = Foil.all(db_session)
    for foil in foils:
        json = foil.to_json()
        if args.check:
            addr = pw.Address(seed=foil.seed)
            balance = addr.balance(assetId=args.assetid)
            json["balance"] = balance
        print(json)
Esempio n. 3
0
def create_run(args):
    pw.setOffline()
    # get free batch id
    batch = Foil.next_batch_id(db_session)

    for i in range(args.batchcount):
        # create foil
        for i in range(args.batchsize):
            # create entry in db
            date = time.time()
            addr = pw.Address()
            foil = Foil(date, batch, addr.seed, None, None, None, None)
            db_session.add(foil)
        print(f"batch {batch}")
        # increment batch number
        batch += 1

    db_session.commit()
Esempio n. 4
0
def csv_run(args):
    pw.setOffline()
    foils = Foil.get_batches_starting_at(db_session, args.batch)
    with open("codes.csv", "w") as f:
        data = "batch,"
        if args.seeds:
            data += "seed"
        else:
            data += "address,amount,funding_txid,funding_date"
        f.write(data + "\n")
        for foil in foils:
            addr = pw.Address(seed=foil.seed)
            data = f"{foil.batch},"
            if args.seeds:
                data += f"\"{foil.seed}\""
            else:
                data += f"{addr.address},{foil.amount},{foil.funding_txid},{foil.funding_date}"
            f.write(data + "\n")
            sys.stdout.write(".")
            sys.stdout.flush()
# *  limitations under the License.
# ********************************************************************************
from ledgerblue.comm import getDongle
from ledgerblue.commException import CommException
import base58
import hashlib
import struct
import sys
import pywaves.crypto as pwcrypto
import pywaves as pw
import time

global dongle
dongle = None

pw.setOffline()

# 'T' for testnet, 'W' for mainnet
chain_id = 'W'

class colors:
    '''Colors class:
    reset all colors with colors.reset
    two subclasses fg for foreground and bg for background.
    use as colors.subclass.colorname.
    i.e. colors.fg.red or colors.bg.green
    also, the generic bold, disable, underline, reverse, strikethrough,
    and invisible work with the main class
    i.e. colors.bold
    '''
    reset = '\033[0m'
Esempio n. 6
0
        app.config["WAVESEXPLORER"] = 'https://testnet.wavesexplorer.com'
    else:
        app.config["WAVESEXPLORER"] = 'https://wavesexplorer.com'
    set_vital_setting("NODE_BASE_URL")
    set_vital_setting("WALLET_SEED")
    set_vital_setting("WALLET_ADDRESS")
    set_vital_setting("ASSET_ID")
    set_vital_setting("ASSET_MASTER_PUBKEY")
    set_vital_setting("TX_SIGNERS")
    try:
        app.config["TX_SIGNERS"] = json.loads(app.config["TX_SIGNERS"])
    except:
        raise Exception('TX_SIGNERS is not valid json') from None

    # set pywaves to offline mode and testnet
    pywaves.setOffline()
    if app.config["TESTNET"]:
        pywaves.setChain("testnet")

else: # paydb
    set_vital_setting("ASSET_NAME")
    set_vital_setting("OPERATIONS_ACCOUNT")

set_vital_setting("ADMIN_EMAIL")
set_vital_setting("FROM_EMAIL", "SECURITY_EMAIL_SENDER")
set_vital_setting("FROM_NAME")

set_vital_setting("SESSION_KEY", "SECRET_KEY")
set_vital_setting("PASSWORD_SALT", "SECURITY_PASSWORD_SALT")
set_vital_setting("SENDGRID_API_KEY", "MAIL_SENDGRID_API_KEY")
set_vital_setting("SERVER_NAME")
Esempio n. 7
0
def images_run(args):
    pw.setOffline()
    # consts
    ppi = 72 # points per inch
    dpi = 300
    mm_per_in = 25.4

    # page size
    width_mm = 160
    height_mm = 120
    width_in = width_mm / mm_per_in
    height_in = height_mm / mm_per_in
    width = width_in * dpi
    height = height_in * dpi
    width_pts = width_in * ppi
    height_pts = height_in * ppi

    # qrcode width and y position
    qrcode_x_center_mm = 20.4 + (39/2.0)
    qrcode_y_center_mm = 22.1 + (39/2.0)
    qrcode_x_center = qrcode_x_center_mm / mm_per_in * dpi
    qrcode_y_center = qrcode_y_center_mm / mm_per_in * dpi
    qrcode_width_mm = 39

    # calc qrcode pix values
    qrcode_width = qrcode_width_mm / mm_per_in * dpi
    qrcode_border = 0
    qrcode_boxes = 37 + qrcode_border + qrcode_border
    qrcode_box_size = int(qrcode_width / qrcode_boxes)

    # batch text
    font_size = 30
    font = ImageFont.truetype("Andale Mono.ttf", font_size)
    text_x_center_mm = 29.3 + (21.5/2.0)
    text_y_center_mm = 120 - 9 - (8.9/2.0)
    text_x_center = text_x_center_mm / mm_per_in * dpi
    text_y_center = text_y_center_mm / mm_per_in * dpi

    # create image directory
    path = "images"
    if not os.path.exists(path):
        os.makedirs(path)

    # create pdf
    fn = os.path.join(path, "images.pdf")
    pdf = canvas.Canvas(fn, pagesize=(width_pts, height_pts))

    foils = Foil.all(db_session)
    for foil in foils:
        filename = f"b{foil.batch}_{foil.id}.png"
        filename = os.path.join(path, filename)

        # create qr code image
        qr = qrcode.QRCode(version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, \
            box_size=qrcode_box_size, border=qrcode_border)
        qr.add_data(foil.seed)
        qr.make()
        qr_img = qr.make_image(fill_color="black", back_color="transparent")

        # create template image
        template = PIL.Image.new("RGBA", (int(width), int(height)))
        # draw batch text
        d = PIL.ImageDraw.Draw(template)
        text = f"b{foil.batch}"
        text_width, text_height = font.getsize(text)
        text_x = text_x_center - (text_width / 2)
        text_y = text_y_center - (text_height / 2)
        d.text((int(text_x), int(text_y)), text, font=font, fill="black")
        # paste qr code
        qrcode_x = qrcode_x_center - (qr_img.size[0] / 2)
        qrcode_y = qrcode_y_center - (qr_img.size[1] / 2)
        template.paste(qr_img, (int(qrcode_x), int(qrcode_y)))

        # save image
        print(filename)
        template.save(filename)

        # add page to pdf
        pdf.drawImage(filename, 0, 0, width_pts, height_pts, mask="auto")
        pdf.showPage()

    # save pdf
    print("saving pdf..")
    pdf.save()