Coder Social home page Coder Social logo

edgeapp / edge-currency-bitcoin Goto Github PK

View Code? Open in Web Editor NEW
17.0 18.0 44.0 15.24 MB

Implements Bitcoin support following the Edge currency plugin API

Home Page: https://edge.app

License: BSD 3-Clause "New" or "Revised" License

JavaScript 100.00%

edge-currency-bitcoin's Introduction

Edge Bitcoin Currency Plugin

Build Status NPM version Dependency Status

js-standard-style

Implements Bitcoin send/receive functionality per the spec for currency plugins for edge-core-js

Installing

npm i edge-currency-bitcoin -s
import { bitcoinCurrencyPluginFactory, bitcoincashCurrencyPluginFactory } from `edge-currency-bitcoin`

Now you can pass bitcoinCurrencyPluginFactory to edge-core-js.

const context = makeEdgeContext({
  apiKey: YOUR_API_KEY,
  plugins: [ bitcoinCurrencyPluginFactory, bitcoincashCurrencyPluginFactory ]
})

This plugin exposes the following otherSettings which can be set using abcAccount.updateSettings()

{
  enableOverrideServers: boolean,
  electrumServers: Array<Array[String, String]>,
  earnComFeeInfoServer: String
  mempoolSpaceFeeInfoServer: String
}

enableOverrideServers = true will force the plugin to ONLY use the electrum servers specified in electrumServers. electrumServers should be in the format [[DNS name], [port]]. ie [h.1209k.com, 50001]. earnComFeeInfoServer should be the fee server, should have the same API as https://bitcoinfees.21.co/api/v1/fees/list. mempoolSpaceFeeInfoServer should be the fee server, should have the same API as https://mempool.space/api/v1/fees/recommended.

Contributing

You'll need to install Yarn 1.3.2 globally on your machine

To run a local version of this repo inside the full Edge Wallet app, clone this repo at the same level as edge-react-gui

