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

@mymonero/mymonero-monero-client

v3.0.3

Published

The JS library containing the JS transpilation of the shared library behind the MyMonero apps

Downloads

443

Readme

:warning: This project is under heavy development. Expect bugs & breaking changes.

General dependencies

If you would like to generate the WASM files yourself you will require docker

Building

  1. Clone the repo git clone https://github.com/mymonero/mymonero-utils.git
  2. cd packages/mymonero-monero-client
  3. rm -rf build removes the old build folder if you have run a build previously.
  4. rm src/MyMoneroClient_* removes the old WASM before your new build.
  5. ./prepare.sh to fetch the monero core code and the mymonero bridging code.
  6. npm run build initiates the emscripten docker image to build the project.

By following these instructions, new WASM library is generated and copied to the src folder


Upgrading from 2.1.x to 2.2.x and 3.x.x

No breaking changes have been made to any packages besides @mymonero/mymonero-monero-client.

For users of @mymonero/mymonero-monero-client, the following changes have been made:

Version 2.2.0 and onwards have changed from having separate MyMoneroClient_WASM.wasm and MyMoneroClient_WASM.js, and now unify the WASM and .js file together.

For webpack users, if you had a script set up to copy the WASM as part of your build process, this should be removed from your webpack.config.js file.

Otherwise, any users of the mymonero-monero-client library should not need to change anything on their side unless you were loading the WASM using a custom method different to our documentation.

While we've made every effort to remain backwards compatible, please let us know if you experience any issues.

Usage

Installation

You can install the WASM and javascript bridging code via npm.

npm i @mymonero/mymonero-monero-client

Initialize

Initialize the WABridge class which loads and prepares the WebAssembly. The WABridge has helper methods for each of the calls allowing for linting and improved error handling

const WABridge = await require('@mymonero/mymonero-monero-client')({})

Generate Wallet

Creates a new wallet using the Language and Locale and Network Type. Only the prefix is checked e.g. en-UK, en-US will match to English.

  • English - en
  • Dutch - nl
  • French - fr
  • Spanish - es
  • Portuguese - pt
  • Japanese - ja
  • Italian - it
  • German - de
  • Russian - ru
  • Chinese, simplified - zh
  • Esperanto - eo
  • Lojban - jbo
const result = WABridge.generateWallet('en-US', 'MAINNET')
console.log(result)

Derive Seed and Keys from Mnemonic

Provided mnemonic seed phrase it will return the primary address and keys.

const result = WABridge.seedAndKeysFromMnemonic(
  'foxe selfish hum nexus juven dodeg pepp ember biscuti elap jazz vibrate biscui',
  'MAINNET'
)
console.log(result)

Validate Private keys

Used to validate the users keys for accessing the wallet. Requires the address, private view key and private spend key.

isValidKeys(address, privateViewKey, privateSpendKey)

const result = WABridge.isValidKeys(
  '43zxvpcj5Xv9SEkNXbMCG7LPQStHMpFCQCmkmR4u5nzjWwq5Xkv5VmGgYEsHXg4ja2FGRD5wMWbBVMijDTqmmVqm93wHGkg',
  '7bea1907940afdd480eff7c4bcadb478a0fbb626df9e3ed74ae801e18f53e104',
  '4e6d43cd03812b803c6f3206689f5fcc910005fc7e91d50d79b0776dbefcd803',
  '',
  'MAINNET'
)
console.log(result)

Generate Payment ID

Generates a new random short payment ID string.

const paymentId = WABridge.generatePaymentId()
console.log(paymentId)

Decode an Address

Decodes the address to access public spend key, public view key, whether it is a subaddress and payment ID.

const result = WABridge.decodeAddress(
  '49qwWM9y7j1fvaBK684Y5sMbN8MZ3XwDLcSaqcKwjh5W9kn9qFigPBNBwzdq6TCAm2gKxQWrdZuEZQBMjQodi9cNRHuCbTr',
  'MAINNET'
)
console.log(result)

Compare two Mnemonics

Compares two mnemonic phrases against each other.

const result = WABridge.compareMnemonics(
  'foxe selfish hum nexus juven dodeg pepp ember biscuti elap jazz vibrate biscui',
  'fox sel hum nex juv dod pep emb bis ela jaz vib bis'
)
console.log(result)

Validate Integrated Address

Checks if the provided address is a integrated address. returns a boolean value. This is a helper function for decodeAddress. If the address is not a subaddress and has a payment id it will return true.

