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

dashwallet

v0.7.1

Published

A more civilized wallet for a less civilized age

Downloads

5

Readme

DashWallet.js

A more civilized DASH Wallet SDK for a less civilized age...

Table of Contents

  • Install
    • Web Browsers
    • Node.js & Bundlers
  • Usage
  • API

Install

Web Browsers

<script src="https://unpkg.com/@dashincubator/[email protected]/secp256k1.js"></script>
<script src="https://unpkg.com/[email protected]/dashkeys.js"></script>
<script src="https://unpkg.com/[email protected]/dashsight.js"></script>
<script src="https://unpkg.com/[email protected]/dashsocket.js"></script>
<script src="https://unpkg.com/[email protected]/dashtx.js"></script>
<script src="https://unpkg.com/[email protected]/dashwallet.js"></script>

Node.js & Bundlers

  1. Install node

    # Mac, Linux
    curl -sS https://webi.sh/node | sh
    
    # Windows
    curl.exe https://webi.ms/node | powershell
  2. Install the dashwallet library

    npm install --save dashwallet0.5
    npm install --save @dashincubator/[email protected]
  3. Install dashwallet-cli for testing locally

    npm install --location=global [email protected]

Usage

// TODO
// (look at dashwallet-cli to see current usage)

Alpha API (will change)

Wallet.create(config)

Creates a wallet instance with the given config

  • DashSight adapter - or any interface matching:
    • getTxs(addr, page)
    • getUtxos(addr)
    • instantSend(txHex)
  • safe
    • wallets
    • addresses
  • Storage adapter
    • save() storage adapter (and "safe").
let w = await Wallet.create({ storage, safe, dashsight });

Wallet.generate(walletInfo)

Generates a complete PrivateWallet object.

Wallet.generate({
  name: "main",
  label: "Main",
  priority: 1, // lower sorts higher
});
{
  "name": "main",
  "label": "Main",
  "device": null,
  "contact": null,
  "priority": 1,
  "phrase": "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong",
  "created_at": "2022-02-22T22:02:22.000Z",
  "archived_at": null
}

Wallet.generateAddress(addrInfo)

Generates a complete addrInfo object.

Wallet.generateAddress({
  wallet: "main",
  hdpath: "m/44'/5'/0'/0",
  index: 0,
});
{
  "checked_at": 0,
  "hdpath": "m/44'/5'/0'/0",
  "index": 0,
  "txs": [],
  "utxos": [],
  "wallet": "main"
}

Wallet.generatePayWallet(walletInfo)

Generates a complete PayWallet object.

{
  "name": "@johndoe",
  "label": "@johndoe",
  "device": null,
  "contact": "@johndoe",
  "priority": 1668919000655,
  "xpub": "xpubXXXX...XXXX",
  "address": "Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "created_at": "2022-02-22T22:02:22.000Z",
  "archived_at": null
}

Wallet#balances()

Show spendable duffs / satoshis per each wallet.

You may need to await wallet.sync() first.

await wallet.balances();
{
  "main": 1212000,
  "@johndoe:1": 120000
}

Wallet#befriend(friendDetails)

Generate or show an xpub for your contact, and import their xpub for you, if any.

await wallet.befriend({
  handle: "@johndoe",
  // optional (either or, not both)
  xpub: "<the-xpub-that-john-doe-gave-to-you>",
  addr: "<a-static-pay-addr-from-john-doe>",
});
["<xpub-YOU-should-give-to-john>", "xpub-JOHN-gave-to-you", "addr-from-JOHN"]

wallet.createTx(txOpts)

TODO: Creates a clean (fingerprint-free) transaction.

wallet.createDirtyTx(txOpts)

Creates a dirty (fingerprint) transaction (hex string) for the given amount to the given contact using utxos from across all PrivateWallets.

await wallet.createDirtyTx({ handle, amount, utxos });
{
  "hex": "abc123...",
  "utxos": [
    {
      "address": "...",
      "outputIndex": 0,
      "satoshis": 1000,
      "script": "...",
      "txId": "..."
    }
  ]
}

The result can be used with dashsight.instantSend(tx.hex).

wallet#findChangeWallet(friendOpts)

Finds your PrivateWallet for the given contact.

await wallet.findChangeWallet({ handle: "@johndoe" });

Returns a PrivateWallet, as described above.

wallet#findFriend(friendOpts)

Finds the xpub-only (pay-to, send-only) wallet for the given contact.

await wallet.findFriend({ handle: "@johndoe" });

Returns a PayWallet, as described above.

wallet#nextChangeAddr(friendOpts)

Find the next unused change address for the PrivateWallet associated with the given contact, or from the main wallet as a fallback.

await wallet.nextChangAddr({ handle: "@johndoe" });

Returns a PayAddr.

"Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

Wallet#sync(syncOpts)

(Re)index addresses for each wallet and fetch latest transactions for the next few addresses.

let now = Date.now();
let staletime = 60 * 1000; // 0 to force immediate sync
await wallet.sync({ now, staletime });

Wallet#utxos()

Get all utxos across all PrivateWallets.

await wallet.utxos();

The results are in dashcore/bitcore format:

[
 txId: '<hex-tx-id>',
 outputIndex: 0,
 address: "Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
 script: 'xxxx...',
 satoshis: 100000000
]

There's no response, just updates to safe.addresses, and store.save() will be called.