liquality / chainify Goto Github PK
View Code? Open in Web Editor NEWBlockchain abstraction layer
Home Page: https://liquality.io
License: MIT License
Blockchain abstraction layer
Home Page: https://liquality.io
License: MIT License
Export ES6 library in package.json's module
field
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:
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.
}
,...
]
You should pass message prefix when signing messages - '\u0018Bitcoin Signed Message:\n'
You have to take into account what type is the address signing the message i.e. if it's segwit you should pass { segwitType: 'p2wpkh' }
You need to encode the string as base64
in order to be able to verify it.
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)
Currently the BitcoinNodeWalletProvider
does not provide publicKey
, derivationPath
or index
. Should call validateaddress
on the node to get this info.
Signing here should be 0 and not based on the previous tx's vin.index
Sometimes getting NPE.
NPE check is needed here https://github.com/liquality/chainabstractionlayer/blob/6db965f46d5437f68ff49c2e235e9a3732051296/packages/bitcoin-js-wallet-provider/lib/BitcoinJsWalletProvider.js#L383
Update address util file toString method to return
Also verify that it is an address object
I saw a contract here, but it looks different from createSwapScript
There is also an EIP, but I'm not sure whether they are same or not
Hi, I'm not familiar with your project. I did a search for https://bitcoinfees.earn.com/api/v1/fees/recommended
and am alerting projects using this API to inaccurate & old data.
An up-to-date API with accurate data would be https://mempool.space/api/v1/fees/recommended
or some alternative.
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"
}
Currently, if scraper is stalled, requesting txs returns old txs but not new.
Related: liquality/atomicagent#32
Currently, including any ledger
packages from CAL in a chrome extension, will return the following regeneratorRuntime
error.
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.
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.
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
Adding a new provider will erase the this
object inside a previously added provider. (I think)
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:
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)
}
Blockscanning using the esplora api is unnecessary for finding swap transactions.
Extend the provider to retrieve transactions by script hash.
Include tests
Currently, Error
is thrown when something goes wrong. We should start using subclasses of Error
like TypeError
etc.
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.
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).
Also check for the transaction receipt status line 97:
return transaction.input === data && transaction.value === value && transaction.status
In this file:
There are two generateSwaps in Eth providers, one in MetaMask and one in Swap.
Just something I found that I thought was worthwhile to log. With the default webpack 3 setup this error get thrown when importing into a project.
It is fixed by using this webpack addon which is natively included in webpack 4.
Currently validateAddress
fails for p2sh-segwit addresses in bitcoin-utils.
One would expect these types of addresses to succeed for all types of addresses... legacy, p2sh-segwit, segwit.
If this function is specifically to be used for validating swap addresses, then it should probably be renamed to validateSwapAddress
.
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 }
If you try to call isAddressUsed
in BitcoinEsploraApiProvider
and error will come up if you don't also include BitcoinRpcProvider
since getReceivedByAddress
is not implemented
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)
The default for this should return the default wallet balance, this call now mimics getreceivedbyaddress
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.
When trying these examples, for example, examples/browser/ethereum/metamask.html
,the html file does not work as I expcected.
The examples/browser/ethereum/metamask.html
files works fine.
MateMaskProvider.js
throws an error: invalid MetaMaskProvider
.
examples/browser/ethereum/metamask.html
in ChromeMateMaskProvider.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
}
Prettier configuration or VS config is missing. Can you please add one.
bitcoinjs-lib
added the ability to always have low R values during transaction creation: bitcoinjs/bitcoinjs-lib#1442
This means signature size is at most 71 bytes, and maxWitnessLen
goes from 108 to 107
It also has other benefits, such as saving several bytes on txs for multisigs: bitcoinjs/bitcoinjs-lib#1175 (comment)
Would be great if there were a way to force low R values during transaction creation, or default to this for CAL.
getWalletAddress
doesn't check change addresses https://github.com/liquality/chainabstractionlayer/blob/dev/packages/ledger-provider/lib/LedgerProvider.js#L124
This should be changed to include change address in the check.
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.
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
Optimizing the existing swap process to utilize second layer scaling solutions such as offchain swaps
https://blog.lightning.engineering/announcement/2017/11/16/ln-swap.html
https://lists.linuxfoundation.org/pipermail/lightning-dev/2018-December/001752.html
Example contract: https://etherscan.io/address/0x5beaea3b149fe1b1a57473aaff631d03adc1ee01
After the refund, more transactions should not be possible to the contract.
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.
Hello,
I want to add new chain to the CAL, but not sure how to get started. Any guide would be really helpful
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.
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:
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:
Result:
amount (numeric) The total amount in BTC received at this address.
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"
}
https://github.com/LedgerHQ/ledgerjs
Also related to #209
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.
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
}
}
The ethereum ledger provider currently sets a 300,000 gas limit. Change this to actually estimate the gas limit using the node.
https://github.com/liquality/chainabstractionlayer/pull/152/files#r269974991
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.
Adding a more configuration oriented approach to supporting additional bitcoin chain clones. Examples include litecoin
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.