🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

dashwallet

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dashwallet

A more civilized wallet for a less civilized age

0.7.1
latest
Source
npm
Version published
Weekly downloads
3
-89.66%
Maintainers
2
Weekly downloads
 
Created
Source

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/secp256k1@1.x/secp256k1.js"></script>
<script src="https://unpkg.com/dashkeys@1.x/dashkeys.js"></script>
<script src="https://unpkg.com/dashsight@1.x/dashsight.js"></script>
<script src="https://unpkg.com/dashsight@1.x/dashsocket.js"></script>
<script src="https://unpkg.com/dashtx@0.x/dashtx.js"></script>
<script src="https://unpkg.com/dashwallet@0.5/dashwallet.js"></script>

Node.js & Bundlers

  • Install node

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

    npm install --save dashwallet0.5
    npm install --save @dashincubator/secp256k1@1.7
    
  • Install dashwallet-cli for testing locally

    npm install --location=global dashwallet-cli@0.5
    

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.

Keywords

dash

FAQs

Package last updated on 28 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts