├── .gitignore ├── .metadata ├── CHANGELOG.md ├── LICENSE ├── README.md ├── example ├── .gitignore ├── .metadata ├── README.md ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── example │ │ │ │ │ └── MainActivity.kt │ │ │ └── res │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h ├── lib │ └── main.dart ├── pubspec.lock ├── pubspec.yaml └── test │ └── widget_test.dart ├── lib ├── src │ ├── bitcoin_transaction.dart │ ├── check_types.dart │ ├── crypto.dart │ ├── ecurve.dart │ ├── ethereum_transaction.dart │ ├── handle_big_int.dart │ ├── op.dart │ ├── p2sh.dart │ ├── push_data.dart │ ├── rlp.dart │ ├── rsa_proxy.dart │ ├── script.dart │ └── wallet_config.dart └── wallet_hd.dart ├── pubspec.lock ├── pubspec.yaml └── test └── wallet_hd_test.dart /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .flutter-plugins-dependencies 28 | .packages 29 | .pub-cache/ 30 | .pub/ 31 | build/ 32 | 33 | # Android related 34 | **/android/**/gradle-wrapper.jar 35 | **/android/.gradle 36 | **/android/captures/ 37 | **/android/gradlew 38 | **/android/gradlew.bat 39 | **/android/local.properties 40 | **/android/**/GeneratedPluginRegistrant.java 41 | 42 | # iOS/XCode related 43 | **/ios/**/*.mode1v3 44 | **/ios/**/*.mode2v3 45 | **/ios/**/*.moved-aside 46 | **/ios/**/*.pbxuser 47 | **/ios/**/*.perspectivev3 48 | **/ios/**/*sync/ 49 | **/ios/**/.sconsign.dblite 50 | **/ios/**/.tags* 51 | **/ios/**/.vagrant/ 52 | **/ios/**/DerivedData/ 53 | **/ios/**/Icon? 54 | **/ios/**/Pods/ 55 | **/ios/**/.symlinks/ 56 | **/ios/**/profile 57 | **/ios/**/xcuserdata 58 | **/ios/.generated/ 59 | **/ios/Flutter/App.framework 60 | **/ios/Flutter/Flutter.framework 61 | **/ios/Flutter/Flutter.podspec 62 | **/ios/Flutter/Generated.xcconfig 63 | **/ios/Flutter/app.flx 64 | **/ios/Flutter/app.zip 65 | **/ios/Flutter/flutter_assets/ 66 | **/ios/Flutter/flutter_export_environment.sh 67 | **/ios/ServiceDefinitions.json 68 | **/ios/Runner/GeneratedPluginRegistrant.* 69 | 70 | # Exceptions to above rules. 71 | !**/ios/**/default.mode1v3 72 | !**/ios/**/default.mode2v3 73 | !**/ios/**/default.pbxuser 74 | !**/ios/**/default.perspectivev3 75 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 76 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 840c9205b344a59e48a5926ee2d791cc5640924c 8 | channel: stable 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [0.0.1] 2 | 3 | * initRelease 4 | 5 | ## [0.0.2] 6 | 7 | * fixed some warning -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 shareven 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wallet_hd 2 | 3 | A Flutter package project , it is use for HD wallet . Support BTC, ETH, ERC20-USDT transfer signature. (用于HD钱包,支持BTC、ETH、ERC20-USDT转账签名). 4 | 5 | 6 | ## Getting Started 7 | 8 | Add this line to pubspec.yaml ( 添加这一行到pubspec.yaml) 9 | 10 | ``` 11 | dependencies: 12 | wallet_hd: ^0.0.2 13 | ``` 14 | 15 | ## How To Use 16 | 17 | Use the class `WalletHd` 18 | 19 | Properties and functions: 20 | ``` dart 21 | /// 创建随机助记词 | Create Random Mnemonic 22 | static String createRandomMnemonic 23 | 24 | /// 导入助记词,返回[btc地址 , eth地址] | Import mnemonic words and return [btc address, eth address] 25 | static Future> getAccountAddress 26 | 27 | /// ETH 导入助记词返回私钥 | ETH import mnemonic phrase and return private key 28 | static EthPrivateKey ethMnemonicToPrivateKey 29 | 30 | /// BTC 导入助记词返回私钥wif | BTC import mnemonic phrase and return private key wif 31 | static String btcMnemonicToPrivateKey 32 | 33 | /// BTC转账 | BTC transfer 34 | static Future transactionBTC 35 | 36 | /// ETH转账 | ETH transfer 37 | static Future transactionETH 38 | 39 | /// ERC20USDT转账 | ERC20USDT transfer 40 | static Future transactionERC20USDT 41 | ``` 42 | 43 | ## Examples 44 | 45 | ```dart 46 | import 'package:wallet_hd/wallet_hd.dart'; 47 | 48 | void main() async { 49 | String mnemonic = WalletHd.createRandomMnemonic(); 50 | Map mapAddr = await WalletHd.getAccountAddress(mnemonic); 51 | String btcAddr = mapAddr["BTC"]; 52 | String ethAddr = mapAddr["ETH"]; 53 | String toAddress = "input the to address ..."; 54 | String amount = "0.1"; 55 | String btcTxPack = 56 | await testTransactionBTC(mnemonic, btcAddr, toAddress, amount); 57 | String ethTxPack = 58 | await testTransactionETH(mnemonic, ethAddr, toAddress, amount); 59 | String erc20USDTTxPack = 60 | await testTransactionERC20USDT(mnemonic, ethAddr, toAddress, amount); 61 | print(btcTxPack); 62 | print(ethTxPack); 63 | print(erc20USDTTxPack); 64 | } 65 | 66 | Future testTransactionBTC( 67 | String mnemonic, 68 | String fromAddress, 69 | String toAddress, 70 | String amount, 71 | ) async { 72 | List unspandList = [ 73 | {"txid": "0x12312313aaaaaaaaa", "output_no": 11, "value": "0.2323"}, 74 | {"txid": "0x12312313bbbbbbbbb", "output_no": 12, "value": "0.2323"}, 75 | ]; 76 | List pendingList = [ 77 | {"txid": "0x12312313aaaaaaaaa", "value": "0.2323"} 78 | ]; 79 | double fee = 0.0002655; 80 | List handledUnspandList = unspandList; 81 | // 如果未确认交易列表不为空,则要从unspands list中去除待确认的交易 | If the list of unconfirmed transactions is not empty, remove the pending transactions from the unspands list 82 | if (pendingList.isNotEmpty) { 83 | pendingList.forEach((e) { 84 | handledUnspandList.removeWhere((x) => e["txid"] == x["txid"]); 85 | }); 86 | } 87 | List unspand = handledUnspandList 88 | .map( 89 | (e) => BitcoinIn(e["txid"], e["output_no"], double.parse(e["value"]))) 90 | .toList(); 91 | 92 | String txPack = await WalletHd.transactionBTC( 93 | mnemonic, fromAddress, toAddress, amount, fee, unspand); 94 | print("btc txPack"); 95 | print(txPack); 96 | } 97 | 98 | Future testTransactionETH( 99 | String mnemonic, 100 | String fromAddress, 101 | String toAddress, 102 | String amount, 103 | ) async { 104 | String gasPrice = "113000000000"; 105 | 106 | /// 新创建的账号初始none是-1 | the new account nonce is -1 107 | int nonce = -1; 108 | String txPack = await WalletHd.transactionETH( 109 | mnemonic, fromAddress, toAddress, amount, gasPrice, nonce); 110 | print("eth txPack"); 111 | print(txPack); 112 | } 113 | 114 | Future testTransactionERC20USDT( 115 | String mnemonic, 116 | String fromAddress, 117 | String toAddress, 118 | String amount, 119 | ) async { 120 | String gasPrice = "113000000000"; 121 | 122 | /// 新创建的账号初始none是-1 | the new account nonce is -1 123 | int nonce = -1; 124 | String txPack = await WalletHd.transactionERC20USDT( 125 | mnemonic, fromAddress, toAddress, amount, gasPrice, nonce); 126 | print("eth txPack"); 127 | print(txPack); 128 | } 129 | 130 | 131 | ``` 132 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | **/ios/Flutter/.last_build_id 26 | .dart_tool/ 27 | .flutter-plugins 28 | .flutter-plugins-dependencies 29 | .packages 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Web related 35 | lib/generated_plugin_registrant.dart 36 | 37 | # Symbolication related 38 | app.*.symbols 39 | 40 | # Obfuscation related 41 | app.*.map.json 42 | 43 | # Exceptions to above rules. 44 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 45 | -------------------------------------------------------------------------------- /example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 840c9205b344a59e48a5926ee2d791cc5640924c 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # example 2 | 3 | A new Flutter project. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.dev/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 28 30 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | lintOptions { 36 | disable 'InvalidPackage' 37 | } 38 | 39 | defaultConfig { 40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 41 | applicationId "com.example.example" 42 | minSdkVersion 16 43 | targetSdkVersion 28 44 | versionCode flutterVersionCode.toInteger() 45 | versionName flutterVersionName 46 | } 47 | 48 | buildTypes { 49 | release { 50 | // TODO: Add your own signing config for the release build. 51 | // Signing with the debug keys for now, so `flutter run --release` works. 52 | signingConfig signingConfigs.debug 53 | } 54 | } 55 | } 56 | 57 | flutter { 58 | source '../..' 59 | } 60 | 61 | dependencies { 62 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 63 | } 64 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 8 | 12 | 19 | 23 | 27 | 32 | 36 | 37 | 38 | 39 | 40 | 41 | 43 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/example/example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.example 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.3.50' 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.5.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.enableR8=true 3 | android.useAndroidX=true 4 | android.enableJetifier=true 5 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip 7 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.mode2v3 3 | *.moved-aside 4 | *.pbxuser 5 | *.perspectivev3 6 | **/*sync/ 7 | .sconsign.dblite 8 | .tags* 9 | **/.vagrant/ 10 | **/DerivedData/ 11 | Icon? 12 | **/Pods/ 13 | **/.symlinks/ 14 | profile 15 | xcuserdata 16 | **/.generated/ 17 | Flutter/App.framework 18 | Flutter/Flutter.framework 19 | Flutter/Flutter.podspec 20 | Flutter/Generated.xcconfig 21 | Flutter/app.flx 22 | Flutter/app.zip 23 | Flutter/flutter_assets/ 24 | Flutter/flutter_export_environment.sh 25 | ServiceDefinitions.json 26 | Runner/GeneratedPluginRegistrant.* 27 | 28 | # Exceptions to above rules. 29 | !default.mode1v3 30 | !default.mode2v3 31 | !default.pbxuser 32 | !default.perspectivev3 33 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 11 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 12 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 13 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 14 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 15 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXCopyFilesBuildPhase section */ 19 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 20 | isa = PBXCopyFilesBuildPhase; 21 | buildActionMask = 2147483647; 22 | dstPath = ""; 23 | dstSubfolderSpec = 10; 24 | files = ( 25 | ); 26 | name = "Embed Frameworks"; 27 | runOnlyForDeploymentPostprocessing = 0; 28 | }; 29 | /* End PBXCopyFilesBuildPhase section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 33 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 34 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 35 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 36 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 37 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 38 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 39 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 40 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 42 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 43 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 44 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | /* End PBXFrameworksBuildPhase section */ 56 | 57 | /* Begin PBXGroup section */ 58 | 9740EEB11CF90186004384FC /* Flutter */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 62 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 63 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 64 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 65 | ); 66 | name = Flutter; 67 | sourceTree = ""; 68 | }; 69 | 97C146E51CF9000F007C117D = { 70 | isa = PBXGroup; 71 | children = ( 72 | 9740EEB11CF90186004384FC /* Flutter */, 73 | 97C146F01CF9000F007C117D /* Runner */, 74 | 97C146EF1CF9000F007C117D /* Products */, 75 | ); 76 | sourceTree = ""; 77 | }; 78 | 97C146EF1CF9000F007C117D /* Products */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | 97C146EE1CF9000F007C117D /* Runner.app */, 82 | ); 83 | name = Products; 84 | sourceTree = ""; 85 | }; 86 | 97C146F01CF9000F007C117D /* Runner */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 90 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 91 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 92 | 97C147021CF9000F007C117D /* Info.plist */, 93 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 94 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 95 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 96 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 97 | ); 98 | path = Runner; 99 | sourceTree = ""; 100 | }; 101 | /* End PBXGroup section */ 102 | 103 | /* Begin PBXNativeTarget section */ 104 | 97C146ED1CF9000F007C117D /* Runner */ = { 105 | isa = PBXNativeTarget; 106 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 107 | buildPhases = ( 108 | 9740EEB61CF901F6004384FC /* Run Script */, 109 | 97C146EA1CF9000F007C117D /* Sources */, 110 | 97C146EB1CF9000F007C117D /* Frameworks */, 111 | 97C146EC1CF9000F007C117D /* Resources */, 112 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 113 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 114 | ); 115 | buildRules = ( 116 | ); 117 | dependencies = ( 118 | ); 119 | name = Runner; 120 | productName = Runner; 121 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 122 | productType = "com.apple.product-type.application"; 123 | }; 124 | /* End PBXNativeTarget section */ 125 | 126 | /* Begin PBXProject section */ 127 | 97C146E61CF9000F007C117D /* Project object */ = { 128 | isa = PBXProject; 129 | attributes = { 130 | LastUpgradeCheck = 1020; 131 | ORGANIZATIONNAME = ""; 132 | TargetAttributes = { 133 | 97C146ED1CF9000F007C117D = { 134 | CreatedOnToolsVersion = 7.3.1; 135 | LastSwiftMigration = 1100; 136 | }; 137 | }; 138 | }; 139 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 140 | compatibilityVersion = "Xcode 9.3"; 141 | developmentRegion = en; 142 | hasScannedForEncodings = 0; 143 | knownRegions = ( 144 | en, 145 | Base, 146 | ); 147 | mainGroup = 97C146E51CF9000F007C117D; 148 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 149 | projectDirPath = ""; 150 | projectRoot = ""; 151 | targets = ( 152 | 97C146ED1CF9000F007C117D /* Runner */, 153 | ); 154 | }; 155 | /* End PBXProject section */ 156 | 157 | /* Begin PBXResourcesBuildPhase section */ 158 | 97C146EC1CF9000F007C117D /* Resources */ = { 159 | isa = PBXResourcesBuildPhase; 160 | buildActionMask = 2147483647; 161 | files = ( 162 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 163 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 164 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 165 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 166 | ); 167 | runOnlyForDeploymentPostprocessing = 0; 168 | }; 169 | /* End PBXResourcesBuildPhase section */ 170 | 171 | /* Begin PBXShellScriptBuildPhase section */ 172 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 173 | isa = PBXShellScriptBuildPhase; 174 | buildActionMask = 2147483647; 175 | files = ( 176 | ); 177 | inputPaths = ( 178 | ); 179 | name = "Thin Binary"; 180 | outputPaths = ( 181 | ); 182 | runOnlyForDeploymentPostprocessing = 0; 183 | shellPath = /bin/sh; 184 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; 185 | }; 186 | 9740EEB61CF901F6004384FC /* Run Script */ = { 187 | isa = PBXShellScriptBuildPhase; 188 | buildActionMask = 2147483647; 189 | files = ( 190 | ); 191 | inputPaths = ( 192 | ); 193 | name = "Run Script"; 194 | outputPaths = ( 195 | ); 196 | runOnlyForDeploymentPostprocessing = 0; 197 | shellPath = /bin/sh; 198 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 199 | }; 200 | /* End PBXShellScriptBuildPhase section */ 201 | 202 | /* Begin PBXSourcesBuildPhase section */ 203 | 97C146EA1CF9000F007C117D /* Sources */ = { 204 | isa = PBXSourcesBuildPhase; 205 | buildActionMask = 2147483647; 206 | files = ( 207 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 208 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 209 | ); 210 | runOnlyForDeploymentPostprocessing = 0; 211 | }; 212 | /* End PBXSourcesBuildPhase section */ 213 | 214 | /* Begin PBXVariantGroup section */ 215 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 216 | isa = PBXVariantGroup; 217 | children = ( 218 | 97C146FB1CF9000F007C117D /* Base */, 219 | ); 220 | name = Main.storyboard; 221 | sourceTree = ""; 222 | }; 223 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 224 | isa = PBXVariantGroup; 225 | children = ( 226 | 97C147001CF9000F007C117D /* Base */, 227 | ); 228 | name = LaunchScreen.storyboard; 229 | sourceTree = ""; 230 | }; 231 | /* End PBXVariantGroup section */ 232 | 233 | /* Begin XCBuildConfiguration section */ 234 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 235 | isa = XCBuildConfiguration; 236 | buildSettings = { 237 | ALWAYS_SEARCH_USER_PATHS = NO; 238 | CLANG_ANALYZER_NONNULL = YES; 239 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 240 | CLANG_CXX_LIBRARY = "libc++"; 241 | CLANG_ENABLE_MODULES = YES; 242 | CLANG_ENABLE_OBJC_ARC = YES; 243 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 244 | CLANG_WARN_BOOL_CONVERSION = YES; 245 | CLANG_WARN_COMMA = YES; 246 | CLANG_WARN_CONSTANT_CONVERSION = YES; 247 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 248 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 249 | CLANG_WARN_EMPTY_BODY = YES; 250 | CLANG_WARN_ENUM_CONVERSION = YES; 251 | CLANG_WARN_INFINITE_RECURSION = YES; 252 | CLANG_WARN_INT_CONVERSION = YES; 253 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 254 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 255 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 256 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 257 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 258 | CLANG_WARN_STRICT_PROTOTYPES = YES; 259 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 260 | CLANG_WARN_UNREACHABLE_CODE = YES; 261 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 262 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 263 | COPY_PHASE_STRIP = NO; 264 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 265 | ENABLE_NS_ASSERTIONS = NO; 266 | ENABLE_STRICT_OBJC_MSGSEND = YES; 267 | GCC_C_LANGUAGE_STANDARD = gnu99; 268 | GCC_NO_COMMON_BLOCKS = YES; 269 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 270 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 271 | GCC_WARN_UNDECLARED_SELECTOR = YES; 272 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 273 | GCC_WARN_UNUSED_FUNCTION = YES; 274 | GCC_WARN_UNUSED_VARIABLE = YES; 275 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 276 | MTL_ENABLE_DEBUG_INFO = NO; 277 | SDKROOT = iphoneos; 278 | SUPPORTED_PLATFORMS = iphoneos; 279 | TARGETED_DEVICE_FAMILY = "1,2"; 280 | VALIDATE_PRODUCT = YES; 281 | }; 282 | name = Profile; 283 | }; 284 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 285 | isa = XCBuildConfiguration; 286 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 287 | buildSettings = { 288 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 289 | CLANG_ENABLE_MODULES = YES; 290 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 291 | ENABLE_BITCODE = NO; 292 | FRAMEWORK_SEARCH_PATHS = ( 293 | "$(inherited)", 294 | "$(PROJECT_DIR)/Flutter", 295 | ); 296 | INFOPLIST_FILE = Runner/Info.plist; 297 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 298 | LIBRARY_SEARCH_PATHS = ( 299 | "$(inherited)", 300 | "$(PROJECT_DIR)/Flutter", 301 | ); 302 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example; 303 | PRODUCT_NAME = "$(TARGET_NAME)"; 304 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 305 | SWIFT_VERSION = 5.0; 306 | VERSIONING_SYSTEM = "apple-generic"; 307 | }; 308 | name = Profile; 309 | }; 310 | 97C147031CF9000F007C117D /* Debug */ = { 311 | isa = XCBuildConfiguration; 312 | buildSettings = { 313 | ALWAYS_SEARCH_USER_PATHS = NO; 314 | CLANG_ANALYZER_NONNULL = YES; 315 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 316 | CLANG_CXX_LIBRARY = "libc++"; 317 | CLANG_ENABLE_MODULES = YES; 318 | CLANG_ENABLE_OBJC_ARC = YES; 319 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 320 | CLANG_WARN_BOOL_CONVERSION = YES; 321 | CLANG_WARN_COMMA = YES; 322 | CLANG_WARN_CONSTANT_CONVERSION = YES; 323 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 324 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 325 | CLANG_WARN_EMPTY_BODY = YES; 326 | CLANG_WARN_ENUM_CONVERSION = YES; 327 | CLANG_WARN_INFINITE_RECURSION = YES; 328 | CLANG_WARN_INT_CONVERSION = YES; 329 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 330 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 331 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 332 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 333 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 334 | CLANG_WARN_STRICT_PROTOTYPES = YES; 335 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 336 | CLANG_WARN_UNREACHABLE_CODE = YES; 337 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 338 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 339 | COPY_PHASE_STRIP = NO; 340 | DEBUG_INFORMATION_FORMAT = dwarf; 341 | ENABLE_STRICT_OBJC_MSGSEND = YES; 342 | ENABLE_TESTABILITY = YES; 343 | GCC_C_LANGUAGE_STANDARD = gnu99; 344 | GCC_DYNAMIC_NO_PIC = NO; 345 | GCC_NO_COMMON_BLOCKS = YES; 346 | GCC_OPTIMIZATION_LEVEL = 0; 347 | GCC_PREPROCESSOR_DEFINITIONS = ( 348 | "DEBUG=1", 349 | "$(inherited)", 350 | ); 351 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 352 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 353 | GCC_WARN_UNDECLARED_SELECTOR = YES; 354 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 355 | GCC_WARN_UNUSED_FUNCTION = YES; 356 | GCC_WARN_UNUSED_VARIABLE = YES; 357 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 358 | MTL_ENABLE_DEBUG_INFO = YES; 359 | ONLY_ACTIVE_ARCH = YES; 360 | SDKROOT = iphoneos; 361 | TARGETED_DEVICE_FAMILY = "1,2"; 362 | }; 363 | name = Debug; 364 | }; 365 | 97C147041CF9000F007C117D /* Release */ = { 366 | isa = XCBuildConfiguration; 367 | buildSettings = { 368 | ALWAYS_SEARCH_USER_PATHS = NO; 369 | CLANG_ANALYZER_NONNULL = YES; 370 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 371 | CLANG_CXX_LIBRARY = "libc++"; 372 | CLANG_ENABLE_MODULES = YES; 373 | CLANG_ENABLE_OBJC_ARC = YES; 374 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 375 | CLANG_WARN_BOOL_CONVERSION = YES; 376 | CLANG_WARN_COMMA = YES; 377 | CLANG_WARN_CONSTANT_CONVERSION = YES; 378 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 379 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 380 | CLANG_WARN_EMPTY_BODY = YES; 381 | CLANG_WARN_ENUM_CONVERSION = YES; 382 | CLANG_WARN_INFINITE_RECURSION = YES; 383 | CLANG_WARN_INT_CONVERSION = YES; 384 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 385 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 386 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 387 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 388 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 389 | CLANG_WARN_STRICT_PROTOTYPES = YES; 390 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 391 | CLANG_WARN_UNREACHABLE_CODE = YES; 392 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 393 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 394 | COPY_PHASE_STRIP = NO; 395 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 396 | ENABLE_NS_ASSERTIONS = NO; 397 | ENABLE_STRICT_OBJC_MSGSEND = YES; 398 | GCC_C_LANGUAGE_STANDARD = gnu99; 399 | GCC_NO_COMMON_BLOCKS = YES; 400 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 401 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 402 | GCC_WARN_UNDECLARED_SELECTOR = YES; 403 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 404 | GCC_WARN_UNUSED_FUNCTION = YES; 405 | GCC_WARN_UNUSED_VARIABLE = YES; 406 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 407 | MTL_ENABLE_DEBUG_INFO = NO; 408 | SDKROOT = iphoneos; 409 | SUPPORTED_PLATFORMS = iphoneos; 410 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 411 | TARGETED_DEVICE_FAMILY = "1,2"; 412 | VALIDATE_PRODUCT = YES; 413 | }; 414 | name = Release; 415 | }; 416 | 97C147061CF9000F007C117D /* Debug */ = { 417 | isa = XCBuildConfiguration; 418 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 419 | buildSettings = { 420 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 421 | CLANG_ENABLE_MODULES = YES; 422 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 423 | ENABLE_BITCODE = NO; 424 | FRAMEWORK_SEARCH_PATHS = ( 425 | "$(inherited)", 426 | "$(PROJECT_DIR)/Flutter", 427 | ); 428 | INFOPLIST_FILE = Runner/Info.plist; 429 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 430 | LIBRARY_SEARCH_PATHS = ( 431 | "$(inherited)", 432 | "$(PROJECT_DIR)/Flutter", 433 | ); 434 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example; 435 | PRODUCT_NAME = "$(TARGET_NAME)"; 436 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 437 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 438 | SWIFT_VERSION = 5.0; 439 | VERSIONING_SYSTEM = "apple-generic"; 440 | }; 441 | name = Debug; 442 | }; 443 | 97C147071CF9000F007C117D /* Release */ = { 444 | isa = XCBuildConfiguration; 445 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 446 | buildSettings = { 447 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 448 | CLANG_ENABLE_MODULES = YES; 449 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 450 | ENABLE_BITCODE = NO; 451 | FRAMEWORK_SEARCH_PATHS = ( 452 | "$(inherited)", 453 | "$(PROJECT_DIR)/Flutter", 454 | ); 455 | INFOPLIST_FILE = Runner/Info.plist; 456 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 457 | LIBRARY_SEARCH_PATHS = ( 458 | "$(inherited)", 459 | "$(PROJECT_DIR)/Flutter", 460 | ); 461 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example; 462 | PRODUCT_NAME = "$(TARGET_NAME)"; 463 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 464 | SWIFT_VERSION = 5.0; 465 | VERSIONING_SYSTEM = "apple-generic"; 466 | }; 467 | name = Release; 468 | }; 469 | /* End XCBuildConfiguration section */ 470 | 471 | /* Begin XCConfigurationList section */ 472 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 473 | isa = XCConfigurationList; 474 | buildConfigurations = ( 475 | 97C147031CF9000F007C117D /* Debug */, 476 | 97C147041CF9000F007C117D /* Release */, 477 | 249021D3217E4FDB00AE95B9 /* Profile */, 478 | ); 479 | defaultConfigurationIsVisible = 0; 480 | defaultConfigurationName = Release; 481 | }; 482 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 483 | isa = XCConfigurationList; 484 | buildConfigurations = ( 485 | 97C147061CF9000F007C117D /* Debug */, 486 | 97C147071CF9000F007C117D /* Release */, 487 | 249021D4217E4FDB00AE95B9 /* Profile */, 488 | ); 489 | defaultConfigurationIsVisible = 0; 490 | defaultConfigurationName = Release; 491 | }; 492 | /* End XCConfigurationList section */ 493 | }; 494 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 495 | } 496 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shareven/wallet_hd/b777ace9ffef5d3f0c175c47dd7449e6c2ce065e/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | example 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:wallet_hd/wallet_hd.dart'; 2 | 3 | void main() async { 4 | String mnemonic = WalletHd.createRandomMnemonic(); 5 | Map mapAddr = await WalletHd.getAccountAddress(mnemonic); 6 | String btcAddr = mapAddr["BTC"]; 7 | String ethAddr = mapAddr["ETH"]; 8 | String toAddress = "input the to address ..."; 9 | String amount = "0.1"; 10 | String btcTxPack = 11 | await testTransactionBTC(mnemonic, btcAddr, toAddress, amount); 12 | String ethTxPack = 13 | await testTransactionETH(mnemonic, ethAddr, toAddress, amount); 14 | String erc20USDTTxPack = 15 | await testTransactionERC20USDT(mnemonic, ethAddr, toAddress, amount); 16 | print(btcTxPack); 17 | print(ethTxPack); 18 | print(erc20USDTTxPack); 19 | } 20 | 21 | Future testTransactionBTC( 22 | String mnemonic, 23 | String fromAddress, 24 | String toAddress, 25 | String amount, 26 | ) async { 27 | List unspandList = [ 28 | {"txid": "0x12312313aaaaaaaaa", "output_no": 11, "value": "0.2323"}, 29 | {"txid": "0x12312313bbbbbbbbb", "output_no": 12, "value": "0.2323"}, 30 | ]; 31 | List pendingList = [ 32 | {"txid": "0x12312313aaaaaaaaa", "value": "0.2323"} 33 | ]; 34 | double fee = 0.0002655; 35 | List handledUnspandList = unspandList; 36 | // 如果未确认交易列表不为空,则要从unspands list中去除待确认的交易 | If the list of unconfirmed transactions is not empty, remove the pending transactions from the unspands list 37 | if (pendingList.isNotEmpty) { 38 | pendingList.forEach((e) { 39 | handledUnspandList.removeWhere((x) => e["txid"] == x["txid"]); 40 | }); 41 | } 42 | List unspand = handledUnspandList 43 | .map( 44 | (e) => BitcoinIn(e["txid"], e["output_no"], double.parse(e["value"]))) 45 | .toList(); 46 | 47 | String txPack = await WalletHd.transactionBTC( 48 | mnemonic, fromAddress, toAddress, amount, fee, unspand); 49 | print("btc txPack"); 50 | print(txPack); 51 | } 52 | 53 | Future testTransactionETH( 54 | String mnemonic, 55 | String fromAddress, 56 | String toAddress, 57 | String amount, 58 | ) async { 59 | String gasPrice = "113000000000"; 60 | 61 | /// 新创建的账号初始none是-1 | the new account nonce is -1 62 | int nonce = -1; 63 | String txPack = await WalletHd.transactionETH( 64 | mnemonic, fromAddress, toAddress, amount, gasPrice, nonce); 65 | print("eth txPack"); 66 | print(txPack); 67 | } 68 | 69 | Future testTransactionERC20USDT( 70 | String mnemonic, 71 | String fromAddress, 72 | String toAddress, 73 | String amount, 74 | ) async { 75 | String gasPrice = "113000000000"; 76 | 77 | /// 新创建的账号初始none是-1 | the new account nonce is -1 78 | int nonce = -1; 79 | String txPack = await WalletHd.transactionERC20USDT( 80 | mnemonic, fromAddress, toAddress, amount, gasPrice, nonce); 81 | print("eth txPack"); 82 | print(txPack); 83 | } 84 | -------------------------------------------------------------------------------- /example/pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | asn1lib: 5 | dependency: transitive 6 | description: 7 | name: asn1lib 8 | url: "https://pub.flutter-io.cn" 9 | source: hosted 10 | version: "0.6.5" 11 | async: 12 | dependency: transitive 13 | description: 14 | name: async 15 | url: "https://pub.flutter-io.cn" 16 | source: hosted 17 | version: "2.4.2" 18 | bech32: 19 | dependency: transitive 20 | description: 21 | name: bech32 22 | url: "https://pub.flutter-io.cn" 23 | source: hosted 24 | version: "0.1.2" 25 | bip32: 26 | dependency: transitive 27 | description: 28 | name: bip32 29 | url: "https://pub.flutter-io.cn" 30 | source: hosted 31 | version: "1.0.5" 32 | bip39: 33 | dependency: transitive 34 | description: 35 | name: bip39 36 | url: "https://pub.flutter-io.cn" 37 | source: hosted 38 | version: "1.0.3" 39 | bitcoin_flutter: 40 | dependency: transitive 41 | description: 42 | name: bitcoin_flutter 43 | url: "https://pub.flutter-io.cn" 44 | source: hosted 45 | version: "2.0.1" 46 | boolean_selector: 47 | dependency: transitive 48 | description: 49 | name: boolean_selector 50 | url: "https://pub.flutter-io.cn" 51 | source: hosted 52 | version: "2.0.0" 53 | bs58check: 54 | dependency: transitive 55 | description: 56 | name: bs58check 57 | url: "https://pub.flutter-io.cn" 58 | source: hosted 59 | version: "1.0.1" 60 | characters: 61 | dependency: transitive 62 | description: 63 | name: characters 64 | url: "https://pub.flutter-io.cn" 65 | source: hosted 66 | version: "1.0.0" 67 | charcode: 68 | dependency: transitive 69 | description: 70 | name: charcode 71 | url: "https://pub.flutter-io.cn" 72 | source: hosted 73 | version: "1.1.3" 74 | clock: 75 | dependency: transitive 76 | description: 77 | name: clock 78 | url: "https://pub.flutter-io.cn" 79 | source: hosted 80 | version: "1.0.1" 81 | collection: 82 | dependency: transitive 83 | description: 84 | name: collection 85 | url: "https://pub.flutter-io.cn" 86 | source: hosted 87 | version: "1.14.13" 88 | convert: 89 | dependency: transitive 90 | description: 91 | name: convert 92 | url: "https://pub.flutter-io.cn" 93 | source: hosted 94 | version: "2.1.1" 95 | crypto: 96 | dependency: transitive 97 | description: 98 | name: crypto 99 | url: "https://pub.flutter-io.cn" 100 | source: hosted 101 | version: "2.1.5" 102 | crypton: 103 | dependency: transitive 104 | description: 105 | name: crypton 106 | url: "https://pub.flutter-io.cn" 107 | source: hosted 108 | version: "1.0.8" 109 | fake_async: 110 | dependency: transitive 111 | description: 112 | name: fake_async 113 | url: "https://pub.flutter-io.cn" 114 | source: hosted 115 | version: "1.1.0" 116 | flutter: 117 | dependency: "direct main" 118 | description: flutter 119 | source: sdk 120 | version: "0.0.0" 121 | flutter_test: 122 | dependency: "direct dev" 123 | description: flutter 124 | source: sdk 125 | version: "0.0.0" 126 | hex: 127 | dependency: transitive 128 | description: 129 | name: hex 130 | url: "https://pub.flutter-io.cn" 131 | source: hosted 132 | version: "0.1.2" 133 | http: 134 | dependency: transitive 135 | description: 136 | name: http 137 | url: "https://pub.flutter-io.cn" 138 | source: hosted 139 | version: "0.12.2" 140 | http_parser: 141 | dependency: transitive 142 | description: 143 | name: http_parser 144 | url: "https://pub.flutter-io.cn" 145 | source: hosted 146 | version: "3.1.4" 147 | isolate: 148 | dependency: transitive 149 | description: 150 | name: isolate 151 | url: "https://pub.flutter-io.cn" 152 | source: hosted 153 | version: "2.0.3" 154 | json_rpc_2: 155 | dependency: transitive 156 | description: 157 | name: json_rpc_2 158 | url: "https://pub.flutter-io.cn" 159 | source: hosted 160 | version: "2.2.1" 161 | matcher: 162 | dependency: transitive 163 | description: 164 | name: matcher 165 | url: "https://pub.flutter-io.cn" 166 | source: hosted 167 | version: "0.12.8" 168 | meta: 169 | dependency: transitive 170 | description: 171 | name: meta 172 | url: "https://pub.flutter-io.cn" 173 | source: hosted 174 | version: "1.1.8" 175 | path: 176 | dependency: transitive 177 | description: 178 | name: path 179 | url: "https://pub.flutter-io.cn" 180 | source: hosted 181 | version: "1.7.0" 182 | pedantic: 183 | dependency: transitive 184 | description: 185 | name: pedantic 186 | url: "https://pub.flutter-io.cn" 187 | source: hosted 188 | version: "1.9.0" 189 | pointycastle: 190 | dependency: transitive 191 | description: 192 | name: pointycastle 193 | url: "https://pub.flutter-io.cn" 194 | source: hosted 195 | version: "1.0.2" 196 | rlp: 197 | dependency: transitive 198 | description: 199 | name: rlp 200 | url: "https://pub.flutter-io.cn" 201 | source: hosted 202 | version: "1.0.1" 203 | sky_engine: 204 | dependency: transitive 205 | description: flutter 206 | source: sdk 207 | version: "0.0.99" 208 | source_span: 209 | dependency: transitive 210 | description: 211 | name: source_span 212 | url: "https://pub.flutter-io.cn" 213 | source: hosted 214 | version: "1.7.0" 215 | stack_trace: 216 | dependency: transitive 217 | description: 218 | name: stack_trace 219 | url: "https://pub.flutter-io.cn" 220 | source: hosted 221 | version: "1.9.5" 222 | stream_channel: 223 | dependency: transitive 224 | description: 225 | name: stream_channel 226 | url: "https://pub.flutter-io.cn" 227 | source: hosted 228 | version: "2.0.0" 229 | string_scanner: 230 | dependency: transitive 231 | description: 232 | name: string_scanner 233 | url: "https://pub.flutter-io.cn" 234 | source: hosted 235 | version: "1.0.5" 236 | term_glyph: 237 | dependency: transitive 238 | description: 239 | name: term_glyph 240 | url: "https://pub.flutter-io.cn" 241 | source: hosted 242 | version: "1.1.0" 243 | test_api: 244 | dependency: transitive 245 | description: 246 | name: test_api 247 | url: "https://pub.flutter-io.cn" 248 | source: hosted 249 | version: "0.2.17" 250 | typed_data: 251 | dependency: transitive 252 | description: 253 | name: typed_data 254 | url: "https://pub.flutter-io.cn" 255 | source: hosted 256 | version: "1.2.0" 257 | uuid: 258 | dependency: transitive 259 | description: 260 | name: uuid 261 | url: "https://pub.flutter-io.cn" 262 | source: hosted 263 | version: "2.2.0" 264 | vector_math: 265 | dependency: transitive 266 | description: 267 | name: vector_math 268 | url: "https://pub.flutter-io.cn" 269 | source: hosted 270 | version: "2.0.8" 271 | wallet_hd: 272 | dependency: "direct main" 273 | description: 274 | path: ".." 275 | relative: true 276 | source: path 277 | version: "0.0.2" 278 | web3dart: 279 | dependency: transitive 280 | description: 281 | name: web3dart 282 | url: "https://pub.flutter-io.cn" 283 | source: hosted 284 | version: "1.2.3" 285 | sdks: 286 | dart: ">=2.9.0-14.0.dev <3.0.0" 287 | flutter: ">=1.17.0 <2.0.0" 288 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: example 2 | description: A new Flutter project. 3 | 4 | # The following line prevents the package from being accidentally published to 5 | # pub.dev using `pub publish`. This is preferred for private packages. 6 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 7 | 8 | # The following defines the version and build number for your application. 9 | # A version number is three numbers separated by dots, like 1.2.43 10 | # followed by an optional build number separated by a +. 11 | # Both the version and the builder number may be overridden in flutter 12 | # build by specifying --build-name and --build-number, respectively. 13 | # In Android, build-name is used as versionName while build-number used as versionCode. 14 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 15 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. 16 | # Read more about iOS versioning at 17 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 18 | version: 1.0.0+1 19 | 20 | environment: 21 | sdk: ">=2.7.0 <3.0.0" 22 | 23 | dependencies: 24 | flutter: 25 | sdk: flutter 26 | 27 | 28 | # The following adds the Cupertino Icons font to your application. 29 | # Use with the CupertinoIcons class for iOS style icons. 30 | wallet_hd: 31 | path: ../ 32 | 33 | dev_dependencies: 34 | flutter_test: 35 | sdk: flutter 36 | 37 | # For information on the generic Dart part of this file, see the 38 | # following page: https://dart.dev/tools/pub/pubspec 39 | 40 | # The following section is specific to Flutter. 41 | flutter: 42 | 43 | # The following line ensures that the Material Icons font is 44 | # included with your application, so that you can use the icons in 45 | # the material Icons class. 46 | uses-material-design: true 47 | 48 | # To add assets to your application, add an assets section, like this: 49 | # assets: 50 | # - images/a_dot_burr.jpeg 51 | # - images/a_dot_ham.jpeg 52 | 53 | # An image asset can refer to one or more resolution-specific "variants", see 54 | # https://flutter.dev/assets-and-images/#resolution-aware. 55 | 56 | # For details regarding adding assets from package dependencies, see 57 | # https://flutter.dev/assets-and-images/#from-packages 58 | 59 | # To add custom fonts to your application, add a fonts section here, 60 | # in this "flutter" section. Each entry in this list should have a 61 | # "family" key with the font family name, and a "fonts" key with a 62 | # list giving the asset and other descriptors for the font. For 63 | # example: 64 | # fonts: 65 | # - family: Schyler 66 | # fonts: 67 | # - asset: fonts/Schyler-Regular.ttf 68 | # - asset: fonts/Schyler-Italic.ttf 69 | # style: italic 70 | # - family: Trajan Pro 71 | # fonts: 72 | # - asset: fonts/TrajanPro.ttf 73 | # - asset: fonts/TrajanPro_Bold.ttf 74 | # weight: 700 75 | # 76 | # For details regarding fonts from package dependencies, 77 | # see https://flutter.dev/custom-fonts/#from-packages 78 | -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | // import 'package:flutter/material.dart'; 9 | // import 'package:flutter_test/flutter_test.dart'; 10 | 11 | // import 'package:example/main.dart'; 12 | 13 | // void main() { 14 | 15 | // } 16 | -------------------------------------------------------------------------------- /lib/src/bitcoin_transaction.dart: -------------------------------------------------------------------------------- 1 | import 'dart:typed_data'; 2 | 3 | import 'package:bitcoin_flutter/bitcoin_flutter.dart'; 4 | import 'package:wallet_hd/src/p2sh.dart'; 5 | import 'package:wallet_hd/src/rlp.dart'; 6 | import 'package:wallet_hd/src/wallet_config.dart'; 7 | import 'package:web3dart/crypto.dart'; 8 | import 'package:bech32/bech32.dart'; 9 | import 'package:bs58check/bs58check.dart' as bs58check; 10 | 11 | class BitcoinIn { 12 | String txHash; 13 | int outputNo; 14 | num value; 15 | 16 | BitcoinIn(this.txHash, this.outputNo, this.value); 17 | } 18 | 19 | class Btransaction { 20 | TransactionBuilder txb; 21 | NetworkType network; 22 | 23 | Btransaction(this.txb, this.network); 24 | } 25 | 26 | class BitcoinTransaction { 27 | static Future signBitcoinTransaction( 28 | String privateKey, Btransaction transaction) async { 29 | if (transaction != null) { 30 | try { 31 | ECPair ecPair = 32 | ECPair.fromWIF(privateKey, network: transaction.network); 33 | transaction.txb.inputs.forEach((element) { 34 | int index = transaction.txb.inputs.indexOf(element); 35 | transaction.txb.sign(vin: index, keyPair: ecPair); 36 | }); 37 | Transaction tx = transaction.txb.buildIncomplete(); 38 | String hex = tx.toHex(); 39 | return hex; 40 | } catch (e) { 41 | print('BitcoinTransaction.signBitcoinTransaction error : $e'); 42 | } 43 | } else { 44 | print( 45 | 'BitcoinTransaction.signBitcoinTransaction error : transaction is null.'); 46 | } 47 | return null; 48 | } 49 | 50 | // 6a = 106 OP_RETURN 51 | // 14 = 20 52 | // 6f6d6e69 = omni 53 | static const _omni = '6a146f6d6e69'; 54 | static final BigInt dirt = BigInt.from(546); 55 | static String _fillLengthWith(String s, 56 | {int length = 16, String char = '0'}) { 57 | if (s == null) return ''; 58 | if (s.length >= length) return s.substring(0, length); 59 | return (char * length + s).substring(s.length); 60 | } 61 | 62 | static String _createOmniPayload(BigInt value, int contract) { 63 | String type = contract.toRadixString(16); 64 | String valueHex = value.toRadixString(16); 65 | String payload = _omni + _fillLengthWith(type) + _fillLengthWith(valueHex); 66 | return payload; 67 | } 68 | 69 | static Future createBitcoinTransaction( 70 | String from, String to, num value, num fee, 71 | {String type = 'BTC', List unspends}) async { 72 | if (WalletConfig.bitcoinType.keys.contains(type) && 73 | unspends != null && 74 | unspends.isNotEmpty) { 75 | CoinInfo coinInfo = WalletConfig.bitcoinType[type]; 76 | 77 | final txb = new TransactionBuilder(network: coinInfo.network); 78 | BigInt coinFee = numPow2BigInt(fee, coinInfo.decimals); 79 | BigInt coinValue = numPow2BigInt(value, coinInfo.decimals); 80 | 81 | BigInt amount = BigInt.zero; 82 | unspends.forEach((element) { 83 | amount += numPow2BigInt(element.value, coinInfo.decimals); 84 | txb.addInput(element.txHash, element.outputNo); 85 | }); 86 | BigInt change = amount - coinValue - coinFee; 87 | print("amount:$amount"); 88 | print("coinValue:$coinValue"); 89 | print("coinFee:$coinFee"); 90 | print("change:$change"); 91 | if (change < BigInt.zero) { 92 | print('Amount is not enough.'); 93 | } else { 94 | if (change >= dirt) { 95 | Uint8List fromAddr = addressToOutputScript(from, coinInfo.network); 96 | // 找零给自己 | Get change for yourself 97 | txb.addOutput(fromAddr, change.toInt()); 98 | } 99 | 100 | Uint8List toAddr = addressToOutputScript(to, coinInfo.network); 101 | print(toAddr); 102 | // 转给别人 | Transfer to others 103 | txb.addOutput(toAddr, coinValue.toInt()); 104 | return Btransaction(txb, coinInfo.network); 105 | } 106 | } 107 | return null; 108 | } 109 | 110 | static Future createOmniTransaction( 111 | String from, String to, num value, num fee, 112 | {String type = 'USDT', List unspends}) async { 113 | if (WalletConfig.omniType.keys.contains(type)) { 114 | CoinInfo coinInfo = WalletConfig.omniType[type]; 115 | try { 116 | final txb = new TransactionBuilder(network: coinInfo.network); 117 | const int decimals = 8; 118 | BigInt coinFee = numPow2BigInt(fee, decimals); 119 | 120 | BigInt amount = BigInt.zero; 121 | unspends.forEach((element) { 122 | amount += numPow2BigInt(element.value, decimals); 123 | txb.addInput(element.txHash, element.outputNo); 124 | }); 125 | BigInt change = amount - dirt - coinFee; 126 | if (change < BigInt.zero) { 127 | print('Amount is not enough.'); 128 | } else { 129 | if (change >= dirt) { 130 | Uint8List fromAddr = addressToOutputScript(from, coinInfo.network); 131 | // 找零给自己 | Get change for yourself 132 | txb.addOutput(fromAddr, change.toInt()); 133 | } 134 | 135 | Uint8List toAddr = addressToOutputScript(to, coinInfo.network); 136 | print("toAddr"); 137 | print(toAddr); 138 | txb.addOutput(toAddr, dirt.toInt()); 139 | 140 | BigInt bigValue = numPow2BigInt(value, coinInfo.decimals); 141 | int contract = num.parse(coinInfo.address).toInt(); 142 | String payload = _createOmniPayload(bigValue, contract); 143 | print("payload"); 144 | print(payload); 145 | 146 | txb.addOutput(hexToBytes(payload), 0); 147 | 148 | return Btransaction(txb, coinInfo.network); 149 | } 150 | } catch (e) { 151 | print('BitcoinTransaction.createOmniTransaction error : $e'); 152 | } 153 | } 154 | return null; 155 | } 156 | 157 | static Uint8List addressToOutputScript(String address, [NetworkType nw]) { 158 | NetworkType network = nw ?? bitcoin; 159 | var decodeBase58; 160 | var decodeBech32; 161 | try { 162 | decodeBase58 = bs58check.decode(address); 163 | } catch (err) {} 164 | if (decodeBase58 != null) { 165 | if (decodeBase58[0] == network.pubKeyHash) { 166 | P2PKH p2pkh = new P2PKH( 167 | data: new PaymentData(address: address), network: network); 168 | return p2pkh.data.output; 169 | } 170 | if (decodeBase58[0] == network.scriptHash) { 171 | P2SH p2sh = 172 | new P2SH(data: new PaymentData(address: address), network: network); 173 | return p2sh.data.output; 174 | } 175 | } else { 176 | try { 177 | decodeBech32 = segwit.decode(address); 178 | } catch (err) {} 179 | if (decodeBech32 != null) { 180 | if (network.bech32 != decodeBech32.hrp) 181 | throw new ArgumentError('Invalid prefix or Network mismatch'); 182 | if (decodeBech32.version != 0) 183 | throw new ArgumentError('Invalid address version'); 184 | P2WPKH p2wpkh = new P2WPKH( 185 | data: new PaymentData(address: address), network: network); 186 | return p2wpkh.data.output; 187 | } 188 | } 189 | throw new ArgumentError(address + ' has no matching Script'); 190 | } 191 | } 192 | -------------------------------------------------------------------------------- /lib/src/check_types.dart: -------------------------------------------------------------------------------- 1 | import 'dart:typed_data'; 2 | import 'dart:math'; 3 | const SATOSHI_MAX = 21 * 1e14; 4 | 5 | bool isShatoshi(int value) { 6 | return isUint(value, 53) && value <= SATOSHI_MAX; 7 | } 8 | 9 | bool isUint(int value, int bit) { 10 | return (value >= 0 && value <= pow(2, bit) - 1); 11 | } 12 | bool isHash160bit(Uint8List value) { 13 | return value.length == 20; 14 | } 15 | bool isHash256bit(Uint8List value) { 16 | return value.length == 32; 17 | } -------------------------------------------------------------------------------- /lib/src/crypto.dart: -------------------------------------------------------------------------------- 1 | import "dart:typed_data"; 2 | import "package:pointycastle/digests/sha512.dart"; 3 | import "package:pointycastle/api.dart" show KeyParameter; 4 | import "package:pointycastle/macs/hmac.dart"; 5 | import "package:pointycastle/digests/ripemd160.dart"; 6 | import "package:pointycastle/digests/sha256.dart"; 7 | 8 | Uint8List hash160(Uint8List buffer) { 9 | Uint8List _tmp = new SHA256Digest().process(buffer); 10 | return new RIPEMD160Digest().process(_tmp); 11 | } 12 | 13 | Uint8List hmacSHA512(Uint8List key, Uint8List data) { 14 | final _tmp = new HMac(new SHA512Digest(), 128)..init(new KeyParameter(key)); 15 | return _tmp.process(data); 16 | } 17 | 18 | Uint8List hash256(Uint8List buffer) { 19 | Uint8List _tmp = new SHA256Digest().process(buffer); 20 | return new SHA256Digest().process(_tmp); 21 | } 22 | -------------------------------------------------------------------------------- /lib/src/ecurve.dart: -------------------------------------------------------------------------------- 1 | import 'dart:typed_data'; 2 | import 'package:hex/hex.dart'; 3 | import "package:pointycastle/ecc/curves/secp256k1.dart"; 4 | import "package:pointycastle/api.dart" show PrivateKeyParameter, PublicKeyParameter; 5 | import 'package:pointycastle/ecc/api.dart' show ECPrivateKey, ECPublicKey, ECSignature, ECPoint; 6 | import "package:pointycastle/signers/ecdsa_signer.dart"; 7 | import 'package:pointycastle/macs/hmac.dart'; 8 | import "package:pointycastle/digests/sha256.dart"; 9 | import 'package:wallet_hd/src/handle_big_int.dart'; 10 | 11 | final zERO32 = Uint8List.fromList(List.generate(32, (index) => 0)); 12 | final ecGroupORDER = HEX.decode("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"); 13 | final ecP = HEX.decode("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"); 14 | final secp256k1 = new ECCurve_secp256k1(); 15 | final n = secp256k1.n; 16 | final G = secp256k1.G; 17 | BigInt nDiv2 = n >> 1; 18 | const THROW_BAD_PRIVATE = 'Expected Private'; 19 | const THROW_BAD_POINT = 'Expected Point'; 20 | const THROW_BAD_TWEAK = 'Expected Tweak'; 21 | const THROW_BAD_HASH = 'Expected Hash'; 22 | const THROW_BAD_SIGNATURE = 'Expected Signature'; 23 | 24 | bool isPrivate (Uint8List x) { 25 | if (!isScalar(x)) return false; 26 | return _compare(x, zERO32) > 0 && // > 0 27 | _compare(x, ecGroupORDER) < 0; // < G 28 | } 29 | bool isPoint(Uint8List p) { 30 | if (p.length < 33) { 31 | return false; 32 | } 33 | var t = p[0]; 34 | var x = p.sublist(1, 33); 35 | 36 | if (_compare(x, zERO32) == 0) { 37 | return false; 38 | } 39 | if (_compare(x, ecP) == 1) { 40 | return false; 41 | } 42 | try { 43 | decodeFrom(p); 44 | } catch(err) { 45 | return false; 46 | } 47 | if ((t == 0x02 || t == 0x03) && p.length == 33) { 48 | return true; 49 | } 50 | var y = p.sublist(33); 51 | if (_compare(y, zERO32) == 0) { 52 | return false; 53 | } 54 | if (_compare(y, ecP) == 1) { 55 | return false; 56 | } 57 | if (t == 0x04 && p.length == 65) { 58 | return true; 59 | } 60 | return false; 61 | } 62 | bool isScalar (Uint8List x) { 63 | return x.length == 32; 64 | } 65 | bool isOrderScalar (x) { 66 | if (!isScalar(x)) return false; 67 | return _compare(x, ecGroupORDER) < 0; // < G 68 | } 69 | bool isSignature (Uint8List value) { 70 | Uint8List r = value.sublist(0, 32); 71 | Uint8List s = value.sublist(32, 64); 72 | return value.length == 64 && 73 | _compare(r, ecGroupORDER) < 0 && 74 | _compare(s, ecGroupORDER) < 0; 75 | } 76 | bool _isPointCompressed (Uint8List p) { 77 | return p[0] != 0x04; 78 | } 79 | bool assumeCompression(bool value, Uint8List pubkey) { 80 | if (value == null && pubkey != null) return _isPointCompressed(pubkey); 81 | if (value == null) return true; 82 | return value; 83 | } 84 | Uint8List pointFromScalar(Uint8List d, bool _compressed) { 85 | if (!isPrivate(d)) throw new ArgumentError(THROW_BAD_PRIVATE); 86 | BigInt dd = fromBuffer(d); 87 | ECPoint pp = G * dd; 88 | if (pp.isInfinity) return null; 89 | return getEncoded(pp, _compressed); 90 | } 91 | Uint8List pointAddScalar(Uint8List p,Uint8List tweak, bool _compressed) { 92 | if (!isPoint(p)) throw new ArgumentError(THROW_BAD_POINT); 93 | if (!isOrderScalar(tweak)) throw new ArgumentError(THROW_BAD_TWEAK); 94 | bool compressed = assumeCompression(_compressed, p); 95 | ECPoint pp = decodeFrom(p); 96 | if (_compare(tweak, zERO32) == 0) return getEncoded(pp, compressed); 97 | BigInt tt = fromBuffer(tweak); 98 | ECPoint qq = G * tt; 99 | ECPoint uu = pp + qq; 100 | if (uu.isInfinity) return null; 101 | return getEncoded(uu, compressed); 102 | } 103 | Uint8List privateAdd (Uint8List d,Uint8List tweak) { 104 | if (!isPrivate(d)) throw new ArgumentError(THROW_BAD_PRIVATE); 105 | if (!isOrderScalar(tweak)) throw new ArgumentError(THROW_BAD_TWEAK); 106 | BigInt dd = fromBuffer(d); 107 | BigInt tt = fromBuffer(tweak); 108 | Uint8List dt = toBuffer((dd + tt) % n); 109 | if (!isPrivate(dt)) return null; 110 | return dt; 111 | } 112 | Uint8List sign(Uint8List hash, Uint8List x) { 113 | if (!isScalar(hash)) throw new ArgumentError(THROW_BAD_HASH); 114 | if (!isPrivate(x)) throw new ArgumentError(THROW_BAD_PRIVATE); 115 | ECSignature sig = deterministicGenerateK(hash, x); 116 | Uint8List buffer = new Uint8List(64); 117 | buffer.setRange(0, 32, encodeBigInt(sig.r)); 118 | var s; 119 | if (sig.s.compareTo(nDiv2) > 0) { 120 | s = n - sig.s; 121 | } else { 122 | s = sig.s; 123 | } 124 | buffer.setRange(32, 64, encodeBigInt(s)); 125 | return buffer; 126 | } 127 | bool verify(Uint8List hash, Uint8List q, Uint8List signature) { 128 | if (!isScalar(hash)) throw new ArgumentError(THROW_BAD_HASH); 129 | if (!isPoint(q)) throw new ArgumentError(THROW_BAD_POINT); 130 | // 1.4.1 Enforce r and s are both integers in the interval [1, n − 1] (1, isSignature enforces '< n - 1') 131 | if (!isSignature(signature)) throw new ArgumentError(THROW_BAD_SIGNATURE); 132 | 133 | ECPoint Q = decodeFrom(q); 134 | BigInt r = fromBuffer(signature.sublist(0, 32)); 135 | BigInt s = fromBuffer(signature.sublist(32, 64)); 136 | 137 | final signer = new ECDSASigner(null, new HMac(new SHA256Digest(), 64)); 138 | signer.init(false, new PublicKeyParameter(new ECPublicKey(Q, secp256k1))); 139 | return signer.verifySignature(hash, new ECSignature(r, s)); 140 | /* STEP BY STEP 141 | // 1.4.1 Enforce r and s are both integers in the interval [1, n − 1] (2, enforces '> 0') 142 | if (r.compareTo(n) >= 0) return false; 143 | if (s.compareTo(n) >= 0) return false; 144 | 145 | // 1.4.2 H = Hash(M), already done by the user 146 | // 1.4.3 e = H 147 | BigInt e = fromBuffer(hash); 148 | 149 | BigInt sInv = s.modInverse(n); 150 | BigInt u1 = (e * sInv) % n; 151 | BigInt u2 = (r * sInv) % n; 152 | 153 | // 1.4.5 Compute R = (xR, yR) 154 | // R = u1G + u2Q 155 | ECPoint R = G * u1 + Q * u2; 156 | 157 | // 1.4.5 (cont.) Enforce R is not at infinity 158 | if (R.isInfinity) return false; 159 | 160 | // 1.4.6 Convert the field element R.x to an integer 161 | BigInt xR = R.x.toBigInteger(); 162 | 163 | // 1.4.7 Set v = xR mod n 164 | BigInt v = xR % n; 165 | 166 | // 1.4.8 If v = r, output "valid", and if v != r, output "invalid" 167 | return v.compareTo(r) == 0; 168 | */ 169 | } 170 | 171 | BigInt fromBuffer(Uint8List d) { return decodeBigInt(d); } 172 | Uint8List toBuffer(BigInt d) { return encodeBigInt(d); } 173 | ECPoint decodeFrom(Uint8List P) { return secp256k1.curve.decodePoint(P); } 174 | Uint8List getEncoded(ECPoint P, compressed) { return P.getEncoded(compressed); } 175 | 176 | ECSignature deterministicGenerateK(Uint8List hash, Uint8List x) { 177 | final signer = new ECDSASigner(null, new HMac(new SHA256Digest(), 64)); 178 | var pkp = new PrivateKeyParameter(new ECPrivateKey(decodeBigInt(x), secp256k1)); 179 | signer.init(true, pkp); 180 | // signer.init(false, new PublicKeyParameter(new ECPublicKey(secp256k1.curve.decodePoint(x), secp256k1))); 181 | return signer.generateSignature(hash); 182 | } 183 | 184 | 185 | 186 | int _compare(Uint8List a, Uint8List b) { 187 | BigInt aa = fromBuffer(a); 188 | BigInt bb = fromBuffer(b); 189 | if (aa == bb) return 0; 190 | if (aa > bb) return 1; 191 | return -1; 192 | } 193 | -------------------------------------------------------------------------------- /lib/src/ethereum_transaction.dart: -------------------------------------------------------------------------------- 1 | import 'dart:typed_data'; 2 | 3 | import 'package:wallet_hd/src/rlp.dart'; 4 | import 'package:wallet_hd/src/wallet_config.dart'; 5 | import 'package:web3dart/crypto.dart'; 6 | import 'package:web3dart/web3dart.dart'; 7 | 8 | 9 | class Etransaction { 10 | Transaction tx; 11 | int chainId = 1; 12 | 13 | Etransaction(this.tx, this.chainId); 14 | } 15 | 16 | class EthereumTransaction { 17 | static Future getEthAddress(String privateKeyHex)async{ 18 | EthPrivateKey privateKey = EthPrivateKey.fromHex(privateKeyHex); 19 | EthereumAddress addr= await privateKey.extractAddress(); 20 | return addr.toString(); 21 | } 22 | static Future signEthereumTransaction( 23 | EthPrivateKey privateKey, Etransaction transaction) async { 24 | if (transaction == null) { 25 | return null; 26 | } else { 27 | privateKey.extractAddress().then((value) => print(value)); 28 | final Uint8List unsignedTx = uint8ListFromList(encode(_encodeToRlp( 29 | transaction.tx, 30 | MsgSignature(BigInt.zero, BigInt.zero, transaction.chainId)))); 31 | 32 | 33 | final signature = await privateKey.signToSignature(unsignedTx, 34 | chainId: transaction.chainId); 35 | final Uint8List signedTx = 36 | uint8ListFromList(encode(_encodeToRlp(transaction.tx, signature))); 37 | 38 | String signedTxhex = bytesToHex(signedTx); 39 | 40 | return '0x' + signedTxhex; 41 | } 42 | } 43 | 44 | static List _encodeToRlp( 45 | Transaction transaction, MsgSignature signature) { 46 | final list = [ 47 | transaction.nonce, 48 | transaction.gasPrice.getInWei, 49 | transaction.maxGas, 50 | ]; 51 | 52 | if (transaction.to != null) { 53 | list.add(transaction.to.addressBytes); 54 | } else { 55 | list.add(''); 56 | } 57 | 58 | list..add(transaction.value.getInWei)..add(transaction.data); 59 | 60 | if (signature != null) { 61 | list..add(signature.v)..add(signature.r)..add(signature.s); 62 | } 63 | return list; 64 | } 65 | 66 | static Future createErc20Transaction( 67 | String from, String to, String value, String gasPrice, int nonce, 68 | {String type = 'USDT'}) async { 69 | if (WalletConfig.erc20Type.keys.contains(type)) { 70 | CoinInfo coinInfo = WalletConfig.erc20Type[type]; 71 | 72 | String operationHex = 73 | '0xa9059cbb000000000000000000000000' + to.toLowerCase().substring(2); 74 | String valueHex = 75 | numPow2BigInt(double.parse(value), coinInfo.decimals).toRadixString(16); 76 | String tokenHex = 77 | ('0000000000000000000000000000000000000000000000000000000000000000' + 78 | valueHex) 79 | .substring(valueHex.length); 80 | String dataHex = operationHex + tokenHex; 81 | 82 | 83 | Transaction transaction = new Transaction( 84 | from: EthereumAddress.fromHex(from), 85 | to: EthereumAddress.fromHex(WalletConfig.erc20Type[type].address), 86 | maxGas: coinInfo.gasLimit, 87 | gasPrice: EtherAmount.inWei(BigInt.parse(gasPrice)), 88 | value: EtherAmount.zero(), 89 | data: hexToBytes(dataHex), 90 | nonce: nonce,); 91 | 92 | return Etransaction(transaction, coinInfo.network); 93 | } else { 94 | return null; 95 | } 96 | } 97 | 98 | static Future createEthereumTransaction( String fromAddress, 99 | String toAddress, String amount, String gasPrice, int nonce) async { 100 | 101 | Transaction transaction = Transaction( 102 | from: EthereumAddress.fromHex(fromAddress), 103 | to: EthereumAddress.fromHex(toAddress), 104 | maxGas: 21000, 105 | gasPrice: EtherAmount.inWei(BigInt.parse(gasPrice)), 106 | value: EtherAmount.inWei(numPow2BigInt(double.parse(amount), 18)), 107 | data: Uint8List(0), 108 | nonce: nonce, 109 | ); 110 | return Etransaction(transaction, 1); 111 | 112 | 113 | } 114 | } 115 | 116 | -------------------------------------------------------------------------------- /lib/src/handle_big_int.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013-present, the authors of the Pointy Castle project 2 | // This library is dually licensed under LGPL 3 and MPL 2.0. 3 | // See file LICENSE for more information. 4 | 5 | library pointycastle.src.utils; 6 | 7 | import "dart:typed_data"; 8 | 9 | /// Decode a BigInt from bytes in big-endian encoding. 10 | BigInt decodeBigInt(List bytes) { 11 | BigInt result = new BigInt.from(0); 12 | for (int i = 0; i < bytes.length; i++) { 13 | result += new BigInt.from(bytes[bytes.length - i - 1]) << (8 * i); 14 | } 15 | return result; 16 | } 17 | 18 | var _byteMask = new BigInt.from(0xff); 19 | 20 | /// Encode a BigInt into bytes using big-endian encoding. 21 | Uint8List encodeBigInt(BigInt number) { 22 | // Not handling negative numbers. Decide how you want to do that. 23 | int size = (number.bitLength + 7) >> 3; 24 | var result = new Uint8List(size); 25 | for (int i = 0; i < size; i++) { 26 | result[size - i - 1] = (number & _byteMask).toInt(); 27 | number = number >> 8; 28 | } 29 | return result; 30 | } 31 | -------------------------------------------------------------------------------- /lib/src/op.dart: -------------------------------------------------------------------------------- 1 | const OPS = { 2 | "OP_FALSE": 0, 3 | "OP_0": 0, 4 | "OP_PUSHDATA1": 76, 5 | "OP_PUSHDATA2": 77, 6 | "OP_PUSHDATA4": 78, 7 | "OP_1NEGATE": 79, 8 | "OP_RESERVED": 80, 9 | "OP_TRUE": 81, 10 | "OP_1": 81, 11 | "OP_2": 82, 12 | "OP_3": 83, 13 | "OP_4": 84, 14 | "OP_5": 85, 15 | "OP_6": 86, 16 | "OP_7": 87, 17 | "OP_8": 88, 18 | "OP_9": 89, 19 | "OP_10": 90, 20 | "OP_11": 91, 21 | "OP_12": 92, 22 | "OP_13": 93, 23 | "OP_14": 94, 24 | "OP_15": 95, 25 | "OP_16": 96, 26 | 27 | "OP_NOP": 97, 28 | "OP_VER": 98, 29 | "OP_IF": 99, 30 | "OP_NOTIF": 100, 31 | "OP_VERIF": 101, 32 | "OP_VERNOTIF": 102, 33 | "OP_ELSE": 103, 34 | "OP_ENDIF": 104, 35 | "OP_VERIFY": 105, 36 | "OP_RETURN": 106, 37 | 38 | "OP_TOALTSTACK": 107, 39 | "OP_FROMALTSTACK": 108, 40 | "OP_2DROP": 109, 41 | "OP_2DUP": 110, 42 | "OP_3DUP": 111, 43 | "OP_2OVER": 112, 44 | "OP_2ROT": 113, 45 | "OP_2SWAP": 114, 46 | "OP_IFDUP": 115, 47 | "OP_DEPTH": 116, 48 | "OP_DROP": 117, 49 | "OP_DUP": 118, 50 | "OP_NIP": 119, 51 | "OP_OVER": 120, 52 | "OP_PICK": 121, 53 | "OP_ROLL": 122, 54 | "OP_ROT": 123, 55 | "OP_SWAP": 124, 56 | "OP_TUCK": 125, 57 | 58 | "OP_CAT": 126, 59 | "OP_SUBSTR": 127, 60 | "OP_LEFT": 128, 61 | "OP_RIGHT": 129, 62 | "OP_SIZE": 130, 63 | 64 | "OP_INVERT": 131, 65 | "OP_AND": 132, 66 | "OP_OR": 133, 67 | "OP_XOR": 134, 68 | "OP_EQUAL": 135, 69 | "OP_EQUALVERIFY": 136, 70 | "OP_RESERVED1": 137, 71 | "OP_RESERVED2": 138, 72 | 73 | "OP_1ADD": 139, 74 | "OP_1SUB": 140, 75 | "OP_2MUL": 141, 76 | "OP_2DIV": 142, 77 | "OP_NEGATE": 143, 78 | "OP_ABS": 144, 79 | "OP_NOT": 145, 80 | "OP_0NOTEQUAL": 146, 81 | "OP_ADD": 147, 82 | "OP_SUB": 148, 83 | "OP_MUL": 149, 84 | "OP_DIV": 150, 85 | "OP_MOD": 151, 86 | "OP_LSHIFT": 152, 87 | "OP_RSHIFT": 153, 88 | 89 | "OP_BOOLAND": 154, 90 | "OP_BOOLOR": 155, 91 | "OP_NUMEQUAL": 156, 92 | "OP_NUMEQUALVERIFY": 157, 93 | "OP_NUMNOTEQUAL": 158, 94 | "OP_LESSTHAN": 159, 95 | "OP_GREATERTHAN": 160, 96 | "OP_LESSTHANOREQUAL": 161, 97 | "OP_GREATERTHANOREQUAL": 162, 98 | "OP_MIN": 163, 99 | "OP_MAX": 164, 100 | 101 | "OP_WITHIN": 165, 102 | 103 | "OP_RIPEMD160": 166, 104 | "OP_SHA1": 167, 105 | "OP_SHA256": 168, 106 | "OP_HASH160": 169, 107 | "OP_HASH256": 170, 108 | "OP_CODESEPARATOR": 171, 109 | "OP_CHECKSIG": 172, 110 | "OP_CHECKSIGVERIFY": 173, 111 | "OP_CHECKMULTISIG": 174, 112 | "OP_CHECKMULTISIGVERIFY": 175, 113 | 114 | "OP_NOP1": 176, 115 | 116 | "OP_NOP2": 177, 117 | "OP_CHECKLOCKTIMEVERIFY": 177, 118 | 119 | "OP_NOP3": 178, 120 | "OP_CHECKSEQUENCEVERIFY": 178, 121 | 122 | "OP_NOP4": 179, 123 | "OP_NOP5": 180, 124 | "OP_NOP6": 181, 125 | "OP_NOP7": 182, 126 | "OP_NOP8": 183, 127 | "OP_NOP9": 184, 128 | "OP_NOP10": 185, 129 | 130 | "OP_PUBKEYHASH": 253, 131 | "OP_PUBKEY": 254, 132 | "OP_INVALIDOPCODE": 255 133 | }; -------------------------------------------------------------------------------- /lib/src/p2sh.dart: -------------------------------------------------------------------------------- 1 | import 'dart:typed_data'; 2 | import 'package:bitcoin_flutter/bitcoin_flutter.dart'; 3 | import 'package:meta/meta.dart'; 4 | import 'package:bs58check/bs58check.dart' as bs58check; 5 | // import 'package:bip32/bip32.dart'; 6 | // import 'package:bip32/src/utils/ecurve.dart'; 7 | import 'package:wallet_hd/src/script.dart' as bscript; 8 | // import 'package:bitcoin_flutter/src/utils/script.dart' as bscript; 9 | // import 'package:bitcoin_flutter/src/utils/constants/op.dart'; 10 | // import 'package:bitcoin_flutter/src/crypto.dart'; 11 | 12 | // import 'package:bitcoin_flutter/bitcoin_flutter.dart'; 13 | import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin_flutter; 14 | import 'package:wallet_hd/src/crypto.dart'; 15 | import 'package:wallet_hd/src/ecurve.dart'; 16 | import 'package:wallet_hd/src/op.dart'; 17 | 18 | class P2SH { 19 | PaymentData data; 20 | bitcoin_flutter.NetworkType network; 21 | P2SH({@required data, network}) { 22 | this.network = network ?? bitcoin; 23 | this.data = data; 24 | _init(); 25 | } 26 | _init() { 27 | if (data.address != null) { 28 | _getDataFromAddress(data.address); 29 | _getDataFromHash(); 30 | } else if (data.hash != null) { 31 | _getDataFromHash(); 32 | } else if (data.output != null) { 33 | if (!isValidOutput(data.output)) 34 | throw new ArgumentError('Output is invalid'); 35 | data.hash = data.output.sublist(2, 22); 36 | _getDataFromHash(); 37 | } else if (data.pubkey != null) { 38 | data.hash = hash160(data.pubkey); 39 | _getDataFromHash(); 40 | _getDataFromChunk(); 41 | } else if (data.input != null) { 42 | List _chunks = bscript.decompile(data.input); 43 | _getDataFromChunk(_chunks); 44 | if (_chunks.length != 2) throw new ArgumentError('Input is invalid'); 45 | if (!bscript.isCanonicalScriptSignature(_chunks[0])) 46 | throw new ArgumentError('Input has invalid signature'); 47 | if (!isPoint(_chunks[1])) 48 | throw new ArgumentError('Input has invalid pubkey'); 49 | } else { 50 | throw new ArgumentError("Not enough data"); 51 | } 52 | } 53 | 54 | void _getDataFromChunk([List _chunks]) { 55 | if (data.pubkey == null && _chunks != null) { 56 | data.pubkey = (_chunks[1] is int) 57 | ? new Uint8List.fromList([_chunks[1]]) 58 | : _chunks[1]; 59 | data.hash = hash160(data.pubkey); 60 | _getDataFromHash(); 61 | } 62 | if (data.signature == null && _chunks != null) 63 | data.signature = (_chunks[0] is int) 64 | ? new Uint8List.fromList([_chunks[0]]) 65 | : _chunks[0]; 66 | if (data.input == null && data.pubkey != null && data.signature != null) { 67 | data.input = bscript.compile([data.signature, data.pubkey]); 68 | } 69 | } 70 | 71 | void _getDataFromHash() { 72 | if (data.address == null) { 73 | final payload = new Uint8List(21); 74 | payload.buffer.asByteData().setUint8(0, network.pubKeyHash); 75 | payload.setRange(1, payload.length, data.hash); 76 | data.address = bs58check.encode(payload); 77 | } 78 | if (data.output == null) { 79 | data.output = 80 | bscript.compile([OPS['OP_HASH160'], data.hash, OPS['OP_EQUAL']]); 81 | } 82 | } 83 | 84 | void _getDataFromAddress(String address) { 85 | Uint8List payload = bs58check.decode(address); 86 | final version = payload.buffer.asByteData().getUint8(0); 87 | if (version != network.scriptHash) 88 | throw new ArgumentError('Invalid version or Network mismatch'); 89 | data.hash = payload.sublist(1); 90 | if (data.hash.length != 20) throw new ArgumentError('Invalid address'); 91 | } 92 | } 93 | 94 | isValidOutput(Uint8List data) { 95 | return data.length == 23 && 96 | data[0] == OPS['OP_HASH160'] && 97 | data[1] == 0x14 && 98 | data[22] == OPS['OP_EQUAL']; 99 | } 100 | -------------------------------------------------------------------------------- /lib/src/push_data.dart: -------------------------------------------------------------------------------- 1 | import 'dart:typed_data'; 2 | import 'package:wallet_hd/src/op.dart'; 3 | 4 | class DecodedPushData { 5 | int opcode; 6 | int number; 7 | int size; 8 | DecodedPushData({this.opcode, this.number, this.size}); 9 | } 10 | class EncodedPushData { 11 | int size; 12 | Uint8List buffer; 13 | 14 | EncodedPushData({this.size, this.buffer}); 15 | 16 | } 17 | EncodedPushData encode(Uint8List buffer, number, offset) { 18 | var size = encodingLength(number); 19 | // ~6 bit 20 | if (size == 1) { 21 | buffer.buffer.asByteData().setUint8(offset, number); 22 | 23 | // 8 bit 24 | } else if (size == 2) { 25 | buffer.buffer.asByteData().setUint8(offset, OPS['OP_PUSHDATA1']); 26 | buffer.buffer.asByteData().setUint8(offset + 1, number); 27 | 28 | // 16 bit 29 | } else if (size == 3) { 30 | buffer.buffer.asByteData().setUint8(offset, OPS['OP_PUSHDATA2']); 31 | buffer.buffer.asByteData().setUint16(offset + 1, number, Endian.little); 32 | 33 | // 32 bit 34 | } else { 35 | buffer.buffer.asByteData().setUint8(offset, OPS['OP_PUSHDATA4']); 36 | buffer.buffer.asByteData().setUint32(offset + 1, number, Endian.little); 37 | } 38 | 39 | return new EncodedPushData( 40 | size: size, 41 | buffer: buffer 42 | ); 43 | } 44 | DecodedPushData decode(Uint8List bf, int offset) { 45 | ByteBuffer buffer = bf.buffer; 46 | int opcode = buffer.asByteData().getUint8(offset); 47 | int number, size; 48 | 49 | // ~6 bit 50 | if (opcode < OPS['OP_PUSHDATA1']) { 51 | number = opcode; 52 | size = 1; 53 | 54 | // 8 bit 55 | } else if (opcode == OPS['OP_PUSHDATA1']) { 56 | if (offset + 2 > buffer.lengthInBytes) return null; 57 | number = buffer.asByteData().getUint8(offset + 1); 58 | size = 2; 59 | 60 | // 16 bit 61 | } else if (opcode == OPS['OP_PUSHDATA2']) { 62 | if (offset + 3 > buffer.lengthInBytes) return null; 63 | number = buffer.asByteData().getUint16(offset + 1); 64 | size = 3; 65 | 66 | // 32 bit 67 | } else { 68 | if (offset + 5 > buffer.lengthInBytes) return null; 69 | if (opcode != OPS['OP_PUSHDATA4']) throw new ArgumentError('Unexpected opcode'); 70 | 71 | number = buffer.asByteData().getUint32(offset + 1); 72 | size = 5; 73 | } 74 | 75 | return DecodedPushData( 76 | opcode: opcode, 77 | number: number, 78 | size: size 79 | ); 80 | } 81 | int encodingLength (i) { 82 | return i < OPS['OP_PUSHDATA1'] ? 1 83 | : i <= 0xff ? 2 84 | : i <= 0xffff ? 3 85 | : 5; 86 | } 87 | -------------------------------------------------------------------------------- /lib/src/rlp.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:math'; 3 | import 'dart:typed_data'; 4 | 5 | import 'package:web3dart/crypto.dart'; 6 | import 'package:typed_data/typed_buffers.dart'; 7 | 8 | class LengthTrackingByteSink extends ByteConversionSinkBase { 9 | final Uint8Buffer _buffer = Uint8Buffer(); 10 | int _length = 0; 11 | 12 | int get length => _length; 13 | 14 | Uint8List asBytes() { 15 | return _buffer.buffer.asUint8List(0, _length); 16 | } 17 | 18 | @override 19 | void add(List chunk) { 20 | _buffer.addAll(chunk); 21 | _length += chunk.length; 22 | } 23 | 24 | void addByte(int byte) { 25 | _buffer.add(byte); 26 | _length++; 27 | } 28 | 29 | void setRange(int start, int end, List content) { 30 | _buffer.setRange(start, end, content); 31 | } 32 | 33 | @override 34 | void close() { 35 | // no-op, never used 36 | } 37 | } 38 | 39 | void _encodeString(Uint8List string, LengthTrackingByteSink builder) { 40 | // For a single byte in [0x00, 0x7f], that byte is its own RLP encoding 41 | if (string.length == 1 && string[0] <= 0x7f) { 42 | builder.addByte(string[0]); 43 | return; 44 | } 45 | 46 | // If a string is between 0 and 55 bytes long, its encoding is 0x80 plus 47 | // its length, followed by the actual string 48 | if (string.length <= 55) { 49 | builder 50 | ..addByte(0x80 + string.length) 51 | ..add(string); 52 | return; 53 | } 54 | 55 | // More than 55 bytes long, RLP is (0xb7 + length of encoded length), followed 56 | // by the length, followed by the actual string 57 | final length = string.length; 58 | final encodedLength = intToBytes(BigInt.from(length)); 59 | 60 | builder 61 | ..addByte(0xb7 + encodedLength.length) 62 | ..add(encodedLength) 63 | ..add(string); 64 | } 65 | 66 | void encodeList(List list, LengthTrackingByteSink builder) { 67 | final subBuilder = LengthTrackingByteSink(); 68 | for (var item in list) { 69 | _encodeToBuffer(item, subBuilder); 70 | } 71 | 72 | final length = subBuilder.length; 73 | if (length <= 55) { 74 | builder 75 | ..addByte(0xc0 + length) 76 | ..add(subBuilder.asBytes()); 77 | return; 78 | } else { 79 | final encodedLength = intToBytes(BigInt.from(length)); 80 | 81 | builder 82 | ..addByte(0xf7 + encodedLength.length) 83 | ..add(encodedLength) 84 | ..add(subBuilder.asBytes()); 85 | return; 86 | } 87 | } 88 | 89 | void _encodeInt(BigInt val, LengthTrackingByteSink builder) { 90 | if (val == BigInt.zero) { 91 | _encodeString(Uint8List(0), builder); 92 | } else { 93 | _encodeString(intToBytes(val), builder); 94 | } 95 | } 96 | 97 | void _encodeToBuffer(dynamic value, LengthTrackingByteSink builder) { 98 | if (value is Uint8List) { 99 | _encodeString(value, builder); 100 | } else if (value is List) { 101 | encodeList(value, builder); 102 | } else if (value is BigInt) { 103 | _encodeInt(value, builder); 104 | } else if (value is int) { 105 | _encodeInt(BigInt.from(value), builder); 106 | } else if (value is String) { 107 | _encodeString(uint8ListFromList(utf8.encode(value)), builder); 108 | } else { 109 | throw UnsupportedError('$value cannot be rlp-encoded'); 110 | } 111 | } 112 | 113 | Uint8List uint8ListFromList(List data) { 114 | if (data is Uint8List) return data; 115 | 116 | return Uint8List.fromList(data); 117 | } 118 | 119 | List encode(dynamic value) { 120 | final builder = LengthTrackingByteSink(); 121 | _encodeToBuffer(value, builder); 122 | 123 | return builder.asBytes(); 124 | } 125 | 126 | BigInt numPow2BigInt(num value, decimals) { 127 | String bigValue = (value.toDouble() * pow(10, decimals)).toString(); 128 | print(bigValue); 129 | BigInt bigIntValue = 130 | BigInt.parse(bigValue.substring(0, bigValue.indexOf('.'))); 131 | print(bigIntValue); 132 | return bigIntValue; 133 | } 134 | -------------------------------------------------------------------------------- /lib/src/rsa_proxy.dart: -------------------------------------------------------------------------------- 1 | import 'package:crypton/crypton.dart'; 2 | 3 | class RsaProxy { 4 | String get privateKey => _rsaPrivateKey.toString(); 5 | String get publicKey => _rsaPublicKey.toString(); 6 | 7 | RSAPrivateKey _rsaPrivateKey; 8 | RSAPublicKey _rsaPublicKey; 9 | 10 | RsaProxy(privateKeyString, publicKeyString) { 11 | if (privateKeyString != null) { 12 | _rsaPrivateKey = RSAPrivateKey.fromString(privateKeyString); 13 | } 14 | if (publicKeyString != null) { 15 | _rsaPublicKey = RSAPublicKey.fromString(publicKeyString); 16 | } 17 | } 18 | 19 | Future verifySignature(String message, String signedText) async { 20 | try { 21 | bool verified = _rsaPublicKey.verifySignature(message, signedText); 22 | return verified; 23 | } catch (e) { 24 | print('rsa verifySignature error : $e'); 25 | } 26 | return false; 27 | } 28 | 29 | Future sign(String message) async { 30 | try { 31 | String signature = _rsaPrivateKey.createSignature(message); 32 | return signature; 33 | } catch (e) { 34 | print('rsa sign error : $e'); 35 | } 36 | return null; 37 | } 38 | 39 | static Future create() async { 40 | RSAKeypair rsaKeypair = RSAKeypair.fromRandom(); 41 | RsaProxy rsa = RsaProxy(null, null); 42 | rsa._rsaPublicKey = rsaKeypair.publicKey; 43 | rsa._rsaPrivateKey = rsaKeypair.privateKey; 44 | return rsa; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /lib/src/script.dart: -------------------------------------------------------------------------------- 1 | import 'dart:typed_data'; 2 | import 'package:hex/hex.dart'; 3 | import 'package:wallet_hd/src/check_types.dart'; 4 | import 'package:wallet_hd/src/ecurve.dart'; 5 | import 'package:wallet_hd/src/op.dart'; 6 | 7 | import 'package:wallet_hd/src/push_data.dart' as pushData; 8 | 9 | Map reverseOPS = OPS.map((String string, int number) => new MapEntry(number, string)); 10 | final opIntBASE = OPS['OP_RESERVED']; 11 | final zero = Uint8List.fromList([0]); 12 | 13 | Uint8List compile(List chunks) { 14 | final bufferSize = chunks.fold(0, (acc, chunk) { 15 | if (chunk is int) return acc + 1; 16 | if (chunk.length == 1 && asMinimalOP(chunk) != null) { 17 | return acc + 1; 18 | } 19 | return acc + pushData.encodingLength(chunk.length) + chunk.length; 20 | }); 21 | var buffer = new Uint8List(bufferSize); 22 | 23 | var offset = 0; 24 | chunks.forEach((chunk) { 25 | // data chunk 26 | if (chunk is Uint8List) { 27 | // adhere to BIP62.3, minimal push policy 28 | final opcode = asMinimalOP(chunk); 29 | if (opcode != null) { 30 | buffer.buffer.asByteData().setUint8(offset, opcode); 31 | offset += 1; 32 | return null; 33 | } 34 | pushData.EncodedPushData epd = pushData.encode(buffer, chunk.length, offset); 35 | offset += epd.size; 36 | buffer = epd.buffer; 37 | buffer.setRange(offset, offset + chunk.length, chunk); 38 | offset += chunk.length; 39 | // opcode 40 | } else { 41 | buffer.buffer.asByteData().setUint8(offset, chunk); 42 | offset += 1; 43 | } 44 | }); 45 | 46 | if (offset != buffer.length) throw new ArgumentError("Could not decode chunks"); 47 | return buffer; 48 | } 49 | 50 | List decompile(dynamic buffer) { 51 | List chunks = []; 52 | 53 | if (buffer == null) return chunks; 54 | if (buffer is List && buffer.length == 2) return buffer; 55 | 56 | var i = 0; 57 | while (i < buffer.length) { 58 | final opcode = buffer[i]; 59 | 60 | // data chunk 61 | if ((opcode > OPS['OP_0']) && (opcode <= OPS['OP_PUSHDATA4'])) { 62 | final d = pushData.decode(buffer, i); 63 | 64 | // did reading a pushDataInt fail? 65 | if (d == null) return null; 66 | i += d.size; 67 | 68 | // attempt to read too much data? 69 | if (i + d.number > buffer.length) return null; 70 | 71 | final data = buffer.sublist(i, i + d.number); 72 | i += d.number; 73 | 74 | // decompile minimally 75 | final op = asMinimalOP(data); 76 | if (op != null) { 77 | chunks.add(op); 78 | } else { 79 | chunks.add(data); 80 | } 81 | 82 | // opcode 83 | } else { 84 | chunks.add(opcode); 85 | i += 1; 86 | } 87 | } 88 | return chunks; 89 | } 90 | 91 | Uint8List fromASM(String asm) { 92 | if (asm == '') return Uint8List.fromList([]); 93 | return compile(asm.split(' ').map((chunkStr) { 94 | if (OPS[chunkStr] != null) return OPS[chunkStr]; 95 | return HEX.decode(chunkStr); 96 | }).toList()); 97 | } 98 | 99 | String toASM (List c) { 100 | List chunks; 101 | if (c is Uint8List) { 102 | chunks = decompile(c); 103 | } else { 104 | chunks = c; 105 | } 106 | return chunks.map((chunk) { 107 | // data? 108 | if (chunk is Uint8List) { 109 | final op = asMinimalOP(chunk); 110 | if (op == null) return HEX.encode(chunk); 111 | chunk = op; 112 | } 113 | // opcode! 114 | return reverseOPS[chunk]; 115 | }).join(' '); 116 | } 117 | 118 | int asMinimalOP (Uint8List buffer) { 119 | if (buffer.length == 0) return OPS['OP_0']; 120 | if (buffer.length != 1) return null; 121 | if (buffer[0] >= 1 && buffer[0] <= 16) return opIntBASE + buffer[0]; 122 | if (buffer[0] == 0x81) return OPS['OP_1NEGATE']; 123 | return null; 124 | } 125 | bool isDefinedHashType (hashType) { 126 | final hashTypeMod = hashType & ~0x80; 127 | // return hashTypeMod > SIGHASH_ALL && hashTypeMod < SIGHASH_SINGLE 128 | return hashTypeMod > 0x00 && hashTypeMod < 0x04; 129 | } 130 | bool isCanonicalPubKey (Uint8List buffer) { 131 | return isPoint(buffer); 132 | } 133 | bool isCanonicalScriptSignature (Uint8List buffer) { 134 | if (!isDefinedHashType(buffer[buffer.length - 1])) return false; 135 | return bip66check(buffer.sublist(0, buffer.length - 1)); 136 | } 137 | bool bip66check (buffer) { 138 | if (buffer.length < 8) return false; 139 | if (buffer.length > 72) return false; 140 | if (buffer[0] != 0x30) return false; 141 | if (buffer[1] != buffer.length - 2) return false; 142 | if (buffer[2] != 0x02) return false; 143 | 144 | var lenR = buffer[3]; 145 | if (lenR == 0) return false; 146 | if (5 + lenR >= buffer.length) return false; 147 | if (buffer[4 + lenR] != 0x02) return false; 148 | 149 | var lenS = buffer[5 + lenR]; 150 | if (lenS == 0) return false; 151 | if ((6 + lenR + lenS) != buffer.length) return false; 152 | 153 | if (buffer[4] & 0x80 != 0) return false; 154 | if (lenR > 1 && (buffer[4] == 0x00) && buffer[5] & 0x80 == 0) return false; 155 | 156 | if (buffer[lenR + 6] & 0x80 != 0) return false; 157 | if (lenS > 1 && (buffer[lenR + 6] == 0x00) && buffer[lenR + 7] & 0x80 == 0) return false; 158 | return true; 159 | } 160 | 161 | Uint8List bip66encode(r, s) { 162 | var lenR = r.length; 163 | var lenS = s.length; 164 | if (lenR == 0) throw new ArgumentError('R length is zero'); 165 | if (lenS == 0) throw new ArgumentError('S length is zero'); 166 | if (lenR > 33) throw new ArgumentError('R length is too long'); 167 | if (lenS > 33) throw new ArgumentError('S length is too long'); 168 | if (r[0] & 0x80 != 0) throw new ArgumentError('R value is negative'); 169 | if (s[0] & 0x80 != 0) throw new ArgumentError('S value is negative'); 170 | if (lenR > 1 && (r[0] == 0x00) && r[1] & 0x80 == 0) throw new ArgumentError('R value excessively padded'); 171 | if (lenS > 1 && (s[0] == 0x00) && s[1] & 0x80 == 0) throw new ArgumentError('S value excessively padded'); 172 | 173 | var signature = new Uint8List(6 + lenR + lenS); 174 | 175 | // 0x30 [total-length] 0x02 [R-length] [R] 0x02 [S-length] [S] 176 | signature[0] = 0x30; 177 | signature[1] = signature.length - 2; 178 | signature[2] = 0x02; 179 | signature[3] = r.length; 180 | signature.setRange(4, 4 + lenR, r); 181 | signature[4 + lenR] = 0x02; 182 | signature[5 + lenR] = s.length; 183 | signature.setRange(6 + lenR, 6 + lenR + lenS, s); 184 | return signature; 185 | } 186 | 187 | 188 | Uint8List encodeSignature(Uint8List signature, int hashType) { 189 | if (!isUint(hashType, 8)) throw ArgumentError("Invalid hasType $hashType"); 190 | if (signature.length != 64) throw ArgumentError("Invalid signature"); 191 | final hashTypeMod = hashType & ~0x80; 192 | if (hashTypeMod <= 0 || hashTypeMod >= 4) throw new ArgumentError('Invalid hashType $hashType'); 193 | 194 | final hashTypeBuffer = new Uint8List(1); 195 | hashTypeBuffer.buffer.asByteData().setUint8(0, hashType); 196 | final r = toDER(signature.sublist(0, 32)); 197 | final s = toDER(signature.sublist(32, 64)); 198 | List combine = List.from(bip66encode(r, s)); 199 | combine.addAll(List.from(hashTypeBuffer)); 200 | return Uint8List.fromList(combine); 201 | } 202 | Uint8List toDER (Uint8List x) { 203 | var i = 0; 204 | while (x[i] == 0) ++i; 205 | if (i == x.length) return zero; 206 | x = x.sublist(i); 207 | List combine = List.from(zero); 208 | combine.addAll(x); 209 | if (x[0] & 0x80 != 0) return Uint8List.fromList(combine); 210 | return x; 211 | } 212 | -------------------------------------------------------------------------------- /lib/src/wallet_config.dart: -------------------------------------------------------------------------------- 1 | import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin_flutter; 2 | 3 | class WalletConfig { 4 | static final Map bitcoinType = { 5 | 'BTC': CoinInfo("m/44'/0'/0'/0/0", bitcoin_flutter.bitcoin, 8), 6 | }; 7 | static final Map omniType = { 8 | 'USDT': 9 | CoinInfo("m/44'/0'/0'/0/0", bitcoin_flutter.bitcoin, 8, address: '31'), 10 | 'TUSDT': 11 | CoinInfo("m/44'/0'/0'/0/1", bitcoin_flutter.testnet, 8, address: '2'), 12 | }; 13 | static final Map ethereumType = { 14 | 'ETH': CoinInfo("m/44'/60'/0'/0/0", 1, 18, gasLimit: 21000), 15 | 'ETC': CoinInfo("m/44'/61'/0'/0/0", 1, 18, gasLimit: 21000), 16 | }; 17 | static final Map erc20Type = { 18 | 'USDT': CoinInfo("m/44'/60'/0'/0/0", 1, 6, 19 | address: '0xdAC17F958D2ee523a2206206994597C13D831ec7', gasLimit: 60000), 20 | 'SIM': CoinInfo("m/44'/60'/0'/0/1", 4, 18, 21 | address: '0x454eb8D2994730a840A37e2A937e525916842Db8', gasLimit: 60000) 22 | }; 23 | } 24 | 25 | class CoinInfo { 26 | final String path; 27 | final Object network; //NetworkType or int 28 | final int decimals; 29 | final String address; 30 | final int gasLimit; 31 | 32 | CoinInfo(this.path, this.network, this.decimals, 33 | {this.address, this.gasLimit}); 34 | } 35 | -------------------------------------------------------------------------------- /lib/wallet_hd.dart: -------------------------------------------------------------------------------- 1 | library wallet_hd; 2 | 3 | import 'package:bip39/bip39.dart' as bip39; 4 | import 'package:wallet_hd/src/bitcoin_transaction.dart'; 5 | import 'package:wallet_hd/src/ethereum_transaction.dart'; 6 | import 'package:wallet_hd/src/wallet_config.dart'; 7 | import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin_flutter; 8 | import 'package:web3dart/web3dart.dart'; 9 | 10 | /// BTC转账 11 | export 'package:wallet_hd/src/bitcoin_transaction.dart'; 12 | 13 | /// ETH转账 14 | export 'package:wallet_hd/src/ethereum_transaction.dart'; 15 | export 'package:wallet_hd/src/rsa_proxy.dart'; 16 | 17 | class WalletHd { 18 | /// 创建随机助记词 | Create Random Mnemonic 19 | static String createRandomMnemonic() { 20 | String randomMnemonic = bip39.generateMnemonic(); 21 | return randomMnemonic; 22 | } 23 | 24 | /// 导入助记词,返回[btc地址 , eth地址] | Import mnemonic words and return [btc address, eth address] 25 | static Future> getAccountAddress(String mnemonic, 26 | {String derivePath}) async { 27 | String btcPath = (derivePath != null && derivePath.isNotEmpty) 28 | ? derivePath 29 | : WalletConfig.bitcoinType["BTC"].path; 30 | bitcoin_flutter.HDWallet hdWalletBtc = 31 | bitcoin_flutter.HDWallet.fromSeed(bip39.mnemonicToSeed(mnemonic)) 32 | .derivePath(btcPath); 33 | String btcAddress = hdWalletBtc.address; 34 | 35 | String ethPath = (derivePath != null && derivePath.isNotEmpty) 36 | ? derivePath 37 | : WalletConfig.ethereumType["ETH"].path; 38 | EthPrivateKey ethPrivateKey = 39 | ethMnemonicToPrivateKey(mnemonic, derivePath: ethPath); 40 | EthereumAddress ethAddr = await ethPrivateKey.extractAddress(); 41 | String ethAddress = ethAddr.toString(); 42 | 43 | return {"BTC": btcAddress, "ETH": ethAddress}; 44 | } 45 | 46 | /// ETH 导入助记词返回私钥 | ETH import mnemonic phrase and return private key 47 | static EthPrivateKey ethMnemonicToPrivateKey(String mnemonic, 48 | {String derivePath}) { 49 | String ethPath = (derivePath != null && derivePath.isNotEmpty) 50 | ? derivePath 51 | : WalletConfig.ethereumType["ETH"].path; 52 | bitcoin_flutter.HDWallet hdWalletEth = 53 | bitcoin_flutter.HDWallet.fromSeed(bip39.mnemonicToSeed(mnemonic)) 54 | .derivePath(ethPath); 55 | 56 | String privateKey = hdWalletEth.privKey; 57 | 58 | EthPrivateKey ethPrivateKey = EthPrivateKey.fromHex(privateKey); 59 | return ethPrivateKey; 60 | } 61 | 62 | /// BTC 导入助记词返回私钥wif | BTC import mnemonic phrase and return private key wif 63 | static String btcMnemonicToPrivateKey(String mnemonic, {String derivePath}) { 64 | /// BTC 普通地址 | Ordinary address 65 | String btcPath = (derivePath != null && derivePath.isNotEmpty) 66 | ? derivePath 67 | : WalletConfig.bitcoinType["BTC"].path; 68 | bitcoin_flutter.HDWallet hdWalletBtc = 69 | bitcoin_flutter.HDWallet.fromSeed(bip39.mnemonicToSeed(mnemonic)) 70 | .derivePath(btcPath); 71 | 72 | return hdWalletBtc.wif; 73 | } 74 | 75 | /// BTC转账 | BTC transfer 76 | static Future transactionBTC( 77 | String mnemonic, 78 | String fromAddress, 79 | String toAddress, 80 | String amount, 81 | num fee, 82 | List unspand, 83 | ) async { 84 | String privateKey = btcMnemonicToPrivateKey(mnemonic); 85 | 86 | Btransaction btransaction = 87 | await BitcoinTransaction.createBitcoinTransaction( 88 | fromAddress, toAddress, double.parse(amount), fee, 89 | unspends: unspand); 90 | 91 | String txPack = await BitcoinTransaction.signBitcoinTransaction( 92 | privateKey, btransaction); 93 | 94 | return txPack; 95 | } 96 | 97 | /// ETH转账 | ETH transfer 98 | static Future transactionETH( 99 | String mnemonic, 100 | String fromAddress, 101 | String toAddress, 102 | String amount, 103 | String gasPrice, 104 | int nonce, 105 | ) async { 106 | EthPrivateKey ethPrivateKey = ethMnemonicToPrivateKey(mnemonic); 107 | 108 | Etransaction transaction = 109 | await EthereumTransaction.createEthereumTransaction( 110 | fromAddress, toAddress, amount, gasPrice, nonce); 111 | 112 | String txPack = await EthereumTransaction.signEthereumTransaction( 113 | ethPrivateKey, transaction); 114 | 115 | return txPack; 116 | } 117 | 118 | /// ERC20USDT转账 | ERC20USDT transfer 119 | static Future transactionERC20USDT( 120 | String mnemonic, 121 | String fromAddress, 122 | String toAddress, 123 | String amount, 124 | String gasPrice, 125 | int nonce, 126 | ) async { 127 | EthPrivateKey ethPrivateKey = ethMnemonicToPrivateKey(mnemonic); 128 | 129 | Etransaction transaction = await EthereumTransaction.createErc20Transaction( 130 | fromAddress, toAddress, amount, gasPrice, nonce); 131 | 132 | String txPack = await EthereumTransaction.signEthereumTransaction( 133 | ethPrivateKey, transaction); 134 | 135 | return txPack; 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | asn1lib: 5 | dependency: transitive 6 | description: 7 | name: asn1lib 8 | url: "https://pub.flutter-io.cn" 9 | source: hosted 10 | version: "0.6.5" 11 | async: 12 | dependency: transitive 13 | description: 14 | name: async 15 | url: "https://pub.flutter-io.cn" 16 | source: hosted 17 | version: "2.4.2" 18 | bech32: 19 | dependency: "direct main" 20 | description: 21 | name: bech32 22 | url: "https://pub.flutter-io.cn" 23 | source: hosted 24 | version: "0.1.2" 25 | bip32: 26 | dependency: "direct main" 27 | description: 28 | name: bip32 29 | url: "https://pub.flutter-io.cn" 30 | source: hosted 31 | version: "1.0.5" 32 | bip39: 33 | dependency: "direct main" 34 | description: 35 | name: bip39 36 | url: "https://pub.flutter-io.cn" 37 | source: hosted 38 | version: "1.0.3" 39 | bitcoin_flutter: 40 | dependency: "direct main" 41 | description: 42 | name: bitcoin_flutter 43 | url: "https://pub.flutter-io.cn" 44 | source: hosted 45 | version: "2.0.1" 46 | boolean_selector: 47 | dependency: transitive 48 | description: 49 | name: boolean_selector 50 | url: "https://pub.flutter-io.cn" 51 | source: hosted 52 | version: "2.0.0" 53 | bs58check: 54 | dependency: "direct main" 55 | description: 56 | name: bs58check 57 | url: "https://pub.flutter-io.cn" 58 | source: hosted 59 | version: "1.0.1" 60 | characters: 61 | dependency: transitive 62 | description: 63 | name: characters 64 | url: "https://pub.flutter-io.cn" 65 | source: hosted 66 | version: "1.0.0" 67 | charcode: 68 | dependency: transitive 69 | description: 70 | name: charcode 71 | url: "https://pub.flutter-io.cn" 72 | source: hosted 73 | version: "1.1.3" 74 | clock: 75 | dependency: transitive 76 | description: 77 | name: clock 78 | url: "https://pub.flutter-io.cn" 79 | source: hosted 80 | version: "1.0.1" 81 | collection: 82 | dependency: transitive 83 | description: 84 | name: collection 85 | url: "https://pub.flutter-io.cn" 86 | source: hosted 87 | version: "1.14.13" 88 | convert: 89 | dependency: transitive 90 | description: 91 | name: convert 92 | url: "https://pub.flutter-io.cn" 93 | source: hosted 94 | version: "2.1.1" 95 | crypto: 96 | dependency: transitive 97 | description: 98 | name: crypto 99 | url: "https://pub.flutter-io.cn" 100 | source: hosted 101 | version: "2.1.5" 102 | crypton: 103 | dependency: "direct main" 104 | description: 105 | name: crypton 106 | url: "https://pub.flutter-io.cn" 107 | source: hosted 108 | version: "1.0.8" 109 | fake_async: 110 | dependency: transitive 111 | description: 112 | name: fake_async 113 | url: "https://pub.flutter-io.cn" 114 | source: hosted 115 | version: "1.1.0" 116 | flutter: 117 | dependency: "direct main" 118 | description: flutter 119 | source: sdk 120 | version: "0.0.0" 121 | flutter_test: 122 | dependency: "direct dev" 123 | description: flutter 124 | source: sdk 125 | version: "0.0.0" 126 | hex: 127 | dependency: "direct main" 128 | description: 129 | name: hex 130 | url: "https://pub.flutter-io.cn" 131 | source: hosted 132 | version: "0.1.2" 133 | http: 134 | dependency: transitive 135 | description: 136 | name: http 137 | url: "https://pub.flutter-io.cn" 138 | source: hosted 139 | version: "0.12.2" 140 | http_parser: 141 | dependency: transitive 142 | description: 143 | name: http_parser 144 | url: "https://pub.flutter-io.cn" 145 | source: hosted 146 | version: "3.1.4" 147 | isolate: 148 | dependency: transitive 149 | description: 150 | name: isolate 151 | url: "https://pub.flutter-io.cn" 152 | source: hosted 153 | version: "2.0.3" 154 | json_rpc_2: 155 | dependency: transitive 156 | description: 157 | name: json_rpc_2 158 | url: "https://pub.flutter-io.cn" 159 | source: hosted 160 | version: "2.2.1" 161 | matcher: 162 | dependency: transitive 163 | description: 164 | name: matcher 165 | url: "https://pub.flutter-io.cn" 166 | source: hosted 167 | version: "0.12.8" 168 | meta: 169 | dependency: "direct main" 170 | description: 171 | name: meta 172 | url: "https://pub.flutter-io.cn" 173 | source: hosted 174 | version: "1.1.8" 175 | path: 176 | dependency: transitive 177 | description: 178 | name: path 179 | url: "https://pub.flutter-io.cn" 180 | source: hosted 181 | version: "1.7.0" 182 | pedantic: 183 | dependency: transitive 184 | description: 185 | name: pedantic 186 | url: "https://pub.flutter-io.cn" 187 | source: hosted 188 | version: "1.9.0" 189 | pointycastle: 190 | dependency: "direct main" 191 | description: 192 | name: pointycastle 193 | url: "https://pub.flutter-io.cn" 194 | source: hosted 195 | version: "1.0.2" 196 | rlp: 197 | dependency: "direct main" 198 | description: 199 | name: rlp 200 | url: "https://pub.flutter-io.cn" 201 | source: hosted 202 | version: "1.0.1" 203 | sky_engine: 204 | dependency: transitive 205 | description: flutter 206 | source: sdk 207 | version: "0.0.99" 208 | source_span: 209 | dependency: transitive 210 | description: 211 | name: source_span 212 | url: "https://pub.flutter-io.cn" 213 | source: hosted 214 | version: "1.7.0" 215 | stack_trace: 216 | dependency: transitive 217 | description: 218 | name: stack_trace 219 | url: "https://pub.flutter-io.cn" 220 | source: hosted 221 | version: "1.9.5" 222 | stream_channel: 223 | dependency: transitive 224 | description: 225 | name: stream_channel 226 | url: "https://pub.flutter-io.cn" 227 | source: hosted 228 | version: "2.0.0" 229 | string_scanner: 230 | dependency: transitive 231 | description: 232 | name: string_scanner 233 | url: "https://pub.flutter-io.cn" 234 | source: hosted 235 | version: "1.0.5" 236 | term_glyph: 237 | dependency: transitive 238 | description: 239 | name: term_glyph 240 | url: "https://pub.flutter-io.cn" 241 | source: hosted 242 | version: "1.1.0" 243 | test_api: 244 | dependency: transitive 245 | description: 246 | name: test_api 247 | url: "https://pub.flutter-io.cn" 248 | source: hosted 249 | version: "0.2.17" 250 | typed_data: 251 | dependency: "direct main" 252 | description: 253 | name: typed_data 254 | url: "https://pub.flutter-io.cn" 255 | source: hosted 256 | version: "1.2.0" 257 | uuid: 258 | dependency: transitive 259 | description: 260 | name: uuid 261 | url: "https://pub.flutter-io.cn" 262 | source: hosted 263 | version: "2.2.0" 264 | vector_math: 265 | dependency: transitive 266 | description: 267 | name: vector_math 268 | url: "https://pub.flutter-io.cn" 269 | source: hosted 270 | version: "2.0.8" 271 | web3dart: 272 | dependency: "direct main" 273 | description: 274 | name: web3dart 275 | url: "https://pub.flutter-io.cn" 276 | source: hosted 277 | version: "1.2.3" 278 | sdks: 279 | dart: ">=2.9.0-14.0.dev <3.0.0" 280 | flutter: ">=1.17.0 <2.0.0" 281 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: wallet_hd 2 | description: A Flutter package project , it is use for HD wallet . Support BTC, ETH, ERC20-USDT transfer signature. 3 | version: 0.0.2 4 | homepage: https://github.com/shareven/wallet_hd 5 | 6 | environment: 7 | sdk: ">=2.7.0 <3.0.0" 8 | flutter: ">=1.17.0 <2.0.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | 14 | bip39: ^1.0.3 15 | bip32: ^1.0.5 16 | bs58check: ^1.0.1 17 | bech32: ^0.1.2 18 | meta: ^1.1.8 19 | bitcoin_flutter: ^2.0.1 20 | web3dart: ^1.2.3 21 | typed_data: ^1.2.0 22 | rlp: ^1.0.1 23 | crypton: ^1.0.8 24 | pointycastle: ^1.0.2 25 | hex: ^0.1.2 26 | 27 | dev_dependencies: 28 | flutter_test: 29 | sdk: flutter 30 | 31 | # For information on the generic Dart part of this file, see the 32 | # following page: https://dart.dev/tools/pub/pubspec 33 | 34 | # The following section is specific to Flutter. 35 | flutter: 36 | 37 | # To add assets to your package, add an assets section, like this: 38 | # assets: 39 | # - images/a_dot_burr.jpeg 40 | # - images/a_dot_ham.jpeg 41 | # 42 | # For details regarding assets in packages, see 43 | # https://flutter.dev/assets-and-images/#from-packages 44 | # 45 | # An image asset can refer to one or more resolution-specific "variants", see 46 | # https://flutter.dev/assets-and-images/#resolution-aware. 47 | 48 | # To add custom fonts to your package, add a fonts section here, 49 | # in this "flutter" section. Each entry in this list should have a 50 | # "family" key with the font family name, and a "fonts" key with a 51 | # list giving the asset and other descriptors for the font. For 52 | # example: 53 | # fonts: 54 | # - family: Schyler 55 | # fonts: 56 | # - asset: fonts/Schyler-Regular.ttf 57 | # - asset: fonts/Schyler-Italic.ttf 58 | # style: italic 59 | # - family: Trajan Pro 60 | # fonts: 61 | # - asset: fonts/TrajanPro.ttf 62 | # - asset: fonts/TrajanPro_Bold.ttf 63 | # weight: 700 64 | # 65 | # For details regarding fonts in packages, see 66 | # https://flutter.dev/custom-fonts/#from-packages 67 | -------------------------------------------------------------------------------- /test/wallet_hd_test.dart: -------------------------------------------------------------------------------- 1 | // import 'package:flutter_test/flutter_test.dart'; 2 | 3 | // import 'package:wallet_hd/wallet_hd.dart'; 4 | 5 | // // void main() { 6 | // // test('adds one to input values', () { 7 | // // final calculator = Calculator(); 8 | // // expect(calculator.addOne(2), 3); 9 | // // expect(calculator.addOne(-7), -6); 10 | // // expect(calculator.addOne(0), 1); 11 | // // expect(() => calculator.addOne(null), throwsNoSuchMethodError); 12 | // // }); 13 | // // } 14 | --------------------------------------------------------------------------------