git clone [email protected]:Airbitz/edge-currency-bitcoin.git`
cd edge-currency-bitcoin
yarn

Run npm run test to run the unit tests.

To use the local cloned version of this repo, cd edge-react-gui and run

npm run updot edge-currency-bitcoin
npm run postinstall

This will copy the necessary files from edge-currency-bitcoin into the edge-react-gui/node_modules/edge-currency-bitcoin replacing the npm installed version. This needs to be done after any modifications to edge-currency-bitcoin

All sources are in the JavaScript Standard Style + Prettier. We check files prior to each commit, so if you have formatting issues, you can run npm run format to fix them automatically.

If you use Visual Studio Code, consider installing the prettier-vscode extension. You'll want to enable the prettier.eslintIntegration configuration option for this to work seamlessly with Standard.

If you use Atom, you can use prettier-atom. You'll want to check the "ESLint Integration" setting for this to work seamlessly with Standard.

License

BSD 3

edge-currency-bitcoin's People

Contributors

adyshimony avatar ahmedbodi avatar ahujsak avatar andreyveze avatar dependabot[bot] avatar jacobburrell avatar jamesrisberg avatar kylanhurt avatar lclc avatar lourenc avatar maverickedge avatar paullinator avatar peachbits avatar riordant avatar safitudo avatar scriptprodigy avatar swansontec avatar thehobbit85 avatar toxeus avatar wolverineks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

edge-currency-bitcoin's Issues

Scanning first BIP 21 / 72 Qr code takes long time till amount is shown

When I scan a BIP 21 / 72 Qr code the first time after opening the app (when it was no running in the background) it takes around 20 seconds until the amount shows up (before it shows 0).

When I did it ones the next time the amount shows up immediately (for different Qr codes from the same source).

Tested with this the following terminal:
https://paymentterminal.bitcoinsuisse.ch/K13QD6

E.g. with

bitcoin:1EzaSLq8Za9eiuSjW1WMii69Ho2obEEsBg?amount=0.00017926&r=https%3a%2f%2fpaymentservices.bitcoinsuisse.ch%2fpay.aspx%3fpublicKey%3dREQUEST-1EzaSLq8Za9eiuSjW1WMii69Ho2obEEsBg

I tried with many wallets - happy that BIP 72 works with Edge ๐Ÿ‘
1/3 of the others didn't.

AccountSync.constructor already exists error

I get this error when i integrate edge-currency-bitcoin in edge-login-web.


magic.js:152 Uncaught Error: A shared value named AccountSync.constructor already exists
    at shareData (magic.js:152)
    at Object.parcelRequire.../../../../node_modules/edge-core-js/lib/edge-core-index.js.aes-js (client-side.js:33)
    at newRequire (frame.e31bb0bc.js:47)
    at localRequire (frame.e31bb0bc.js:53)
    at Object.parcelRequire.../../../../node_modules/edge-currency-bitcoin/lib/engine/currencyEngine.js.biggystring (currencyEngine.js:5)
    at newRequire (frame.e31bb0bc.js:47)
    at localRequire (frame.e31bb0bc.js:53)
    at Object.parcelRequire.../../../../node_modules/edge-currency-bitcoin/lib/plugin/currencyPlugin.js.buffer (currencyPlugin.js:19)
    at newRequire (frame.e31bb0bc.js:47)
    at localRequire (frame.e31bb0bc.js:53)


Trying to add new cryptocurrency

I try to add new cryptocurrency to your wallet using your plugin system.
Fork link: https://github.com/zvs001/edge-currency-bitcoin

Also i added this currency to electrum server and run it locally
Electrum fork link: https://github.com/zvs001/electrumx

I can create wallet with edge application and can send something to this wallet address using default desktop client. I can see this transactions and balance inside electrum server using electrum client. But inside edge application always displays zero.

May be you can advice something?

Lightning via rust-lightning

Hey! Do y'all have any interest in lightning/any thoughts on how you might integrate it into Edge Bitcoin support?

[shill]
I've been working on https://github.com/rust-bitcoin/rust-lightning for about a year now to provide a lightning library instead of standalone node, ie designed to be easy to integrate into an existing wallet that already has its own key management, storage, blockchain download logic, etc. Written in rust, it can be compiled out to almost any platform (wasm, shared library, static library, etc) rather easily and can be called from virtually any language.

As of the past month or so, the API has started to stabilize and I'm starting to look at exploring possibly integration. It's not at the "you should put money in this" point yet, but it's been more than capable of opening/closing channels/sending/receiving payments, etc for months and we're chipping away at error handling and test coverage. You can see the docs/API at http://docs.rs/lightning, but at a high level most of the integration work is just providing glue to do things like pass bytes onto TCP sockets, handle money-sent/money-received events, writing data out to disk, etc, etc.
[/shill]

fetchStratumServers() can populate serverList with garbage

This is actually an issue for the software running https://info1.edgesecure.co:8444/v1/ but I didn't find the repo so I'm opening the issue here because this repo is affected.

The io.fetch for the electrumServers list assumes that the server will respond with a non-success status code if there are no servers configured and acts accordingly.

Unfortunately, this is not how the server behaves when it is asked for electrum servers of coins it doesn't know.

curl -w "\nstatus code: %{http_code}\n" https://info1.edgesecure.co:8444/v1/electrumServers/FTC
"Unable to find electrumServers FTC"
status code: 200

Custom mining fee is not properly translated due to incorrect transaction size estimate

I set a custom mining fee of 1 sat/b, and it was rejected due to network rules. Then set the value to 2, and it passed, but on a the receiving wallet (electrum) it was listed as 1.7 sat/b.

Seems the size estimation is significantly off for the transaction type in question. This was sending from a single 3-address to a single bech32 address with a single change output.

Electrum lists the size as 165 bytes, but the fee implies a size estimate of 137 bytes.

abcAccount.updateSettings() exists?

Hey guys, looking forward to integrating with your product! I have a question...

When I look at your README and you mention we can do the following:

This plugin exposes the following otherSettings which can be set using abcAccount.updateSettings()

{
  enableOverrideServers: boolean,
  electrumServers: Array<Array[String, String]>,
  feeInfoServer: String
}

*I don't see the implementation of this to override the electrumServers(currencyEngine.js)

// ------------------------------------------------------------------------
  // Public API
  // ------------------------------------------------------------------------
  updateSettings (settings: any): void {
    // TODO: Implement this
  }

How do we do this? I am assuming that we would pass in the updatedSettings into the abcAccount.updateSettings(updatedSettings) - could I get an example? I would like to work on the plugin based on my own local electrum server...

Out of bounds read (offset=0) error when broadcasting LTC or Dogecoin transactions.

I'm trying to send supported coins each other. Using latest version of edge-core-js and edge-currency-bitcoin, edge-currency-accountbased, I could make XRP transactions work each other.
But for Dogecoin and LTC, I am getting error when broadcasting the tx data.

`const sendXrp = async () => {
try {
const { username, password, opt } = masterAccount;
const abcContext = await getContext();

    const abcAccount = await abcContext.loginWithPassword(
        username,
        password,
        opt
    );

    console.log(`\n----- Edge Account ID ----`);
    console.log(abcAccount.id);

    const walletIds = await abcAccount.listWalletIds();
    console.log(`\n----- Wallet Ids ----`);
    console.log(walletIds);

    const walletInfo = await abcAccount.waitForCurrencyWallet(masterAccount.walletId);
    console.log(`\n----- Wallet Info ------`);
    console.log(walletInfo);

    console.log(`\n----- Wallet Address -----`);
    console.log(walletInfo.getReceiveAddress());

    const balance = await walletInfo.getBalance({currencyCode: 'LTC'});
    console.log(`\n------------------------------------- Current Balance`);
    console.log(balance);

    // start engine
    await walletInfo.startEngine();

    const tx = await walletInfo.makeSpend({
        spendTargets: [
            {
                publicAddress: 'MFktv8WkXMDh1yyYoKfZKBjb9jbSnyfdgN',
                nativeAmount: '100000'
            }
        ]
    });


    console.log(tx);

    await walletInfo.signTx(tx);

    console.log(`Broadcasting tx`);
    await walletInfo.broadcastTx(tx);
    const result = await walletInfo.saveTx(tx);

    console.log(result);

}`

It works in offline functions, signing tx data etc.
But the error happens in the broadcastTx(tx) function.

{ Error: Out of bounds read (offset=0). at BufferReader.readU32 (/Volumes/box3/worksheet/BCT/edge/node_modules/bcoin/lib/utils/reader.js:196:8) at TX.fromReader (/Volumes/box3/worksheet/BCT/edge/node_modules/bcoin/lib/primitives/tx.js:2271:21) at TX.fromRaw (/Volumes/box3/worksheet/BCT/edge/node_modules/bcoin/lib/primitives/tx.js:2256:15) at Function.fromRaw (/Volumes/box3/worksheet/BCT/edge/node_modules/bcoin/lib/primitives/tx.js:2236:19) at verifyTxAmount (/Volumes/box3/worksheet/BCT/edge/node_modules/edge-currency-bitcoin/lib/utils/coinUtils.js:304:27) at CurrencyEngine.broadcastTx (/Volumes/box3/worksheet/BCT/edge/node_modules/edge-currency-bitcoin/lib/engine/currencyEngine.js:688:16) at Object.broadcastTx (/Volumes/box3/worksheet/BCT/edge/node_modules/edge-core-js/lib/core/currency/wallet/currency-wallet-api.js:384:21) at sendXrp (/Volumes/box3/worksheet/BCT/edge/app.js:233:26) at <anonymous> type: 'EncodingError', message: 'Out of bounds read (offset=0).' }

I've tried Doge and LTC, but both had same errors. I tried to change amounts but no luck.
Could you please advise what could be wrong or how to fix this issue?

types out of date

edge-core-js has updated types
should edge-core-js be a peer dependency to keep types in sync?
also, update to most recent edge-core-js

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.