npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bitstore

v2.5.0

Published

A content-addressable cloud storage web service that uses Bitcoin public key infrastructure for authentication and payment.

Downloads

55

Readme

bitstore

A content-addressable file hosting and distribution service that uses Bitcoin public key infrastructure for authentication and payment.

The basic idea is that customers pay for the storage and retrieval costs of their digital media. Here at Blockai we are committed to building consumer products that never rely on advertising or selling personal data to third-party companies to cover our costs. In essence, we're building products where people own their own content and with that comes taking on financial responsibility.

How it works is a customer sends a small amount of Bitcoin to a deposit address provided by Bitstore and their account is immediately credited. Once their credits are in place they are free to store and retrieve media on a per-file and per-use basis. Once a customer's credits have been used up the file is no longer available for retrieval, however anyone can make a deposit to any account.

If we did our math correctly it currently costs about 1/3rd of a cent to upload a photograph and distribute a 100 copies but I expect adjustments to our initial pricing mechanism. Needless to say, using Bitstore will cost very little and we don't really expect people to purchase more than a few dollars worth of credits, depending on their distribution needs.

Content-addressable

Content-addressable means that the file is referenced not by a name but by a cryptographic hash of the contents. Bitstore supports MD5, SHA-1, SHA-256 and BitTorrent Info Hash as identifiers.

Every digital file has a unique hash. Think of it like a fingerprint. If any of the bits in the file change, the fingerprint changes. This property is great for tracking different versions of files and is employed by revision control systems like git.

Install

npm install bitstore

Browser Usage

In our examples we're going to use bitcoinjs-lib to create our wallet.

Bitcoin Wallet

var bitcoin = require("bitcoinjs-lib");

var seed = bitcoin.crypto.sha256("test");
var wallet = new bitcoin.Wallet(seed, bitcoin.networks.testnet);
var address = wallet.generateAddress();

var signRawTransaction = function(txHex, cb) {
  var tx = bitcoin.Transaction.fromHex(txHex);
  var signedTx = wallet.signWith(tx, [address]);
  var txid = signedTx.getId();
  var signedTxHex = signedTx.toHex();
  cb(false, signedTxHex, txid);
};

var signMessage = function (message, cb) {
  var key = wallet.getPrivateKey(0);
  var network = bitcoin.networks.testnet;
  cb(null, bitcoin.Message.sign(key, message, network).toString('base64'));
};

var commonWallet = {
  network: 'testnet',
  signMessage: signMessage,
  signRawTransaction: signRawTransaction,
  address: address
}

We'll need to provide an instance of a commonBlockchain which will provide functions for signing a transaction, propagating a transaction, and looking up a transaction by txid.

In this example we're using a testnet version that is provided by blockcypher-unofficial.

var commonBlockchain = require('blockcypher-unofficial')({
  network: "testnet"
});

Bitstore Client

The Bitstore client uses a Bitcoin wallet to sign tokens for identification and to authorize with the Bitstore servers. In effect your Bitcoin wallet address is your ID.

var bitstore = require('bitstore');

var bitstoreClient = bitstore(commonWallet);

var bitstoreDepositAddress, bitstoreBalance;

bitstoreClient.wallet.get(function (err, wallet) {
  bitstoreDepositAddress = wallet.deposit_address;
  bitstoreBalance = wallet.balance;
});

Send Bitcoin to Bitstore Deposit Address

Bitstore is a pay-per-use, per-file service and needs Bitcoin in order to operate.

We need to send some Bitcoin from our brain wallet to the Bitstore deposit address in order to top up our balance.

var newTx = wallet.createTx(bitstoreDepositAddress, 100000, 1000, address);
var signedTx = wallet.signWith(newTx, [address]);
var signedTxHex = signedTx.toHex();

commonBlockchain.Transactions.Propagate(signedTxHex, function(err, receipt) {
  console.log("propagation receipt", receipt);
});

Upload file to Bitstore

Once your Bitstore account has some credits you can start uploading files.

var file; // a browser File object returned from drop or file select form

var hash_sha1, hash_sha256, hash_btih, uri, size, torrent;

bitstoreClient.files.put(file, function (err, receipt) {
  hash_sha1 = receipt.hash_sha1;
  hash_sha256 = receipt.hash_sha256;
  hash_btih = receipt.hash_btih;
  uri = receipt.uri;
  size = receipt.size;
  torrent = receipt.torrent;
});

Command Line Usage

$ cat ~/.bitstore
{
  "privateKey": "your private key (used for authentication)",
  "network": "livenet"
}

$ bitstore --help

  Usage: bitstore [options] [command]


  Commands:

    files                               list uploaded files
    files:put|upload <filePath>         upload local file or url
    files:meta <sha1>                   file metadata
    files:torrent <sha1>                torrent json
    files:destroy|rm <sha1>             destroy file
    wallet                              show wallet
    wallet:deposit                      deposit to wallet
    wallet:withdraw <amount> <address>  withdraw from wallet
    transactions                        list transactions
    status                              bitstore server status

  Options:

    -h, --help     output usage information
    -V, --version  output the version number