Code Monkey home page Code Monkey logo

chainify's Introduction

Liquality

Standard Code Style MIT License Liquality Gitter Telegram

A handy tool to quickly get started with Liquality Atomic Swap (https://liquality.io)

Usage

npx liquality --help

Usage: liquality [options]

Options:
  -V, --version            output the version number
  -s, --skip-latest-check  Use the most recent version available on the disk
  -d, --do-not-open        Do not open the application link in the browser
  -p, --port <port>        Application port. Default 8080
  --use-http               Use HTTP
  --btc-rpc <url>          Bitcoin RPC endpoint. Default http://localhost:18332
  --btc-rpc-user <user>    Bitcoin RPC user. Default bitcoin
  --btc-rpc-pass <pass>    Bitcoin RPC pass. Default local321
  --eth-rpc <url>          Ethereum RPC endpoint. Default http://localhost:8545
  -h, --help               output usage information

Installation

npm i -g liquality

Deploy Your Own Liquality Instance

Deploy

License

MIT

chainify's People

Contributors

andonmitev avatar b0b4456 avatar beemi avatar bradleysuira avatar dependabot[bot] avatar deswurstes avatar developerfred avatar github-actions[bot] avatar gr0kchain avatar grandsmarquis avatar greenkeeper[bot] avatar harshjv avatar i3wgnit avatar jennievon avatar jesseabram avatar koderholic avatar kraikov avatar matthewjablack avatar mintheredonethat avatar monokh avatar skeremidchiev avatar snyk-bot avatar t0mcr8se avatar tima-t avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar

chainify's Issues

Quick init using umd module

var bitcoin = new ChainAbstractionLayer.Client("bitcoin://user:pass@localhost:18443/")

gives me the following error

{
    message: "bitcoin.BitcoinRPCProvider not found",
    name: "ProviderNotFoundError",
    stack: "ProviderNotFoundError: bitcoin.BitcoinRPCProvider …t/index.umd.js:17:102108)↵    at <anonymous>:1:16"
}

Refrain from using third party api's

https://github.com/ConsenSys/chainabstractionlayer/blob/e922f712a99c457ccddf607b597ec3e854a393ea/src/providers/bitcoin/BitcoinLedgerProvider.js#L33

Replace this with the rpc's calls to bitcoind using

importaddress "address" ( "label" rescan p2sh )

Adds a script (in hex) or address that can be watched as if it were in your wallet but cannot be used to spend. Requires a new wallet backup.

Arguments:

  1. "script" (string, required) The hex-encoded script (or address)
  2. "label" (string, optional, default="") An optional label
  3. rescan (boolean, optional, default=true) Rescan the wallet for transactions
  4. p2sh (boolean, optional, default=false) Add the P2SH version of the script as well

Note: This call can take minutes to complete if rescan is true, during that time, other rpc calls
may report that the imported address exists but related transactions are still missing, leading to temporarily incorrect/bogus balances and unspent outputs until rescan completes.
If you have the full public key, you should call importpubkey instead of this.

Note: If you import a non-standard raw script in hex form, outputs sending to it will be treated
as change, and not show up in many RPCs.

getreceivedbyaddress "address" ( minconf )

Returns the total amount received by the given address in transactions with at least minconf confirmations.

Arguments:

  1. "address" (string, required) The bitcoin address for transactions.
  2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.

Result:
amount (numeric) The total amount in BTC received at this address.

Need Bitcoin Wallet Provider that doesn't require ledger

Currently everything in CAL relies on ledger for signing, to generating transactions, on bitcoin. It would be great to be able to do this directly by interacting with the bitcoin node.

Essentially there needs to be a Bitcoin Wallet Provider and Bitcoin Swap Provider

Export different modules

Currently, ChainAbstractionLayer is exported by default and Provider, providers, schemas, crypto are added statically to ChainAbstractionLayer. This makes it hard to only import specific modules of our library.

index.js

import ChainAbstractionLayer from './ChainAbstractionLayer'
import Provider from './Provider'
import crypto from './crypto'
import providers from './providers'
import BlockSchema from './schema/Block.json'
import TransactionSchema from './schema/Transaction.json'

export {
  ChainAbstractionLayer,
  Provider,
  crypto,
  providers,
  schemas: {
    Block: BlockSchema,
    Transaction: TransactionSchema
  }
}

Issue about examples in chainabstractionlayer

I want to try the swap function. When I use the examples in chainabstractionlayer at https://github.com/liquality/chainabstractionlayer/tree/dev/examples .

MateMaskProvider.js throws an error: invalid MetaMaskProvider.
I don't have a clue how to slove this problem.

Pre-requisites

  • I looked through both open and closed issues and did not find an existing problem.
  • code: use chainabstractionlayer branch dev
  • bitcoin private network installed
  • ethereum private network installed
  • web3.js v1.2.2 installed
  • MetaMask 7.7.1
  • Linux 16.04
  • Chrome Version 78.0.3904.108 (Official Build) (64-bit)

Description

When trying these examples, for example, examples/browser/ethereum/metamask.html,the html file does not work as I expcected.

Expected Behavior

The examples/browser/ethereum/metamask.html files works fine.

Actual Behavior

MateMaskProvider.js throws an error: invalid MetaMaskProvider.

Steps to Reproduce

  1. start bitcoin private network
  2. start ethereum private network
  3. open examples/browser/ethereum/metamask.html in Chrome
  4. MateMaskProvider.js throws an error: invalid MetaMaskProvider
export default class MetaMaskProvider extends WalletProvider {
  constructor (metamaskProvider, network) {
    super(network)
    if (!isFunction(metamaskProvider.sendAsync)) {
      throw new Error('Invalid MetaMask Provider')
    }
    this._metamaskProvider = metamaskProvider
    this._network = network
  }

error

Create EthereumERC20MementoSwapFindProvider

Using the api and blockscanning for finding swap transactions is too resource heavy when relying on a remote node. As a workaround, the memento api can be used to reduce this burden.

Transactions can be retrieves by address from the memento api.

Some things from #236 can be reused.

Guide to add new chain

Hello,

I want to add new chain to the CAL, but not sure how to get started. Any guide would be really helpful

Cannot read property 'transactions' of null

Occasionally get this error: Cannot read property 'transactions' of null
It doesn't affect the swap. Trace:

EthereumSwapProvider.js:250 Uncaught (in promise) TypeError: Cannot read property 'transactions' of null
    at EthereumSwapProvider.<anonymous> (EthereumSwapProvider.js:250)
    at tryCatch (runtime.js:63)
    at Generator._invoke (runtime.js:282)
    at Generator.e.<computed> [as next] (runtime.js:116)
    at asyncGeneratorStep (asyncToGenerator.js:3)
    at _next (asyncToGenerator.js:25)

Adding support for delegating tx propagation

Investigate a scheme which allows a swap participant to delegate the propagation of either their claim or refund transaction to another member of the network.

Example: Using SIGHASH_SINGLE which leaves a difference on the UTXO which allows anyone on the network to claim the difference between the total amount and the mining fee.

Subclass errors

Currently, Error is thrown when something goes wrong. We should start using subclasses of Error like TypeError etc.

Adding a proof of funds

Although the current BIP199 amendment and ERC1630 standards safeguard users from counter party risk through atomic swaps, it would be good if either party in the exchange was able to verify that they are dealing with a user who is in possession of the keys for the addresses involved in the swap. This mechanism helps ensure that there are no MITM attempts which aim to alter or hijack the swap from the confirming party of the swap.

RpcError: -32000 invalid sender'

Error seems to suggest that the wrong chain config is being used.

Confirm we're testing against a rinkeby eth node

$ curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":67}' http://127.0.0.1:8080/ethereumrpc/
{"jsonrpc":"2.0","id":67,"result":"4"}

Geth log error

WARN [12-05|15:09:16.534] Served eth_sendRawTransaction            conn=127.0.0.1:42954 reqid=1575558555996 t=1.272341ms err="invalid sender"

Agent Config:

  [assets.ETH]
  network = "rinkeby"
    [assets.ETH.rpc]
    url = "http://127.0.0.1:8080/ethereumrpc/"

Error:

2019-12-05T14:35:26.947Z liquality:agent:worker Max attempts reached. Job has failed { _id: 5de91557e86c4452558496ef,
  name: 'reciprocate-init-swap',
  data: { orderId: '7be6c5a3-41f6-4c83-9874-0353e008d8e5' },
  type: 'normal',
  priority: 0,
  nextRunAt: null,
  lastModifiedBy: null,
  lockedAt: null,
  lastRunAt: 2019-12-05T14:35:25.595Z,
  failCount: 6,
  failReason:
   'http://127.0.0.1:8080/ethereumrpc/ - RpcError: -32000 invalid sender',
  failedAt: 2019-12-05T14:35:26.945Z,
  lastFinishedAt: 2019-12-05T14:35:26.945Z }

regeneratorRuntime error when using ledger packages in chrome extension`

Currently, including any ledger packages from CAL in a chrome extension, will return the following regeneratorRuntime error.

image (3)

Not including any ledger packages solves this problem, but webusb and ledger packages should be usable.

Also this is problematic for users that include @liquality/bundle as they may run into this error, not realizing that they should instead only include the necessary packages to stop this error from occurring.

Create EthereumMementoSwapFindProvider

Using the api and blockscanning for finding swap transactions is too resource heavy when relying on a remote node. As a workaround, the memento api can be used to reduce this burden.

The contract address for the swap can be generated and watched for the swap transactions using the memento API.

Include tests

Verify status of the Etherem transaction after deploying HTLC script

I'm not 100% sure about this issue so I did not create a pull request. I'm just scratching the code base but it's maybe worth looking into a possible security flaw.

What's the context

Imagine that I want to take part in an atomic swap (On the Ethereum side and being the one deciding the secret).
If I send my TX with insufficient gas it'll be reverted and I'll keep my ETH but the test to see if the transaction was correct only using the value and input inside of doesTransactionMatchSwapParams will still pass. So I could trick the other person into believing everything is normal (if he does not verify the TX or balance on a block explorer).

How to fix?

Also check for the transaction receipt status line 97:

return transaction.input === data && transaction.value === value && transaction.status

In this file:

https://github.com/liquality/chainabstractionlayer/blob/fab06e57021f290c05fe1c4c5b533b4fb4bcf7d3/src/providers/ethereum/EthereumSwapProvider.js#L97

ReferenceError: regeneratorRuntime is not defined

I'm getting the following error when trying to run the example script.

/btc20node_modules/@ledgerhq/hw-transport-node-hid/lib/TransportNodeHid.js:1
ReferenceError: regeneratorRuntime is not defined
    at /btc20/node_modules/@ledgerhq/hw-transport-node-hid/lib/TransportNodeHid.js:86:50
    at /btc20/node_modules/@ledgerhq/hw-transport-node-hid/lib/TransportNodeHid.js:125:6
    at Object.<anonymous> (/btc20/node_modules/@ledgerhq/hw-transport-node-hid/lib/TransportNodeHid.js:202:2)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)

Refrain from using third party api's

https://github.com/ConsenSys/chainabstractionlayer/blob/e922f712a99c457ccddf607b597ec3e854a393ea/src/providers/bitcoin/BitcoinLedgerProvider.js#L41

getrawtransaction "txid" ( verbose "blockhash" )

NOTE: By default this function only works for mempool transactions. If the -txindex option is
enabled, it also works for blockchain transactions. If the block which contains the transaction
is known, its hash can be provided even for nodes without -txindex. Note that if a blockhash is
provided, only that block will be searched and if the transaction is in the mempool or other
blocks, or if this node does not have the given block available, the transaction will not be found.
DEPRECATED: for now, it also works for transactions with unspent outputs.

Return the raw transaction data.

If verbose is 'true', returns an Object with information about 'txid'.
If verbose is 'false' or omitted, returns a string that is serialized, hex-encoded data for 'txid'.

Arguments:

  1. "txid" (string, required) The transaction id
  2. verbose (bool, optional, default=false) If false, return a string, otherwise return a json object
  3. "blockhash" (string, optional) The block in which to look for the transaction

Result (if verbose is not set or set to false):
"data" (string) The serialized, hex-encoded data for 'txid'

Result (if verbose is set to true):
{
"in_active_chain": b, (bool) Whether specified block is in the active chain or not (only present with explicit "blockhash" argument)
"hex" : "data", (string) The serialized, hex-encoded data for 'txid'
"txid" : "id", (string) The transaction id (same as provided)
"hash" : "id", (string) The transaction hash (differs from txid for witness transactions)
"size" : n, (numeric) The serialized transaction size
"vsize" : n, (numeric) The virtual transaction size (differs from size for witness transactions)
"version" : n, (numeric) The version
"locktime" : ttt, (numeric) The lock time
"vin" : [ (array of json objects)
{
"txid": "id", (string) The transaction id
"vout": n, (numeric)
"scriptSig": { (json object) The script
"asm": "asm", (string) asm
"hex": "hex" (string) hex
},
"sequence": n (numeric) The script sequence number
"txinwitness": ["hex", ...] (array of string) hex-encoded witness data (if any)
}
,...
],
"vout" : [ (array of json objects)
{
"value" : x.xxx, (numeric) The value in BTC
"n" : n, (numeric) index
"scriptPubKey" : { (json object)
"asm" : "asm", (string) the asm
"hex" : "hex", (string) the hex
"reqSigs" : n, (numeric) The required sigs
"type" : "pubkeyhash", (string) The type, eg 'pubkeyhash'
"addresses" : [ (json array of string)
"address" (string) bitcoin address
,...
]
}
}
,...
],
"blockhash" : "hash", (string) the block hash
"confirmations" : n, (numeric) The confirmations
"time" : ttt, (numeric) The transaction time in seconds since epoch (Jan 1 1970 GMT)
"blocktime" : ttt (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)
}

Fuse network integration

Integrating Fuse network on Liquality as per the below instructions

Liquality_Integration_Guide_V1.pdf

We would like to start with the Steps 1-3 as a start.

Below is the link which gives details about Fuse network.

https://docs.fuse.io/the-fuse-chain/network-details

About Fuse network:

Fuse Network is the company behind a decentralized EVM-compatible blockchain and a mobile-payment-focused plug-and-play infrastructure. Its primary focus is on supporting payment-centric token-powered communities and micro economies.

sendTransaction in BitcoinLedgerProvider should enable multiple outputs

Looking at sendTransaction in BitcoinLedgerProvider
(https://github.com/liquality/chainabstractionlayer/blob/master/src/providers/bitcoin/BitcoinLedgerProvider.js#L389)
there are certain instances where it should be able to specify multiple outputs. Or even multiple inputs. This is designed of course to ensure that it is in line with the sendTransaction in (https://github.com/liquality/chainabstractionlayer/blob/master/src/providers/ethereum/EthereumMetaMaskProvider.js#L76) is inline.

Perhaps there's a way both elements could be achieved, or maybe there needs to be a separate function for Bitcoin for multiple inputs and outputs.

Difficulty in number exponential form returns invalid block

When running bitcoind, difficulty is represented as a number exponential (i.e. 4.656542373906925e-10). However JsonRpcProvider parses this as a string. Meaning when @liquality/schema validates the Block it will determine that it's invalid, since it's a string.

Example block that is valid, that will be invalidated

{
  "hash": "1915264161530d46071964f7adcd97dc3f645ef6b3e00a850571c9e75fb4ad46",
  "confirmations": 1,
  "strippedsize": 228,
  "size": 264,
  "weight": 948,
  "height": 1649,
  "version": 536870912,
  "versionHex": "20000000",
  "merkleroot": "e0b2c829e72198339793e169eea05808842d9cc396b9c14045b1736d0381da3e",
  "tx": [
    "e0b2c829e72198339793e169eea05808842d9cc396b9c14045b1736d0381da3e"
  ],
  "time": 1580279280,
  "mediantime": 1580279279,
  "nonce": 0,
  "bits": "207fffff",
  "difficulty": 4.656542373906925e-10,
  "chainwork": "0000000000000000000000000000000000000000000000000000000000000ce4",
  "previousblockhash": "0a6d1a4badd577b58c6e74b18482df58af4cab0b44f3f860de9fbcdcba26f305"
}

Refrain from using third party api's

https://github.com/ConsenSys/chainabstractionlayer/blob/e922f712a99c457ccddf607b597ec3e854a393ea/src/providers/bitcoin/BitcoinLedgerProvider.js#L37

This can be replaced with (note this will only return information assuming you've used the importaddress rpc call)

listunspent ( minconf maxconf ["addresses",...] [include_unsafe] [query_options])

Returns array of unspent transaction outputs
with between minconf and maxconf (inclusive) confirmations.
Optionally filter to only include txouts paid to specified addresses.

Arguments:

  1. minconf (numeric, optional, default=1) The minimum confirmations to filter
  2. maxconf (numeric, optional, default=9999999) The maximum confirmations to filter
  3. "addresses" (string) A json array of bitcoin addresses to filter
    [
    "address" (string) bitcoin address
    ,...
    ]
  4. include_unsafe (bool, optional, default=true) Include outputs that are not safe to spend
    See description of "safe" attribute below.
  5. query_options (json, optional) JSON with query options
    {
    "minimumAmount" (numeric or string, default=0) Minimum value of each UTXO in BTC
    "maximumAmount" (numeric or string, default=unlimited) Maximum value of each UTXO in BTC
    "maximumCount" (numeric or string, default=unlimited) Maximum number of UTXOs
    "minimumSumAmount" (numeric or string, default=unlimited) Minimum sum value of all UTXOs in BTC
    }

Result
[ (array of json object)
{
"txid" : "txid", (string) the transaction id
"vout" : n, (numeric) the vout value
"address" : "address", (string) the bitcoin address
"account" : "account", (string) DEPRECATED. The associated account, or "" for the default account
"scriptPubKey" : "key", (string) the script key
"amount" : x.xxx, (numeric) the transaction output amount in BTC
"confirmations" : n, (numeric) The number of confirmations
"redeemScript" : n (string) The redeemScript if scriptPubKey is P2SH
"spendable" : xxx, (bool) Whether we have the private keys to spend this output
"solvable" : xxx, (bool) Whether we know how to spend this output, ignoring the lack of keys
"safe" : xxx (bool) Whether this output is considered safe to spend. Unconfirmed transactions
from outside keys and unconfirmed replacement transactions are considered unsafe
and are not eligible for spending by fundrawtransaction and sendtoaddress.
}
,...
]

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.