const result = WABridge.isIntegratedAddress(
  '4L6Gcy9TAHqPVPMnqa5cPtJK25tr7maE7LrJe67vzumiCtWwjDBvYnHZr18wFexJpih71Mxsjv8b7EpQftpB9NjPaL41VrjstLM5WevLZx', 
  'MAINNET'
)
console.log(result)

Validate Subaddress

Checks if the provided address is a subaddress. returns a boolean value. This is a helper function for decodeAddress. If the address decode returns is a subaddress it will return true.

const result = WABridge.isSubaddress(
  '4L6Gcy9TAHqPVPMnqa5cPtJK25tr7maE7LrJe67vzumiCtWwjDBvYnHZr18wFexJpih71Mxsjv8b7EpQftpB9NjPaL41VrjstLM5WevLZx', 
  'MAINNET'
)
console.log(result)

Generate new Integrated Address

Generate a new intergrated address using address and payment ID. Accepts a primary addresss and a short payment id. subaddresses cannot be paired with a payment id.

const result = WABridge.newIntegratedAddress(
  '43zxvpcj5Xv9SEkNXbMCG7LPQStHMpFCQCmkmR4u5nzjWwq5Xkv5VmGgYEsHXg4ja2FGRD5wMWbBVMijDTqmmVqm93wHGkg',
  '07749f00b7e3a2f6',
  'MAINNET'
)
console.log(result)

Extract Address and Keys from Seed

Provided a hexadecimal seed it will return primary address and keys.

const result = WABridge.addressAndKeysFromSeed(
  '9c973aa296b79bbf452781dd3d32ad7f', 
  'MAINNET'
)
console.log(result)

Derive Mnemonic from Seed

Provided a hexadecimal seed it will return a mnemonic seed phrase.

const result = WABridge.mnemonicFromSeed(
  '9c973aa296b79bbf452781dd3d32ad7f',
  'English'
)
console.log(result)

Estimate transaction fee

Calculates an estimated transaction fee. Its based on two outputs being used. The fees per byte value can be retrieved from the get_unspent_outs MM server call.

const result = WABridge.estimateTxFee(1, 6000)
console.log(result)

Generate Key Image

Generates key image for an output. returns the key image for the tx public key and output index. generateKeyImage (txPublicKey, privateViewKey, publicSpendKey, privateSpendKey, outputIndex)

const result = WABridge.generateKeyImage(
      '585d3601bc6f3b63ad041fbb5f301a6239cbc98ec2954ef827d5f81aed59cff9',
      '5925eac0f78c40a79c75a43be68905adeb7b6ae34c1be2dda2b5b417f8099700',
      '1a9fd7ccfa0de91673f5637eb94a67d85b54eae83d1ec9b609689ec846a50fdd',
      '5000f1da72ec13401b6e4cfccdc5e52c9d0b04383fcb32c85f235874c5104e0d',
      0
    )
console.log(result)

Create Transaction

Creates a raw transaction from the options provided. This Tx needs to be sent on to the light wallet server for broadcast. Multiple destination transactions do not support payment ids. Only one destination can be set if there is an associated payment id. This includes integrated addresses. Subaddresses and primary desitnations can be mixed within a single transaction.

const options = {
    destinations: [
      { 
        'to_address': '42ddLnxquN84kpfmEpL8FxdBw32BGuwagXSz6xRSAUA2e7dupTS1FxP3vo1iPBA2doHPwJUpE7WVCMutnfwVMtVAKoaEA8X', 
        'send_amount': '0.0001'
      }
    ],
    priority: 1,
    address: '46kDcL7a9uVQojKQWqxqZUg9cKuffJvjYhbjbybxV46oNZm3Pa7qX9YWXC6vjAnyr3NrMFWvGjj7GUNVrQM9itGC5npKFD8',
    privateViewKey: 'f9f3aa647a5cce9ed896936b7f500b6bf87f48d4e092692c07fe824743a2d402',
    publicSpendKey: '872d28c53d4f2c8e532b445a4d4193ea0d9d72b25695dff2b98bfd82e113cc80',
    privateSpendKey: '9efdc2250dcea2babdf2d8463185234e97b0bebdb0bd313134254316b708f40f',
    shouldSweep: false,
    paymentId: '',
    nettype: 'MAINNET',
    unspentOuts: unspentOuts,
    randomOutsCb: function () {
      return {
        amount_outs: [
          { amount: '0', outputs: [] },
          { amount: '0', outputs: [] }
        ]
      }
    }
   }
WABridge.createTransaction(options)
  .then(function (result) {
    console.log(result)
  })

License

See LICENSE.txt for license.

All source code copyright © 2022 by MyMonero. All rights reserved.