Git Product home page Git Product logo

airgap-coin-lib's Issues

Add Support for BTC Multisig

Currently, Airgap does not support Bitcoin Multi-Signature, which is a very common when you are holding a big amount of bitcoin and want to secure it.

We would like to see support for

  • P2SH (Legacy Multisig)
  • P2WSH (Native SegWit Multisig)
  • P2SH-P2WSH (embedded Segwit Multisig)

Since we are using bitcoin.js which is already supports multisig like here https://github.com/bitcoinjs/bitcoinjs-lib/blob/1f92ada3fda587c1c0a6aa93649afa04e8382b93/test/integration/transactions.spec.ts#L204

No USD price and chart

For AE tokens in the wallet, we see a balance $0.0, without any chart showing the token price changes.

Seems like the functionality is handled here:

function price (fsym, tsyms, options) {
options = options || {}
let url = `${baseUrl}price?fsym=${fsym}&tsyms=${tsyms}`
if (options.exchanges) url += `&e=${options.exchanges}`
if (options.tryConversion === false) url += '&tryConversion=false'
return fetchJSON(url)
}

When fetching the price directly it works:

$ curl -s "https://min-api.cryptocompare.com/data/price?fsym=AE&tsyms=USD" | jq '.'
{
  "USD": 0.1917
}

It worked fine couple months ago.

Sync / Signing Protocol Enhancement

Airgap currently uses a very basic protocol to sync wallets, send requests for signing transactions and broadcast signed transactions.

We propose a new protocol that does replace the existing one with the following design goals:

  • Allow Apps such as AirGap Vault to properly display all necessary information when signing a transaction
  • Make sure to not transmit redundant information, send only what is necessary
  • Sign exactly the data that is sent in the request, also for easy verifiability whether the request was tampered with on the way

The following data is necessary for a user to verify his transaction properly:

  • From-Address (where does this transaction get sent from)
  • To-Address (where does this transaction go)
  • Amount (what value is transmitted in this transaction)
  • Fee (what will this transaction cost me)
  • Protocol (what type of coin/protocol does this transaction rely upon)

Coins/Protocols might add data that is necessary for proper signing such as data in case of Ethereum, or Inputs/Outputs in case of Bitcoin.

General Thoughts

This protocol solves a couple of similar use cases such as EIP 681, although not completely the same. We aim to use the protocol to facilitate communicate between cold-storage wallets / devices and internet-connected devices using a one-way method such as cameras (=> QR Codes). This adds another design goal, size-efficiency. EIP 681 or similar protocols in Bitcoin, rely on the receiver having access to the internet in order to fetch necessary properties (fpr example nonce or UTXO).

The protocol consists of two layers:

  • The basic approach on how serialization and encoding is handled
  • The content of individual payloads, which can differ given its purpose

Basic Approach

Serialization - RLP

We chose RLP as our serialization method due to two reasons:

  • RLP is enjoying more adaption in crypto, with Aeternity adapting RLP as well after Ethereum
  • It is able to serialize and deserialize data in a predictable way
  • Easy to understand and implement
  • Encoded Data as Binary, size-efficient

Encoding in URL - Base64

We use base64 to encode the data when embedded in a URL-Scheme to further shorten the amount of characters necessary in comparison to HEX-Data (Base16).

Example of Protocol Payloads

The type of request that is encoded in the protocol is always determined by the scheme / url that the request is sent to. The data itself does not include information about "what" it is, similar to how an ethereum TX does not do that. As we always have to include some kind of URL-Scheme regardless, this information would be redundant anyways.

1. Syncing a Cryptocurrency Wallet

Version: [number]
Protocol Identifier: [string]
Public Key: [string]
Derivation Path: [string]
isExtendedPublicKey: [1 || 0]

In case of syncing an ETH wallet, this could look sth like this:

