Giter Site home page Giter Site logo

npmt_my-wallet-v3's Introduction

MyWallet Build Status Coverage Status

JavaScript Model for Blockchain.info wallet.

Build

Install Yarn

yarn # recommended, can also use `npm install`
npm run build

Tests

npm test

Dev

Watch files and re-build

npm run build:watch

Clean

Clean generated files:

make clean

Getting Started

Load dist/my-wallet.js.

Optional: set alias for modules you use

var MyWallet = Blockchain.MyWallet;
var WalletStore = Blockchain.WalletStore;
var Spender = Blockchain.Spender;
var API = Blockchain.API;

Disable logout, if desired, for development work:

MyWallet.disableLogout(true);

// Set an interval, since logout gets reactived by certain parts of the code
window.setInterval(function() { MyWallet.disableLogout(true); }, 60000);

My Wallet communicates about its state with user-defined event listeners. Setup a listener like so:

function myListenerFun(eventName, data) {
    // Handle events
}

// Register listener function with MyWallet
MyWallet.addEventListener(myListenerFun);

Some events that we need to process:

Event Name Our Action
did_multiaddr Populate wallet statistics on the UI
hd_wallets_does_not_exist Create an HD wallet
on_wallet_decrypt_finish Get wallet transaction history

To build an HD wallet with an existing legacy wallet, we must initialize after receiving event notification from MyWallet.

var passphrase = MyWallet.generateHDWalletPassphrase();

MyWallet.initializeHDWallet(passphrase, null, null, _successFun, _errorFun);

Load a wallet from the server, with no 2FA

var guid = "my-wallet-guid-1234-bcde";
var pass = "wallet-password";
var twoFactorCode = null;

MyWallet.fetchWalletJSON(guid, null, null, pass, twoFactorCode,
    successFun, need2FAfun, wrong2FAfun, otherErrorFun);

// Do stuff with the wallet
var LegacyAddresses = MyWallet.getLegacyActiveAddresses();

In order to fetch the wallet history, make a call to get_history:

MyWallet.get_history(_successFun, _errorFun);

get_history will trigger the did_multiaddr event on completion, so the wallet stats and display can be updated.

Security

Security issues can be reported to us in the following venues:

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.