This repository has been archived by the owner on Jun 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 74
WIP: Receiving blockchain transactions #1123
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@T-Dnzt All pending tests implemented 🎉 |
# Conflicts: # apps/eth_blockchain/lib/eth_blockchain/block.ex # apps/eth_blockchain/test/eth_blockchain/block_test.exs # apps/eth_geth_adapter/lib/eth_geth_adapter/block.ex # apps/ewallet_db/priv/repo/seeds_sample/00_token.exs # apps/ewallet_db/priv/repo/seeds_sample/01_exchange_pair.exs
mederic-p
approved these changes
Aug 28, 2019
PR description updated with all the changes. @T-Dnzt @mederic-p please have a look. |
Github is not basing of the |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue/Task Number:
Overview
This PR adds an
AddressTracker
module that handles relevant transactions, inserting them in the DB if they are related to the hot wallet address or to one of the deposit wallet address.An HD wallet system had to be implemented to support generating deposit wallet addresses for each internal wallet.
Changes
New tables/schemas:
EWalletDB.BlockchainDepositWallet
- Stores the address, public key and HD derivation path for each specific blockchain deposit wallets.EWalletDB.BlockchainHDWallet
- Keeps a reference to theKeychain.Key
where the private key to a HD wallet is stored.EWalletDB.BlockchainState
- Keeps track of a connected blockchain's overall state. Currently tracks the latest block number.Impacted tables/schemas:
EWalletDB.BlockchainWallet
- Keeps track of blockchain wallets recognized by the eWallet. The eWallet does not necessary have private keys to these wallets.EWalletDB.Wallet
- The existing wallet now holds references toEWalletDB.BlockchainDepositWallet
so funds from blockchain can be deposited directly to these internal wallets. The relationship ishas_many
at DB level, but exposed ashas_one
at application level.New endpoint:
/wallet.generate_deposit_address
- Generates a deposit address for an existingEWalletDB.Wallet
Impacted endpoint:
/transaction.create
- Now supports fund transfers from a hot wallet to an external blockchain addressAdded behaviours:
mix seed --blockchain
- Added blockchain HD wallet seeding to the existing--blockchain
seed.EWallet.AddressTracker
- Tracks a specific blockchain address for activities, e.g. new transactions, and add the state to the eWallet.EWallet.TransactionTracker
- Tracks a specific transaction for activities, e.g. number of block confirmations, and update the eWallet state accordingly.Implementation Details
The majority of the implementation include:
AdminAPI
:AdminAPI.V1.WalletController.generate_deposit_address/2
andEWallet.BlockchainDepositWalletGate
to handle blockchain deposit wallet generationAdminAPI.V1.ConfigurationController
to support primary hot wallet validationAdminAPI.ConnCase
to prepare anEWalletDB.BlockchainHDWallet
during test setupEthBlockchain
:EthBlockchain.Block.get/3
andEthGethAdapter.Block.get/1
to get a block by its block numberEthBlockchain.Block.get_transactions/3
to get a list of transactions in the given block numberEthBlockchain.DumbReceivingAdapter
that simulates transactions from/to the hot walletEWallet
:EWallet.BlockchainAddressFetcher
that parses input for wallet addresses that are trackable by the eWalletEWallet.BlockchainStateGate
that retrieves the blockchain state, e.g. last transacted block number and highest block number seen, for processing.EWallet.BlockchainLocalTransactionGate
that takes a blockchain-confirmed transaction and reflect the newly confirmed transaction into the local ledger.EWallet.BlockchainTransactionGate
to start tracking blockchain transaction statusEWallet.AddressTracker
that keeps track of a blockchain address and reflects any new transaction events intoEWalletDB.Transaction
EWallet.DBCase
to prepare anEWalletDB.BlockchainHDWallet
during test setupEWalletDB
:EWalletDB.BlockchainDepositWallet
(see Changes above)EWalletDB.BlockchainHDWallet
(see Changes above)EWalletDB.BlockchainState
(see Changes above)EWalletDB.BlockchainWallet.get_all_hot/2
to list all known hot walletsEWalletDB.TransactionState
to handle each transaction's possible transitionsEWalletDB.Token.all_blockchain/2
to list all tokens that are linked to the blockchainEWalletDB.Transaction.get_last_blk_number/1
that returns the latest block number that has a transaction saved to the eWalletUsage
N/A
Impact
API schema updated. DB migration required. Seeding required to enable blockchain.