[
 [1], // version
 ['eth'], // protocol identifier
 ['03c2c5da503a199294e2354425f9571d060a3a5971b4c61fcdccaf035d0fb18e6d'], // public-key
 ['m/44'/60'/0'/0'], // derivation path
 [0], // whether is an extended publicKey or not
]
[[1],['eth'],['03c2c5da503a199294e2354425f9571d060a3a5971b4c61fcdccaf035d0fb18e6d'],['m/44'/60'/0'/0'],[0]]

Which base64-encoded and embedded in a scheme equals:

airgap-wallet://sync?data=+F/BAcSDZXRo+ES4QjAzYzJjNWRhNTAzYTE5OTI5NGUyMzU0NDI1Zjk1NzFkMDYwYTNhNTk3MWI0YzYxZmNkY2NhZjAzNWQwZmIxOGU2ZM+ObS80NCcvNjAnLzAnLzDBgA==

2. Transaction Signing Request

Version: [number]
Protocol Identifier: [string]
From: [[string]...]
To: [[string]...]
Amount: [BigNumber.toString]
Fee: [BigNumber.toString]
Public Key: [string]
Callback: [string]
Unsigned Transaction: [any]

Given the following Ethereum TX:

{
   'nonce': '0x00',
   'gasPrice': '0x04a817c800',
   'gasLimit': '0x5208',
   'to': '0xf5E54317822EBA2568236EFa7b08065eF15C5d42',
   'value': '0x0de0b6b3a7640000',
   'data': '0x',
   'chainId': 1
}

made from the address 0x7461531f581A662C5dF140FD6eA1317641fFcad2, encoded in RLP this would give us sth like this:

[
 [1], // version
 ['eth'], // protocol identifier
 ['0x7461531f581A662C5dF140FD6eA1317641fFcad2'], // from
 [], // to, in this case we can extract it from the payload
 [], // amount, also possible to extract from the payload
 [], // fee, also possible to extract from the payload
 ['03c2c5da503a199294e2354425f9571d060a3a5971b4c61fcdccaf035d0fb18e6d'], // public-key
 [], // callback scheme
 [
  ['0x00'], //nonce
  ['0x04a817c800'], // gasPrice
  ['0x5208'], // gasLimit
  ['0xf5E54317822EBA2568236EFa7b08065eF15C5d42'], // to
  ['0x0de0b6b3a7640000'], // value
  ['0x'], // data
  [1] // chainId
 ]
]
[[1],['eth'],['0x7461531f581A662C5dF140FD6eA1317641fFcad2'],[],[],[],['03c2c5da503a199294e2354425f9571d060a3a5971b4c61fcdccaf035d0fb18e6d'],[],[['0x00'],['0x04a817c800'],['0x5208'],['0xf5E54317822EBA2568236EFa7b08065eF15C5d42'],['0x0de0b6b3a7640000'],['0x'],[1]]]

Which base64-encoded and embedded in a scheme equals:

airgap-vault://sign?data=+JnBAcSDZXRo1ZR0YVMfWBpmLF3xQP1uoTF2Qf/K0sDAwPhEuEIwM2MyYzVkYTUwM2ExOTkyOTRlMjM1NDQyNWY5NTcxZDA2MGEzYTU5NzFiNGM2MWZjZGNjYWYwMzVkMGZiMThlNmTA8cEAxoUEqBfIAMOCUgjVlPXlQxeCLrolaCNu+nsIBl7xXF1CyYgN4Lazp2QAAMGAwQE=

Open Questions

  • What do we accept as callback scheme?
  • Callback Scheme should probably be whitelisted due to security concerns, what happens if a non-whitelisted scheme is supplied?
  • Does the callback scheme only support custom URL schemes or universal links?

Tao (Bittensor) Support

Hi, I would like to add support for a token of the bittensor project based on substrate. I noticed you already have substrate integration so I anticipate it will be manageable to implement.

AFAIK there is a devteam-hosted block explorer (and RPC node) which is based on polkadotjs as well as a dockerized RPC node available.

I hope to start working on this soon. Thanks.

Lets add Blockchains

BSC, Cronos, Solana, Terra, Avalanche, Fantom, Harmony, Elrond (i know they wont all be possible in the near term, but whichever integrations wouldnt be too extensive, let me know which would be most easiest and ill see if i can make it happen. I say that because i am just starting in blockchain development, but i really want to do this to gain experience and to have something highly productive and scalable to show a recruiter. Of course I am going to change some things, personalize the design and make a fork for my portfolio,
comment your suggestions for easiest blockchain integration for me to get started or a specific DApp if you think that would be better
Anybody can email me at [email protected]

TezosKtProtocol.delegateInfo misleading

naming on two methods is misleading:

TezosKtProtocol.delegateInfo returns DelegationRewardInfo

and

TezosKtProtocol.isAddressDelegated returns DelegationInfo

The naming would suggest that I receive in the first call "DelegationInfo" (because I'm not asking form rewards info) and the second call I would expect to receive a boolean.

-> change the naming or change the return.

Adding a new protocol to the library

Hi guys,

What's the process of adding a new blockchain into this?, I wanted to add another staking network .

I felt this wallet is good as your security is awesome.

let me know the steps

Thanks

Examples not working

I've cloned this repo, did npm i and according to https://github.com/airgap-it/airgap-coin-lib/blob/master/examples/readme.md

$ npx ts-node examples/serializer/create-qr.ts 
/usr/local/lib/node_modules/ts-node/src/index.ts:859
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^
TSError: ⨯ Unable to compile TypeScript:
examples/serializer/create-qr.ts:6:3 - error TS2322: Type 'number' is not assignable to type 'string'.

6   id: generateId(8),
    ~~

  packages/serializer/src/v2/message.ts:22:3
    22   id: string
         ~~
    The expected type comes from property 'id' which is declared here on type 'IACMessageDefinitionObject'
examples/serializer/create-qr.ts:37:3 - error TS2322: Type 'number' is not assignable to type 'string'.

37   id: generateId(8),
     ~~

  packages/serializer/src/v2/message.ts:22:3
    22   id: string
         ~~
    The expected type comes from property 'id' which is declared here on type 'IACMessageDefinitionObject'
examples/serializer/create-qr.ts:48:20 - error TS2673: Constructor of class 'SerializerV3' is private and only accessible within the class declaration.

48 const serializer = new SerializerV3()
                      ~~~~~~~~~~~~~~~~~~
examples/serializer/create-qr.ts:52:16 - error TS7006: Parameter 'serialized' implicitly has an 'any' type.

52   .then(async (serialized) => {
                  ~~~~~~~~~~

    at createTSError (/usr/local/lib/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/usr/local/lib/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/usr/local/lib/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/usr/local/lib/node_modules/ts-node/src/index.ts:1433:41)
    at Module.m._compile (/usr/local/lib/node_modules/ts-node/src/index.ts:1617:30)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Object.require.extensions.<computed> [as .ts] (/usr/local/lib/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1023:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12) {
  diagnosticCodes: [ 2322, 2322, 2673, 7006 ]
}

Add BCH support

It should be fairly easy as it is almost the same as Bitcoin BTC

Token support plans?

I like the work you guys are doing, very cool. Any plans to support:

It would be good to add support plans / roadmap to your supported currencies page? (If you don't already have it somewhere and I'm missing it)

I accidentally added a random "Z" in the yarn.lock and got this exact error. The error pointed at line 51, but the Z was way down in the middle of the file. Checking for typos is a good first step if you get this error.

I accidentally added a random "Z" in the yarn.lock and got this exact error. The error pointed at line 51, but the Z was way down in the middle of the file. Checking for typos is a good first step if you get this error.

Originally posted by @kylezeeuwen in yarnpkg/yarn#6152 (comment)

Binance Smart Chain support

Greetings.

This issue is related to airgap-it/airgap-wallet#55.

As the title suggests, I would like to implement BSC support into AirGap. As per #7, AirGap as a project prefers not to accumulate features that the maintainers cannot properly maintain, so I understand that my changes could end up not merged, which is fair considering the security centric approach of this project.

As per "Contribute Guidelines", I would like to know if there is interest in such a PR before implementing it?

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.