Giter Club home page Giter Club logo

stacks.js's Introduction

Stacks.js Test Action Badge Monorepo Version Label

Important

Looking for Nakamoto updates? Use version 6.13.0 or later to test the latest nakamoto changes. e.g., npm install @stacks/[email protected]

Welcome to the Stacks.js repository, your one-stop solution for working with the Stacks blockchain using JavaScript/TypeScript. This repository nests a collection of packages designed to provide you with the essential building blocks to work with the Stacks blockchain from JavaScript/TypeScript.

Packages

For installation instructions and usage guidelines, refer to the respective `README`` in each package directory.

Connecting Wallets

  • @stacks/connect Connect web application to Stacks wallet browser extensions (separate repo).

Stacks Primitives

  • @stacks/transactions Construct, decode transactions, and work with Clarity smart contracts on the Stacks blockchain.
  • @stacks/wallet-sdk Library for building wallets, managing accounts, and handling keys for the Stacks blockchain.
  • @stacks/storage Store and fetch files with Gaia, the decentralized storage system.
  • @stacks/encryption Encryption functions used by stacks.js packages.
  • @stacks/auth Construct and decode authentication requests for Stacks apps.
  • @stacks/profile Functions for manipulating user profiles.
  • @stacks/network Network and API library for working with Stacks blockchain nodes.
  • @stacks/common Common utilities used by stacks.js packages.

Native Smart Contract Interaction

Others

  • @stacks/cli Command line interface to interact with auth, storage, and Stacks transactions.
  • @stacks/keychain DEPRECATED: replaced by @stacks/wallet-sdk

Reference

Auto-generated library references for the stacks.js packages are located at stacks.js.org.

Migrating from previous versions

To migrate your app from blockstack.js to Stacks.js follow the steps in the migration guide.

Bugs and feature requests

If you encounter a bug or have a feature request, we encourage you to follow the steps below:

  1. Search for existing issues: Before submitting a new issue, please search existing and closed issues to check if a similar problem or feature request has already been reported.
  2. Open a new issue: If it hasn't been addressed, please open a new issue. Choose the appropriate issue template and provide as much detail as possible, including steps to reproduce the bug or a clear description of the requested feature.
  3. Evaluation SLA: Our team reads and evaluates all the issues and pull requests. We are available Monday to Friday and we make our best effort to respond within 7 business days.

Please do not use the issue tracker for personal support requests or to ask for the status of a transaction. You'll find help at the #support Discord channel.

Contributing & Development

Development of Stacks.js happens in the open on GitHub, and we are grateful to the community for contributing bug fixes and improvements. Read below to learn how you can take part in improving the Stacks.js.

Code of Conduct

Please read Stacks.js' Code of Conduct since we expect project participants to adhere to it.

Contributing Guide

Read our contributing guide to learn about our development process, how to propose bug fixes and improvements, and how to build and test your changes.

Community

Join our community and stay connected with the latest updates and discussions:

License

Stacks.js is open source and released under the MIT License.

stacks.js's People

Contributors

agraebe avatar ahsan-javaid avatar asimm241 avatar aulneau avatar beguene avatar brandonparee avatar dependabot[bot] avatar diwakergupta avatar fariedt avatar friedger avatar github-actions[bot] avatar hstove avatar hugocaillard avatar janniks avatar jcnelson avatar kantai avatar kyranjamie avatar lakshmilavanyakasturi avatar larrysalibra avatar libanhassan avatar marcosc90 avatar pradel avatar reedrosenbluth avatar saralab avatar scott-martin avatar shea256 avatar shreyasthiagaraj avatar wbobeirne avatar yknl avatar zone117x avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stacks.js's Issues

Use argparse instead of cement

The command-line input is currently parsed using cement, we want to switch to argparse.

Also, instead of

opendig -u <openname>

We should be able to do

opendig +<openname>

And if no '+' is given then check if it's a valid domain name and query the dns_resolver instead

update the values of the output format for the lookup command

Earlier we discussed changing the names of the address, script, public key, etc. to make sure they all have the "owner" prefix to make it clear that they all pertain to the owner. "owner" is also a more appropriate term than "sender" which is really ambiguous.

At this point, I'm suggesting we update the values of the lookup response to the following:

[
    {
        "first_registered": 374085,
        "last_renewed": 374085,
        "revoked": false,
        "owner_address": "19MoWG8u88L6t766j7Vne21Mg4wHsCQ7vk",
        "owner_script": "76a9145bb0253ff5a02082942615d3d215079e9c5bdb9f88ac",
        "owner_public_key": "03a75eab0d1e1e7e71a237c5580c4ff060d6033391ab7cbd9e3cf881f41633a68b",
        "value_hash": "c9efe60e0eca3802777a8accee4e38ded8422891"
    }
]

Allowed multiple registration of the same .id

Today I tried using the command line to register a few handles and I was able to register the same handle 4 times with 4 separate payments. Each time I tried 'lookup' the name showed as unregistered. The name has since verified and shows with 'names' command, bit I'm assuming this is not meant to be a feature?

Had the zope 3.6+ issue when installing, now fixed if this is of any significance. Ubuntu 14.04 64bit

use coinrpc

the ons_resolver code currently uses an old way of talking to namecoind that should be deprecated. need to:

  1. remove namecoinrpc/ folder
  2. In ons_resolver.py .. use [coinrpc][http://github.com/openname/coinrpc] instead. More specifically,

namecoind = NamecoindServer(server, NAMECOIND_PORT, NAMECOIND_USER, NAMECOIND_PASSWD)

can be imported from coinrpc

mainnet addresses/private keys even if the blockchain in use is in testset mode

When I run the walletcommand for the first time it creates addresses of the mainnet type (beginning with 1xxxxx), even if I the blockstack-server node is linked to a bitcoin node in testnet mode. In that case it should initialize blockstack wallet with testnet addresses/private keys (beginning with mxxxx, nxxxx, etc.)

Optionally supply a "fund-with" private key

Add support to all name operations to allow a "fund-with" private key that actually sends the BTC. If supplied, the owner address will receive all of its value back, and the "fund-with" address will pay the mining fee and output fees.

Interface improvement suggestions

In this issue I'm outlining a list of interface improvement suggestions. It'd be nice to discuss them here and if you'd like, I can separate them out into different issues. Here they are:

Blockstack Info

In this command, are we going to have multiple queues like one for registrations and one for transfers? I noticed how you put "queue" at the front in order to keep them together in alphabetical sorting, but I'd like to suggest as an alternative that we have a top level object called "queues" and then have lists in the queues object for "registrations", "transfers", etc. That could look something like this:

{
  "queues": {
    "registrations": [],
    "transfers": []
  }
}

It looks cleaner this way and "queue_register" is a bit of a hard name to read. It took my brain a bit to process it the first time I saw it. Alternatively, if we only plan on having a registration queue, then we can change the name of this list to "registration_queue".

Blockstack Lookup

I'm thinking that we might want to change "data_record" to "data", as it looks much cleaner this way.

On the other hand, one could make a good case for being more explicit. If a user would be confused by seeing "data" instead of "data_record" then it probably makes sense to keep it. Otherwise, I'd simplify.

Blockstack Names

The labels in this command should be updated to be consistent. This means either "names_owned" should be changed to "names" OR "addresses[0].names" should be changed to "addresses[0].names_owned".

I'm inclined towards the former simply because the command is blockstack names but I feel like it could go either way.

Blockstack Wallet

As we discussed, we should remove this command from the default set of commands and roll it into the advanced mode. In addition, any command that relies on and interacts with public keys, addresses, and/or balances but not private keys should not require unlocking of the wallet. This can be simply addressed by storing an unencrypted public key alongside the encrypted private key. You might be already doing this (so in that case all you need to do is access it and derive the addresses).

Blockstack Config

I'm wondering whether we should update the blockstack config command so that it is only a "set" command and not a "get" command. The reason I'm thinking this makes sense is that it's a bit confusing to have certain pieces of information in the "info" command that can be obtained through another command (the "config" command) that returns a subset of that information (just the server info and advanced mode). It also seems to make sense to have the config option as only for "configuring" / setting configs.

This change would mean that if users want to get the configuration details, they would have to run blockstack info. The updated blockstack config command would then only be valid if options were provided.

blockstack-cli fails in certain connections

registering and updating fails when trying from my work connection, but works from a home connection.

info, price, balance, deposit all seem to work.

This happens after a reboot, so it doesn't seem to be a process failing.

Calculate fees

When using the blockstack register command, the software appears to add a default fee of .00016 BTC. Add a way to estimate the fee necessary to have the transaction included in the next block (or show options for "slow," "medium," "expedited" transaction fees).

Improvements to error messages

I went through a bunch of the commands and noted error messages that are either missing or invalid or could use some improvements to better communicate to the user what is going on.

Here's the list I came up with:

Cost, Lookup, Transfer, Update and Whois

With an invalid name is provided to either the cost, lookup, transfer, update, or whois command, this should be reported to the user and the reason the name is invalid should be specified.

As an example, with the commands blockstack cost a or blockstack lookup a (or the equivalents for transfer, update and whois), the error message should be updated to the following:

The name specified is invalid. Names must be included with a valid TLD.

With blockstack cost % or blockstack lookup %, the error message should be updated to the following:

The name specified is invalid. Names may only contain alphanumeric characters, dashes, and underscores and must end with a period followed by a valid TLD.

With the name blockstack cost .id or blockstack lookup .id, the error message should be updated to the following:

The name specified is invalid. Names must be at least one character long, not including the TLD.

Cost

In particular, with the cost command, there is currently no error message for the invalid command blockstack cost .id. Instead the following is returned:

$ blockstack cost .id
{
    "details": {
        "registration_fee": 6.25e-05,
        "transactions_fee": 0.00016
    },
    "total_cost": 0.00022250000000000001
}

We should update the error message to the one specified in the previous section.

Next, when a name registration costs more than the balance, the following error message should be returned:

The cost of the name you're trying to register exceeds your wallet's balance.

Transfer

Update the error message shown when an invalid name transfer is attempted:

The name you're trying to transfer is not in your possession.

Update

Update the error message shown when an invalid name update is attempted:

The name you're trying to update is not in your possession.

Register

With the register command, if a name is invalid the error message returned should indicate the name is invalid. Currently this message is returned: "This namespace doesn't exist, try using namespaces like .id". We should use the same error messages specified in the other commands above, depending on whether the name is lacking a TLD or whether the name doesn't have any characters or whether invalid characters are used.

Also, if blockstack register .id is entered, the user should not be taken to register the name. Instead, an error should be thrown.

error: command 'cc' failed with exit status 1 (OS X El Captian 10.11.4)

Typed the command line "sudo pip install blockstack" and got the following error message:

_**1 error generated.

error: command 'cc' failed with exit status 1


Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;file='/private/tmp/pip_build_root/scrypt/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-W6yXcl-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/tmp/pip_build_root/scrypt
Storing debug log for failure in /Users/omaritani/Library/Logs/pip.log
Omars-MacBook-Pro-2:~ omaritani$ **
_

Then tried the command line " ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install pycrypto" and got the following message:

_Omars-MacBook-Pro-2:~ omaritani$ ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install pycrypto
Requirement already satisfied (use --upgrade to upgrade): pycrypto in /Library/Python/2.7/site-packages
Cleaning up...
Omars-MacBook-Pro-2:~ omaritani$ _

Ability to withdraw bitcoins from the Blockstack wallet

I would like to withdraw some Bitcoins form my Blockstack wallet:
blockstack withdraw address amount

Alternatively, documentation could be written on how to decrypt the private key so that I can import the wallet to another bitcoin client and send out the Bitcoins that way.

RPC endpoint

In the develop branches of blockstack-server and blockstack-client, I've been migrating our RPC implementation off of Twisted's JSON/netstring protocol over to something more conventional, with less dependencies. The code currently uses Python's SimpleXMLRPCServer implementation, and expose all server methods to the client via an HTTP(S) interface. However, we often pass Python dictionaries over the RPC interface, which don't serialize well in XMLRPC (in particular, dictionaries with integer keys). So what I've ended up doing is adding a custom serializer that translates each RPC into a JSON string and back--effectively implementing JSONRPC over XMLRPC.

This might sound extremely kludgy on first glance, but consider:

  • Blockstack-server's RPC paths are disk-bound, since each RPC makes a query against a SQLite file. The overhead of extra serialization and deserialization is negligible by comparison.
  • There is no JSON equivalent to SimpleXMLRPCServer in the Python standard library. Anything we do to remove the XML would either introduce a dependency, or require us to build and ship our own SimpleJSONRPCServer implementation.
  • Serializing the RPC into a JSON dict and back--fits into less than 50 lines of easy-to-understand Python. That's considerably smaller than even a modest JSONRPC HTTP server and client, and the bulk of the complex code is already maintained by the Python developers.

The only downside I see to this approach is that this adds a bad design smell, because it uses two serialization formats where only one is strictly necessary. If there was a SimpleJSONRPCServer and jsonrpclib.ServerProxy equivalent for JSON that didn't add an external dependency, I'd spring for that in a heartbeat.

Potential error with the blockstack register command

Hey @muneeb-ali. I'm pretty confident I downloaded the latest version when you helped me out yesterday (I pasted the exact command you gave me and installed from the develop branch). Unfortunately I'm getting an error with the register command when I provide just the name and nothing more. Has the update command not been separated out from register yet or is there some other issue here? I'm inclined to think the former because of the error message. But in any case, I wanted to report this and provide the response I'm getting. Here it is:

$ blockstack register boomboom.id
Registering boomboom.id will cost 0.00041 BTC. Continue? (y/n): y
{
    "error": "Unexpected error, <Fault 1: \"<type 'exceptions.TypeError'>:register() takes exactly 3 arguments (2 given)\">",
    "help": "Try getting latest version of CLI with sudo pip install blockstack --upgrade"
}

Comply with pep8

The code currently doesn't conform to pep8 formatting guidelines

Update transaction successfully broadcast but record json wasn't stored

blockstore-cli update successfully broadcast this transaction:
https://live.blockcypher.com/btc/tx/91cb40ea52ded01b3de02a9fb385231e815f0c955c7735a404b00219005b9792/

But the user data doesn't look like it made it into the dht. I initially suspected the problem with my dht-mirror (blockstack-packages/blockstack-dht-mirror#4) was at fault.

Looking at the output of the command, however:

blockstore-cli update theblockchain.id "$(cat ~/theblockchain.json)" "$(cat ~/theblockchain.key)"
{
    "data": "69642b47b034a6786a53aad537f716420748a1312afaf6f3cd6c45109b3fcccf200ef65b0d17eb",
    "error": "No transaction hash given",
    "success": true
}

blockstore-cli appears to have exited before calling store_name_record to persist the data in the dht.

The above output seems consistent with exiting here:
https://github.com/blockstack/blockstore-client/blob/master/blockstore_client/client.py#L879

Haven't yet tried to replicate.

pip install blockstack fails osx 10.11.4

$ sudo pip install blockstack

fails with:

scrypt-1.1.6/lib/crypto/crypto_aesctr.c:38:10: fatal error: 'openssl/aes.h' file not found

I used the following to work around this:

$ env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install blockstack

but then hit:

copying LICENSE -> /System/Library/Frameworks/Python.framework/Versions/2.7/

error: [Errno 1] Operation not permitted: '/System/Library/Frameworks/Python.framework/Versions/2.7/LICENSE'

(All of this was executed as root).

sh-3.2# pip --version
pip 1.5.4 from /Library/Python/2.7/site-packages/pip-1.5.4-py2.7.egg (python 2.7)
sh-3.2# python --version
Python 2.7.10

updates to password behavior

The wallet setup process is awesome. Nice flow.

The only issue I noticed was that passwords were displayed in plaintext. I figured we'd get around to updating this at some point and I didn't think this was an urgent issue until @guylepage3 took a screenshot (thankfully he blocked out the password).

After we launch the CLI, we're probably going to be getting a bunch of people providing us with feedback - some will send us screenshots of their terminals and I fear that some will accidentally take screenshots with their passwords.

The way to fix this would be to treat the input as a masked password input. I've seen some command line input tools have native support for this but I haven't checked in a while.

Is this something we can add in quickly before the release? No worries if not, but if are able to it might save us some grief from the HN crowd.

Incorrect text?

When attempting to register a name will forbidden characters, eg 'qwert-y' the error message reads:

' The name specified is invalid. Names may only contain alphanumeric characters, dashes, and underscores."

Sorry if this doesn't warrant posting here.

New commands for blockstore-cli

Need:

  • blockstore-cli get_all_names [offset] [count]
  • blockstore-cli get_names_in_namespace <namespace_id> [offset] [count]
  • blockstore-cli get_consensus_at <block number>

Add more as we think of them.

multithreaded check from multiple servers

in ons_resolver.py .. it currently checks a few servers in a loop (not multithreaded so server 1 is checked and then server 2 is checked and so on). need to change this:

  1. all servers are queried in parallel, using threads
  2. can give an option where a reply from n out of m servers is considered satisfactory e.g., if 3 out of 5 servers confirm that it's the same data then we can accept the data as valid

server address doesn't get picked up from .ini file

In client.py, server_host remains the default localhost regardless of the value in the .ini file

def session ()
global default_proxy
    print server_host
    proxy = BlockstoreRPCClient(server_host, server_port)

Running `blockstack info` times out

I noticed that around 3:40pm (UTC) that I had problems connecting to server.blockstack.org

The error message was:
$ blockstack info
{
"advanced_mode": "false",
"cli_version": "0.0.12.7",
"server_alive": false,
"server_error": "timeout: timed out",
"server_host": "server.blockstack.org",
"server_port": "6264"
}

After waiting several minutes and trying again, I got through:
$ blockstack info
{
"advanced_mode": "false",
"cli_version": "0.0.12.7",
"consensus_hash": "0032dd1376228665819bb557e8f46b2a",
"last_block_processed": 406951,
"last_block_seen": 406959,
"server_alive": true,
"server_host": "server.blockstack.org",
"server_port": "6264",
"server_version": "0.0.10.3"
}

Then immediately after getting the success message, I ran it one more time and this time it failed.
$ blockstack info
{
"advanced_mode": "false",
"cli_version": "0.0.12.7",
"server_alive": false,
"server_error": "timeout: timed out",
"server_host": "server.blockstack.org",
"server_port": "6264"
}

I'm connecting from Hong Kong on a home internet connection. Happy to give more info if needed.

Rename parser.py

I was trying to install blockstack-profiles package which pulls in pycparser and noticed the following error:

Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Users/muneeb/Dropbox (Personal)/work/blockstack/registrar/registrar/debug.py", line 16, in <module>
    from blockstack_profiles import resolve_zone_file_to_profile
  File "/Users/muneeb/.virtualenvs/registrar/lib/python2.7/site-packages/blockstack_profiles/__init__.py", line 1, in <module>
    from token_signing import sign_token_record, sign_token_records
  File "/Users/muneeb/.virtualenvs/registrar/lib/python2.7/site-packages/blockstack_profiles/token_signing.py", line 5, in <module>
    from jsontokens import TokenSigner, TokenVerifier, decode_token
  File "/Users/muneeb/.virtualenvs/registrar/lib/python2.7/site-packages/jsontokens/__init__.py", line 10, in <module>
    from token_signer import TokenSigner
  File "/Users/muneeb/.virtualenvs/registrar/lib/python2.7/site-packages/jsontokens/token_signer.py", line 15, in <module>
    from cryptography.hazmat.backends import default_backend
  File "/Users/muneeb/.virtualenvs/registrar/lib/python2.7/site-packages/cryptography/hazmat/backends/__init__.py", line 7, in <module>
    import pkg_resources
  File "/Users/muneeb/.virtualenvs/registrar/lib/python2.7/site-packages/pkg_resources/__init__.py", line 71, in <module>
    import parser
  File "/Users/muneeb/.virtualenvs/registrar/lib/python2.7/site-packages/blockstore_client/parser.py", line 24, in <module>
    import config
  File "/Users/muneeb/.virtualenvs/registrar/lib/python2.7/site-packages/blockstore_client/config.py", line 31, in <module>

There seems to be a conflict between parser.py in our client package and pycparser and currently we cannot install both the client and blockstack-profiles in the same virtualenv.

Separate local daemon for different users

Different users on the same machine should not share the same local daemon to broadcast their transactions (this is not a security concern because their wallets are different, but it's causing confusion in reading/displaying the state of local queues).

suggested updates to the "cost" command

There are a couple issues I see with the cost command right now...

First, the "transactions_fee" field should be renamed to "transaction_fee".

Second, some people may find the price of the name to be what they are interested in, as opposed to the total cost including the fee. Consider that in the future we'll have dynamic fees and so those will float up and down. Also consider that this function will be most valuable for expensive names (if you know a name is only a few cents then it's not particularly edifying whether it is 2 cents or 1 cent), and with this scenario the name price will dwarf the transaction fee. Further, people may want to be able to set their own fees so that they can speed up or slow down the registration. Thus, the name price itself is likely going to be the most important metric for a lot of people. At the same time, the total estimated cost is important as well. So they should be given equal footing, in my view, within the response. That means no nested dictionary. And as a bonus we get increased simplicity by having no nesting in the response (this isn't always desirable).

With these things considered, I'm proposing we update the response of the command to the following:

{
  "name_price": 0.02, 
  "transaction_fee": 0.005, 
  "total_estimated_cost": 0.025
}

circular dependency on blockstore

We should probably try to remove the circular dependency on blockstore. This will:

a) enable people to install only the client (and not the daemon)
b) fix the pip install issue where the current hack to get the client is with "pip install blockstore" and "pip install blockstore-client" gives an import error for blockstore

pip install blockstack fails Ubuntu 14.04: ImportError: Twisted requires zope.interface 3.6.0 or later: no module named zope.interface.

I installed blockstack on Ubuntu 14.04, and run the command
sudo blockstack lookup fredwilson.id
But fail with:
ImportError: Twisted requires zope.interface 3.6.0 or later: no module named zope.interface.
Details as follows:
lxw@ubuntu:~ » sudo blockstack lookup fredwilson.id Traceback (most recent call last): File "/usr/local/bin/blockstack", line 34, in <module> from blockstore_client.blockstore_cli import run_cli, exit_with_error File "/usr/local/lib/python2.7/dist-packages/blockstore_client/__init__.py", line 24, in <module> import client File "/usr/local/lib/python2.7/dist-packages/blockstore_client/client.py", line 37, in <module> import parsing, schemas, storage, drivers, config, spv, utils File "/usr/local/lib/python2.7/dist-packages/blockstore_client/storage.py", line 43, in <module> from config import log File "/usr/local/lib/python2.7/dist-packages/blockstore_client/config.py", line 27, in <module> import virtualchain File "/usr/local/lib/python2.7/dist-packages/virtualchain/__init__.py", line 28, in <module> from virtualchain import setup_virtualchain, run_virtualchain, stop_virtualchain, sync_virtualchain, stop_sync_virtualchain, virtualchain_set_opfields File "/usr/local/lib/python2.7/dist-packages/virtualchain/virtualchain.py", line 38, in <module> from txjsonrpc.netstring import jsonrpc File "/usr/local/lib/python2.7/dist-packages/txjsonrpc/netstring/jsonrpc.py", line 11, in <module> from twisted.internet import defer, protocol, reactor File "/usr/lib/python2.7/dist-packages/twisted/__init__.py", line 53, in <module> _checkRequirements() File "/usr/lib/python2.7/dist-packages/twisted/__init__.py", line 37, in _checkRequirements raise ImportError(required + ": no module named zope.interface.") **ImportError: Twisted requires zope.interface 3.6.0 or later: no module named zope.interface.**

get_name_record results in an "AWS Access Key" error

Here's my full output:

(blockstore-cli)blockstore-client-$ blockstore-cli get_name_record werner.id
[ERROR] [s3:72] Could not create/fetch bucket blockstore-test
[ERROR] [s3:73] S3ResponseError: 403 Forbidden
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InvalidAccessKeyId</Code><Message>The AWS Access Key Id you provided does not exist in our records.</Message><AWSAccessKeyId>a</AWSAccessKeyId><RequestId>D09232CA3DFD8CD3</RequestId><HostId>wus/t/TLPupb+GNpNLqQpA6ou5UJoh5H+NBnEGYyrxZjplO8ieS90OA8y8Dn8TBG</HostId></Error>
Traceback (most recent call last):
  File "/Users/ryan/.virtualenvs/blockstore-cli/lib/python2.7/site-packages/blockstore_client-0.0.3-py2.7.egg/blockstore_client/drivers/s3.py", line 70, in get_bucket
    bucket = conn.create_bucket(bucket_name)
  File "/Users/ryan/.virtualenvs/blockstore-cli/lib/python2.7/site-packages/boto-2.38.0-py2.7.egg/boto/s3/connection.py", line 621, in create_bucket
    response.status, response.reason, body)
S3ResponseError: S3ResponseError: 403 Forbidden
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InvalidAccessKeyId</Code><Message>The AWS Access Key Id you provided does not exist in our records.</Message><AWSAccessKeyId>a</AWSAccessKeyId><RequestId>D09232CA3DFD8CD3</RequestId><HostId>wus/t/TLPupb+GNpNLqQpA6ou5UJoh5H+NBnEGYyrxZjplO8ieS90OA8y8Dn8TBG</HostId></Error>
[ERROR] [s3:123] Failed to get bucket 'blockstore-test'
[ERROR] [client:232] Failed to load user record '3dafd5f42798df3045cd2eb70a71cccf8500e6d4'
{
    "error": "User data could not be loaded from storage"
}

wallet is locked after manually restarting rpc_daemon

after executing $ kill -9 on rpc_daemon processes, my wallet remains locked upon restarting blockstack-cli with $ blockstack info.

to unlock the wallet again, a workaround was used:

$ blockstack register afafdsafsd.id
Enter wallet password: 
Unlocked wallet.
Registering afafdsafsd.id will cost 0.00041 BTC. Continue? (y/n): n
Not registering.

by going down a path that would need an unlocked wallet, i was able to unlock the wallet after entering my password.

there should be a command to unlock the wallet outright

Unable to install development version

When I run

$ sudo pip install git+https://github.com/blockstack/blockstack-client.git@develop --upgrade

I get

Could not find a version that satisfies the requirement virtualchain>=0.0.9 (from blockstack-client==0.0.13) (from versions: 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.0.6, 0.0.8)

Then I tried to first install registrar of develop branch.
I also installed virtualchain of develop branch (0.0.9).
Now when I run blockstack-client installation I get:

Could not find a version that satisfies the requirement registrar>=0.0.4 (from blockstack-client==0.0.13) (from versions: 0.0.1, 0.0.2, 0.0.3, 0.0.3.1, 0.0.3.2, 0.0.3.3, 0.0.3.4, 0.0.3.7) No matching distribution found for registrar>=0.0.4 (from blockstack-client==0.0.13)

But registrar 0.0.4 does not exists on github.

So it's not possible to use blockstack-client in develop branch.

Demand-based fee estimation

Don't estimate the fee based on transaction size alone; also take into account ongoing transaction volume. Eventually, we'll do replace-by-fee as well.

KeyError: 'storage_drivers'

Just cloned commit 8cd21f7 and built and installed it. When starting, getting this error:

Traceback (most recent call last):
  File "/usr/local/bin/blockstore-cli", line 5, in <module>
    pkg_resources.run_script('blockstore-client==0.0.3', 'blockstore-cli')
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 528, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1394, in run_script
    execfile(script_filename, namespace, namespace)
  File "/usr/local/lib/python2.7/dist-packages/blockstore_client-0.0.3-py2.7.egg/EGG-INFO/scripts/blockstore-cli", line 609, in <module>
    run_cli()
  File "/usr/local/lib/python2.7/dist-packages/blockstore_client-0.0.3-py2.7.egg/EGG-INFO/scripts/blockstore-cli", line 78, in run_cli
    storage_drivers = conf['storage_drivers']
KeyError: 'storage_drivers'

I assume this means it's not configured correctly, but 1. there should be a better error, and 2. I already have blockstored running on the same machine, so not sure how to configure blockstore-client separately?

Issues installing through pip on Arch

I wonder if this is python 3.x compliant, I got the following issue when trying to install:

Successfully installed Twisted basicrpc bitcoin bitmerchant blockcypher blockstack blockstore blockstore-client boto cachetools commontools future kademlia keychain protocoin pybitcoin pybitcointools pymongo python-bitcoinrpc python-dateutil registrar requests rpcudp scrypt tinydb txJSON-RPC u-msgpack-python utilitybelt virtualchain
Traceback (most recent call last):
  File "/usr/bin/pip", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python2.7/site-packages/pip/__init__.py", line 213, in main
    return command.main(cmd_args)
  File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 246, in main
    pip_version_check(session)
  File "/usr/lib/python2.7/site-packages/pip/utils/outdated.py", line 102, in pip_version_check
    installed_version = get_installed_version("pip")
  File "/usr/lib/python2.7/site-packages/pip/utils/__init__.py", line 848, in get_installed_version
    working_set = pkg_resources.WorkingSet()
  File "/usr/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 626, in __init__
    self.add_entry(entry)
  File "/usr/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 682, in add_entry
    for dist in find_distributions(entry, True):
  File "/usr/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2080, in find_eggs_in_zip
    if metadata.has_metadata('PKG-INFO'):
  File "/usr/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1610, in has_metadata
    return self.egg_info and self._has(self._fn(self.egg_info, name))
  File "/usr/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1968, in _has
    return zip_path in self.zipinfo or zip_path in self._index()
  File "/usr/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1848, in zipinfo
    return self._zip_manifests.load(self.loader.archive)
  File "/usr/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1788, in load
    mtime = os.stat(path).st_mtime
OSError: [Errno 2] No such file or directory: '/usr/lib/python2.7/site-packages/python_dateutil-2.4.2-py2.7.egg'

Import external private key to blockstack wallet

There doesn't seem to be a way to import an external private key into the blockstack wallet separately. A user may want to transfer their ID to a different address that they own and outside of the blockstack wallet. The user can then import the separate key in order to manage it.

pip lies

$ pip --version
pip 1.5.4 from /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (python 3.4)

Downloading/unpacking opendig
Downloading opendig-0.1.0.tar.gz
Running setup.py (path:/private/tmp/pip_build_root/opendig/setup.py) egg_info for package opendig

Downloading/unpacking cement==2.2.2 (from opendig)
Downloading cement-2.2.2.tar.gz (101kB): 101kB downloaded
Running setup.py (path:/private/tmp/pip_build_root/cement/setup.py) egg_info for package cement

Downloading/unpacking dnspython==1.11.1 (from opendig)
Downloading dnspython-1.11.1.zip (220kB): 220kB downloaded
Running setup.py (path:/private/tmp/pip_build_root/dnspython/setup.py) egg_info for package dnspython

Installing collected packages: opendig, cement, dnspython
Running setup.py install for opendig
changing mode of build/scripts-3.4/opendig from 644 to 755

changing mode of /Library/Frameworks/Python.framework/Versions/3.4/bin/opendig to 755

Running setup.py install for cement

Running setup.py install for dnspython
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/dns/dnssec.py", line 117
raise UnsupportedAlgorithm, 'unsupported algorithm "%s"' % algorithm
^
SyntaxError: invalid syntax

Sorry: TabError: inconsistent use of tabs and spaces in indentation (edns.py, line 117)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/dns/entropy.py", line 104
    if size > 4294967296L:
                        ^
SyntaxError: invalid syntax

  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/dns/message.py", line 176
    return '<DNS message, ID ' + `self.id` + '>'
                                 ^
SyntaxError: invalid syntax

  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/dns/name.py", line 171
    h = 0L
         ^
SyntaxError: invalid syntax

  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/dns/node.py", line 172
    raise ValueError, 'replacement is not an rdataset'
                    ^
SyntaxError: invalid syntax

  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/dns/query.py", line 118
    except select.error, e:
                       ^
SyntaxError: invalid syntax

  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/dns/rdataclass.py", line 103
    text = 'CLASS' + `value`
                     ^
SyntaxError: invalid syntax

  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/dns/rdatatype.py", line 213
    text = 'TYPE' + `value`
                    ^
SyntaxError: invalid syntax

  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/dns/rdtypes/ANY/LOC.py", line 22
    _pows = (1L, 10L, 100L, 1000L, 10000L, 100000L, 1000000L, 10000000L,
              ^
SyntaxError: invalid syntax

  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/dns/renderer.py", line 221
    ednsflags &= 0xFF00FFFFL
                           ^
SyntaxError: invalid syntax

  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/dns/tokenizer.py", line 491
    if value < 0 or value > 4294967296L:
                                      ^
SyntaxError: invalid syntax

  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/dns/tsig.py", line 96
    long_time = time + 0L
                        ^
SyntaxError: invalid syntax

  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/dns/ttl.py", line 39
    total = 0L
             ^
SyntaxError: invalid syntax

  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/dns/zone.py", line 874
    except dns.exception.SyntaxError, detail:
                                    ^
SyntaxError: invalid syntax

Successfully installed opendig cement dnspython
Cleaning up...

$ opendig
ERROR: opendig is not installed. Try 'sudo pip install opendig'

Explore ways to retry a register

@JFiscella ended up in a situation where a preorder went through but register didn't for some reason and the CLI was not retrying a register automatically (which should not happen). This should work in the current code, but it didn't in this particular case so need to explore it more. The behavior is not deterministic. A register operation that @JFiscella tried later on worked.

get_consensus_at broken: no logger in utils.py

get_consensus_at doesn't work in version 0.0.7 because there's no log defined in util.py.

root@blockchainid:~# blockstore-cli get_consensus_at 385159
Traceback (most recent call last):
  File "/usr/local/bin/blockstore-cli", line 928, in <module>
    run_cli()
  File "/usr/local/bin/blockstore-cli", line 925, in run_cli
    print_result(result)
  File "/usr/local/lib/python2.7/dist-packages/blockstore_client/utils.py", line 46, in print_result
    print pretty_dump(json_str)
  File "/usr/local/lib/python2.7/dist-packages/blockstore_client/utils.py", line 40, in pretty_dump
    log.debug("ERROR in pretty print: %s" % e)
NameError: global name 'log' is not defined
root@blockchainid:~#

blockstore-cli launch

git clone https://github.com/blockstack/blockstore-client
cd blockstore-client
python setup.py build
sudo python setup.py install
blockstore-cli
Traceback (most recent call last):
  File "/usr/local/bin/blockstore-cli", line 5, in <module>
    pkg_resources.run_script('blockstore-client==0.0.3', 'blockstore-cli')
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 499, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1235, in run_script
    execfile(script_filename, namespace, namespace)
  File "/usr/local/lib/python2.7/dist-packages/blockstore_client-0.0.3-py2.7.egg/EGG-INFO/scripts/blockstore-cli", line 547, in <module>
    run_cli()
  File "/usr/local/lib/python2.7/dist-packages/blockstore_client-0.0.3-py2.7.egg/EGG-INFO/scripts/blockstore-cli", line 77, in run_cli
    storage_drivers = conf['storage_drivers']
KeyError: 'storage_drivers'

on Ubuntu 12.04 and Max OS X yosemite

switch from pycrypto to python cryptography

Hey!

We discussed earlier the switch from pycrypto to python cryptography (https://github.com/pyca/cryptography).

As I mentioned, I've worked with both before and the latter is the best, IMO. Really well-written, documented, and tested.

Here's the documentation for symmetric encryption with a password:

https://cryptography.io/en/latest/fernet/?highlight=password

>>> import base64
>>> import os
>>> from cryptography.fernet import Fernet
>>> from cryptography.hazmat.backends import default_backend
>>> from cryptography.hazmat.primitives import hashes
>>> from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
>>> password = b"password"
>>> salt = os.urandom(16)
>>> kdf = PBKDF2HMAC(
...     algorithm=hashes.SHA256(),
...     length=32,
...     salt=salt,
...     iterations=100000,
...     backend=default_backend()
... )
>>> key = base64.urlsafe_b64encode(kdf.derive(password))
>>> f = Fernet(key)
>>> token = f.encrypt(b"Secret message!")
>>> token
'...'
>>> f.decrypt(token)
'Secret message!'

It's simple yet extensible and only uses high-level functions, so there's no need to deal with padding and such.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.