Skip to main content

Bitcoin protocols made easy.

Project description

Documentation: https://austecon.github.io/polyglot/ Powered by BitSV: https://github.com/AustEcon/bitsv

Powered by BitSV: https://github.com/AustEcon/bitsv

https://img.shields.io/travis/AustEcon/polyglot.svg?branch=master&style=flat-square https://img.shields.io/pypi/pyversions/bitsv.svg?style=flat-square https://img.shields.io/badge/license-MIT-orange.svg?style=flat-square

Polyglot is designed to be Bitcoin SV’s most intuitive way to interact with a myriad of metanet protocols through python - a match made in heaven.

The style of this library is inspired by ofek’s library bit (bitsv’s predecessor)

Here are some examples:

Polyglot extends bitsv with the polyglot.Upload class, which inherits all of the properties of the bitsv.PrivateKey class such as checking balance, unspends, sending payments etc.

  1. Upload an image < 100kb with b:// protocol (https://github.com/unwriter/B):

>>> import polyglot
>>> uploader = polyglot.Upload('your private key goes here in WIF format')
>>> # Optional parameters shown for completeness are populated from the file path by default
>>> uploader.upload_b(file, media_type=None, encoding=None, file_name=None)

See image here: https://bico.media/252ea6d5a4a4bfc956518403f6e5aa2ced1c2590d1120cd75341e0233d1b06e3

This works for a wide range of media types.

  1. Upload large multimedia > 100kb with bcat:// protocol (https://bcat.bico.media/):

>>> file = "C:/Users/username/Pictures/BSV_banner.jpg""
>>> uploader.upload_bcat(file)

See image here: https://bico.media/be8b6a79e66934d3419265fbf3295d03e331a4c08098ae7f817a7592ffaedd2b

Please note: For BCAT protocol, it is very important to have an adequate number of “fresh” utxos with 1 confirmation to generate the parts. To do this see #3 Utilities (next).

  1. Basic Utilities

Some basic utilities are included for working with utxo splitting and manually extracting the media type / handling of the file based on the file path (with extension) - to cover some potentially more advanced useage patterns of the B and BCAT protocols.

>>> uploader.get_media_type_for_file_name(file) #--> media_type
>>> uploader.get_encoding_for_file_name(file) #--> encoding,
>>> uploader.get_filename(path) #--> file_name.ext)

But additionally:

>>> uploader.get_largest_utxo(self) #--> largest utxo (for splitting)
>>> uploader.split_biggest_utxo(self) #--> splits utxo into 100000 satoshi amounts
>>> uploader.filter_utxos_for_bcat(self) #-- > filters utxos with 0 conf or too low amount to handle a 100kb tx
>>> get_file_ext(file) #--> .ext
>>> calculate_txid(rawtx) #--> txid

Features

Currently Working:

1. Uploading

  • B:// (for multimedia up to 100kb) - https://github.com/unwriter/B

  • BCAT:// (for multimedia up to 310mb uncompressed, 110GB with nested gzip) - https://bcat.bico.media/

2. UTXO management

  • Utilities for splitting / selecting UTXOs for a single private key - especially for use in BCAT protocol.

  • Bip32 level UTXO management is also planned

Planned:

1. HTML reference converter

A Class that will allow for easy conversion of metanet style referencing:

  • B:// (ref. by txid)

  • C:// (ref. by sha256 hash of content)

  • D:// (ref. by dynamic state - linked to identity system)

To localhost paths or mainstream internet urls as well as toggling it all back and forth.

This will allow quick iteration of building a web application on the local machine but also rapid conversion to b://, c:// d:// etc. referencing styles for deployment to the blockchain.

Would just need a dictionary of {path : B:// reference} pairs for example to be swapped back and forth. Many other features in mind (possibly for another repository).

2. Downloading

Should be able to specify content by:

  • B:// (ref. by txid)

  • C:// (ref. by sha256 hash of content)

  • D:// (ref. by dynamic state - linked to identity system)

  • Should work for content uploaded via BCAT

And have it be downloaded.

If it is a static html page then should optionally allow retreival of all referenced content to reconstruct the entire webpage on the local machine.

3. Identity protocols (Money Button, AIP etc.):

I would like to add a very simple interface for interacting with - AIP (https://github.com/BitcoinFiles/AUTHOR_IDENTITY_PROTOCOL) - other ID protocols (e.g. Ryan X. Charles of Money Button has been working hard on this area)

4. “Linking / mapping / database functions”:

Installation

Polyglot is distributed on PyPI as a universal wheel and is available on Linux/macOS and Windows and supports Python 3.6+. pip >= 8.1.2 is required.

$ pip install polyglot-bitcoin # pip3 if pip is Python 2 on your system.

Credits

  • CoinGeek / nChain / Bitcoin Association for putting on an amazing hackathon from which this project was born!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polyglot-bitcoin-0.0.3.tar.gz (9.1 kB view details)

Uploaded Source

File details

Details for the file polyglot-bitcoin-0.0.3.tar.gz.

File metadata

  • Download URL: polyglot-bitcoin-0.0.3.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.1

File hashes

Hashes for polyglot-bitcoin-0.0.3.tar.gz
Algorithm Hash digest
SHA256 a683f579f36155e0017f71640680cd3ab959d0b172b145f7638cd68bb590d5e3
MD5 11fabdd40f846f3259f37d50fe0b1eca
BLAKE2b-256 b6425c63d84e5af999f9e44787b43e63977fce9c26c635b993b24937ba9f2633

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page