• o9_217670
  • 2.5MB
  • zip
  • 0
  • VIP专享
  • 0
  • 2022-04-26 01:23
区块链_钱包 多钱包-分步指南 初始要求-新启动 一家新成立的公司的主要重点是建立一个既支持传统资产(黄金,白银,股票等)又支持当前非常热门的话题-加密资产的投资组合管理系统(PMS)! 但是,由于有很多硬币,我们的任务是了解高清钱包的工作原理,并建立一个可以创建它们的系统。 争夺市场 hd-wallet-derive derive-一种命令行工具,支持BIP32,BIP39和BIP44,并且还支持最受欢迎钱包的非标准派生路径。 不幸的是,在python有许多可用的工具,我们需要将脚本与python集成在后端。 一旦使用此“通用”钱包进行集成,就可以管理300多个硬币中的数十亿个地址,从而在竞争中占据重要优势。 依存关系 必须在操​​作系统(任何版本5或7)上安装PHP。 无需了解任何PHP 克隆工具。 Python比特币库。 Python以太坊库。 指示 项目设置 创建一个名
  • Blockchain_Wallet-master
  • wallet
  • .ipynb_checkpoints
  • wallet-checkpoint.py
  • constants-checkpoint.py
  • wallet-checkpoint.ipynb
  • __pycache__
  • constants.cpython-37.pyc
  • hd-wallet-derive
  • derive
  • .DS_Store
  • wallet.ipynb
  • wallet.py
  • constants.py
  • images
  • Images
  • .DS_Store
  • .newtons-coin-cradle.jpg.icloud
  • BitcoinTestnet.png
  • jasonPrint.png
  • directory-tree.png
  • transaction-status.png
  • BTCTEST_Transaction.png
  • README.md
# Blockchain_Wallet ![newtons-coin-cradle](Images/newtons-coin-cradle.jpg) ## Multiwallet - Step by Step Guide --- #### Initial Requirements - New Startup Main Focus of a newly startup company is to build a portfolio management system (PMS) that supports both, traditional assets (gold, silver, stocks, etc.) and currently very hot topic - crypto-assets!! But as there are many coins, our task is to understand how HD wallets work, and to build a system that can create them. #### Race to capture the market `hd-wallet-derive` - A command line tool that supports BIP32, BIP39 and BIP44 and also supports non-standard derivation paths for the most popular wallets. Unfortunately, there arent many tools available in `python` and we need to integrate the script in backend with `python`. Once the integration is done with this "universal" wallet, one can manage billions of addresses across 300+ coins, giving a serious edge against the competition. ## Dependencies - PHP must be installed on operating system (any version, 5 or 7). No need to know any PHP - Clone the [`hd-wallet-derive`](https://github.com/dan-da/hd-wallet-derive) tool. - [`bit`](https://ofek.github.io/bit/) Python Bitcoin library. - [`web3.py`](https://github.com/ethereum/web3.py) Python Ethereum library. ## Instructions <details> <summary>Project setup</summary> - Create a project directory called `wallet` and `cd` into it. - Clone the `hd-wallet-derive` tool into this folder and install it using the instructions on its `README.md`. - Create a symlink called `derive` for the `hd-wallet-derive/hd-wallet-derive.php` script into the top level project directory like so: `ln -s hd-wallet-derive/hd-wallet-derive.php derive` This will clean up the command needed to run the script in the code, to call `./derive` instead of `./hd-wallet-derive/hd-wallet-derive.php.exe`. - Test run the `./derive` script properly, use one of the examples on the repo's `README.md` *Note*: If one gets an error running `./derive`, as it happens in Windows machine then use: `./hd-wallet-derive/hd-wallet-derive.php.exe` - Create a file called `wallet.py` -- universal wallet script. Directory tree for `hd-wallet-derive` ![directory-tree](images/directory-tree.png) </details> <details> <summary>Setup constants</summary> - In a separate file, `constants.py`, set the following constants: - `BTC = 'btc'` - `ETH = 'eth'` - `BTCTEST = 'btc-test'` - In `wallet.py`, import all constants: `from constants import *` - Use these anytime to reference these strings, both in function calls, and in setting object keys. </details> <details> <summary>Generate a Mnemonic</summary> - Generate a new 12 word mnemonic using `hd-wallet-derive` or by using [this tool](https://iancoleman.io/bip39/). - Set this mnemonic as an environment variable, and include the one generated as a fallback using: `mnemonic = os.getenv('MNEMONIC', 'insert mnemonic here')` </details> <details> <summary>Deriving the wallet keys</summary> - Use the `subprocess` library to call the `./derive` script from Python. Make sure to properly wait for the process. - The following flags must be passed into the shell command as variables: - Mnemonic (`--mnemonic`) must be set from an environment variable, or default to a test mnemonic - Coin (`--coin`) - Numderive (`--numderive`) to set number of child keys generated - Set the `--format=json` flag, then parse the output into a JSON object using `json.loads(output)` - Wrap all of this into one function, called `derive_wallets` - Create an object called `coins` that derives `ETH` and `BTCTEST` wallets with this function. When done properly, the final object should look something like this (there are only 3 children each in this image): ![wallet-object](images/jasonPrint.png) Test the `coins` by calling `coins[COINTYPE][INDEX]['privkey']`. </details> <details> <summary>Linking the transaction signing libraries</summary> Use `bit` and `web3.py` to leverage the keys obtained in the `coins` object. Create 3 more funtions: 1. `priv_key_to_account` -- this will convert the `privkey` string in a child key to an account object that `bit` or `web3.py` can use to transact. This function needs the following parameters: - `coin` -- the coin type (defined in `constants.py`). - `priv_key` -- the `privkey` string will be passed through here. Check the coin, then return one of the following functions based on the library: - For `ETH`, return `Account.privateKeyToAccount(priv_key)` - For `BTCTEST`, return `PrivateKeyTestnet(priv_key)` 2. `create_tx` -- this will create the raw, unsigned transaction that contains all metadata needed to transact. This function needs the following parameters: - `coin` -- the coin type (defined in `constants.py`). - `account` -- the account object from `priv_key_to_account`. - `to` -- the recipient address. - `amount` -- the amount of the coin to send. Check the coin, then return one of the following functions based on the library: - For `ETH`, return an object containing `to`, `from`, `value`, `gas`, `gasPrice`, `nonce`, and `chainID`. Make sure to calculate all of these values properly using `web3.py`! - For `BTCTEST`, return `PrivateKeyTestnet.prepare_transaction(account.address, [(to, amount, BTC)])` 3. `send_tx` -- this will call `create_tx`, sign the transaction, then send it to the designated network. This function needs the following parameters: - `coin` -- the coin type (defined in `constants.py`). - `account` -- the account object from `priv_key_to_account`. - `to` -- the recipient address. - `amount` -- the amount of the coin to send. Check the coin, then create a `raw_tx` object by calling `create_tx`. Then, sign the `raw_tx` using `bit` or `web3.py` (hint: the account objects have a sign transaction function within). Once signed the transaction, send it to the designated blockchain network. - For `ETH`, return `w3.eth.sendRawTransaction(signed.rawTransaction)` - For `BTCTEST`, return `NetworkAPI.broadcast_tx_testnet(signed)` </details> <details> <summary>Execute the transactions</summary> ***Bitcoin Testnet transaction*** - Fund a `BTCTEST` address using [this testnet faucet](https://testnet-faucet.mempool.co/). - Use a [block explorer](https://tbtc.bitaps.com/) to watch transactions on the address. ***BTCTEST Transaction*** `btc_test_acc = priv_key_to_account(BTCTEST,btc_test_PrivateKey)` `create_tx(BTCTEST,btc_test_acc,"n1u1MQ11bBZvj6JzjzJKxiT5PgCsfc3ZiQ", 0.01)` `send_txn(BTCTEST,btc_test_acc,"n1u1MQ11bBZvj6JzjzJKxiT5PgCsfc3ZiQ", 0.01)` Confirmation on executed transaction ![btc-test](images/BTCTEST_Transaction.png) ***ETH Transaction - Local PoA*** - Add one of the `ETH` addresses to the pre-allocated accounts in `mtestnet.json` - Initialize using `geth --datadir nodeX init mtestnet.json`. - [Add the following middleware](https://web3py.readthedocs.io/en/stable/middleware.html#geth-style-proof-of-authority) to `web3.py` to support the PoA algorithm: `from web3.middleware import geth_poa_middleware w3.middleware_onion.inject(geth_poa_middleware, layer=0)` - Connect to HTTP with address private key `w3 = Web3(Web3.HTTPProvider(""))` - Due to a bug in `web3.py`, send a transaction or two with MyCrypto first, since the `w3.eth.generateGasPrice()` function does not work with an empty chain. Use one of the `ETH` address `privkey`, or one of the `node` keystore files. - Send a transaction from the pre-funded address within the wallet to another, then get the `TxStatus` from MyCrypto ` ![eth-transaction](images/transaction-status.png)
    • supply-chain:基于FISCO-BCOS区块链的供应链demo,使用node.js构建后端
      前端/后端/链端 胡邱诗雨 18340056 计科3班 前端/链端 谢善睿 18340184 计科7班 前端/链端 实验报告见 。 演示视频见 。 目录文件说明: accounts: 区块链账户的公钥和私钥。 authentications: FISCO-BCOS 区块链链...
    • Liquidity-Module-For-the-Hub
      流动性模块使集线器能够为流动性提供者和掉期请求者拥有完整的简单AMM(自动做市商)功能的后端实用程序流。 虽然实施的一般结构来自Uniswap,但我们定制了几种设计来改善经济激励系统,提供更好的用户体验,并适合...
    • Cashmunity:Memo.cashBlockpress 后端
      这个轻量级后端针对特定协议交易扫描和规范比特币现金区块链,并提供简单的查询端点。 目前支持的协议: 备忘录(截至 2018 年 5 月 9 日 ) Blockpress(截至 2018 年 5 月 9 日的 v1.2 ) 先决条件 比特币节点...
    • explorer:开源统一区块链浏览器
      后端由GraphQL接口提供。 想象 我们正在构建区块链资源管理器。 在大多数情况下,所有区块链浏览器都是相似的-它们都显示区块链状态的区块,交易,操作,硬币转移和其他技术信息。 它们几乎都是针对区块链协议的,...
    • Multy-back:Multy的后端-移动Multy区块链钱包
      适用于应用程序的后端服务器 使用说明 在所有情况下,您multy.config在multy.config文件中使用地址,密码,标记和其他设置来设置配置参数。 注意,该配置文件必须与二进制文件位于同一目录中。 从来源 要构建Multy-...
    • ethereum-delegated-tx-service:通用以太坊委派的交易后端。 最后让用户轻松使用区块链
      以太坊委托交易通用后端 优雅的以太坊委托交易实现。 首先,委托交易或元交易允许用户以代币而不是以太币支付费用,从而使加密用户的体验再次焕然一新。 该后端随附可,该可用于支持通过签名执行某些操作的任何...
    • BookChain:基于区块链的图书馆管理系统
      书链 Rest-API作为基于区块链的图书馆管理系统的后端 特征 基于物联网的图书馆管理 基于区块链 点对点图书转移
    • 区块链精通课程
    • backend:区块链
      点阵后端 会写指令 安装和运行 安装 需要eris-db来运行区块链。 需要node.js来运行服务器。 安装最新版本+ npm(包括在标准安装中)。 将存储库拉入CD并放入根目录,然后进行npm install , npm update 。 跑步 ...
    • 区块链项目开发实战.zip