Skip to content

Commit

Permalink
genesis
Browse files Browse the repository at this point in the history
  • Loading branch information
mocodesmo committed Jun 16, 2023
1 parent dbef23e commit 07aa7d3
Show file tree
Hide file tree
Showing 309 changed files with 29,775 additions and 2 deletions.
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# See https://www.dartlang.org/guides/libraries/private-files

# Files and directories created by pub
.dart_tool/
.packages
build/
# If you're building an application, you may want to check-in your pubspec.lock
pubspec.lock

# Directory created by dartdoc
# If you don't generate documentation locally you can remove this line.
doc/api/

# Avoid committing generated Javascript files:
*.dart.js
*.info.json # Produced by the --dump-info flag.
*.js # When generated by dart2js. Don't specify *.js if your
# project includes source files written in JavaScript.
*.js_
*.js.deps
*.js.map
.flutter-plugins
.flutter-plugins-dependencies
.DS_Store
30 changes: 30 additions & 0 deletions .metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled.

version:
revision: a14a4eac6132065fcbd853a2ff376e6911cdb2ea
channel: beta

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: a14a4eac6132065fcbd853a2ff376e6911cdb2ea
base_revision: a14a4eac6132065fcbd853a2ff376e6911cdb2ea
- platform: macos
create_revision: a14a4eac6132065fcbd853a2ff376e6911cdb2ea
base_revision: a14a4eac6132065fcbd853a2ff376e6911cdb2ea

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
40 changes: 40 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "debug",
"request": "launch",
"type": "dart",
"args": [
// "-v",
]
},
{
"name": "widgetbook",
"request": "launch",
"type": "dart",
"program": "widgetbook/app.dart",
"args": [
"-v",
]
},
{
"name": "profile",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "release",
"request": "launch",
"type": "dart",
"flutterMode": "release",
"args": [
"-v",
]
}
]
}
63 changes: 63 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"editor.tokenColorCustomizations": {
"comments": "#229977"
},
"explorer.fileNesting.patterns": {
"main.dart": "routes.dart, styles.dart, locator.dart",
"pubspec.yaml": "pubspec.lock,pubspec_overrides.yaml,.packages,.flutter-plugins,.flutter-plugins-dependencies,.metadata",
"*.dart": "${capture}.g.dart"
},
"[dart]": {
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true,
},

},

"files.exclude": {
"**/.metadata": true,
".gitignore": true,
"**/.packages": true,
"**/pubspec.lock": true,
"**/.flutter-plugins": true,
"**/.dart_tool": true,
"**/.flutter-plugins-dependencies": true,
"**/generated_plugin_registrant.dart": true,
"**/CHANGELOG.md": true,
"l10n.yaml": true,
"LICENSE": true,
"**/analysis_options.yaml": true,
"build.yaml": true,
"**/packages": true,
"README.md": true,
"**/build": true,
"assets": true,
"**/assets": true,
"**/**.g.dart": true,
"**/**.freezed.dart": true,
"android": true,
"ios": true,
"windows": true,
"web": true,
"macos": true,
"zmacos": true,
"linux": true,
"**/widgetbook": true,
// "**/pubspec.yaml": true,
"**/maintainance": true,
"**/test": true
// "integration_test": true
//
//
// "**/lib/auth": true,
// // "**/lib/create": true,
// // "**/lib/home": true,
// "**/lib/import": true,
// // "**/lib/settings": true,
// "**/lib/transaction": true,
// // "**/lib/send": true,
// "**/lib/wallet": true,
// "**/lib/wallet_settings": true,
}
}
12 changes: 12 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Enable Freezed",
"type": "shell",
"command": "flutter pub run build_runner watch --delete-conflicting-outputs",
"isBackground": true,
},
],
"inputs": [],
}
151 changes: 149 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,149 @@
# Bull Bitcoin Mobile
The Bull Bitcoin Mobile Wallet and Exchange App
## ⚡️ Quick start



> Make sure Flutter is installed
> Make sure either Android Studio or Xcode is installed
> Installation docs [here](https://docs.flutter.dev/get-started/install).
> Make sure the Flutter VSCode Extension is installed

<br>
Clean the project

```bash
flutter clean
flutter pub get
```

<br>
Run via CLI

> Select device from bottom right of VSCode.
```bash
flutter run
```

<br>
Run via VSCode debugger

> Select device from bottom right of VSCode.
> Go to 'Run and Debug' panel on the Side Bar
> Select 'debug' from the dropdown
> Click the Play Button
> Open Debug Console for logs
# About Bull Bitcoin Mobile

Bull Bitcoin Mobile has two main components: an open-source non-custodial Bitcoin wallet and a mobile interface for the Bull Bitcoin exchange and payments service offered at www.BullBitcoin.com. The app is designed to work on Android and iOS.

The Bull Bitcoin wallet can be used by anyone. Trading features and trusted features can be unlocked by logging into a Bull Bitcoin account.

The wallet is built in the dart/flutter framework using the Bitcoin Development Kit, specifically the BDK-flutter library.

Note: Bitcoin Exchange features not yet released.

www.bullbitcoin.com

## Motivation

Our mission is to facilitate and encourage the self-custody of Bitcoin by providing an integrated experience that combines a Bitcoin Wallet, Bitcoin Payments service and a Bitcoin Exchange (on-ramp, off-ramp).

Non-custodial Bitcoin exchanges and payment processors such as Bull Bitcoin have existed for over a decade. When a user purchases Bitcoin, the user must first provide a Bitcoin address to the exchange. The exchange will send the Bitcoin directly to the user’s own Bitcoin wallet as soon as the Bitcoin purchase is confirmed.

The primary issue with non-custodial exchanges is that they require users to set-up a Bitcoin Wallet using a separate mobile, desktop or web app before being able to purchase Bitcoin. This creates a sub-optimal and confusing user experience, forcing the end-user to use two separate applications, sharing data (bitcoin addresses) back-and-forth between the two.

Custodial exchanges provide a cleaner and more friendly user experience by providing a Bitcoin balance, a fiat balance, and a mechanism to move funds from a fiat balance to a Bitcoin balance within the same user interface.

Bull Bitcoin Mobile solves the problem of having a single, integrated experience within a single mobile application without requiring the user to give up self-custody.

## Integration with Bull Bitcoin exchange and payment processor [planned]

When installing the Bull Bitcoin Mobile app, a self-custodial wallet will be created, regardless of whether he is a Bull Bitcoin user or not. The user will access the Bull Bitcoin exchange from the same application. When purchasing Bitcoin, the mobile app will automatically create a Bitcoin receiving address and provide it to Bull Bitcoin’s servers as a new payout address and Bull Bitcoin will send the Bitcoin directly to the mobile wallet. There is no need to share the xpub of the wallet to Bull Bitcoin’s servers.

Users of Bull Bitcoin Mobile can also specify an external Bitcoin address, they do not need to use the Bull Bitcoin wallet.

When spending or selling Bitcoin, the exchange will create a payment invoice (BIP21) that will automatically be opened by the same application. All the user has to do is to confirm or reject that transaction. The experience will be functionally the same as that of a custodial exchange, with the exception that the user will have to do a backup of the Bitcoin wallet.

## Bitcoin wallet features

### General features

- Non-custodial: private keys are generated on the device, and never leave the device.
- Wallets are descriptor based. Users can export their wallet descriptors.
- Multiple wallets can be created. Users can switch easily from one wallet to the other on the wallet homepage.
- Amounts can be viewed as Bitcoin or Sats.
- Users can enable RBF for each transaction.
- Users can send the full wallet balance (sweep a wallet).

### Network fee estimation

- Unlike most wallets which rely on Bitcoin Core's smart fee estimation algorithm, Bull Bitcoin wallet fetches the network fee estimation from a Mempool instance.
- Network fees will be more dynamic, and much cheaper.
- Default network fee can be specified in the settings and will be used for all transactions, unless specified when creating a transaction
- There are for network fee presets:
1. Fastest: aiming for next block
2. Fast: aiming for three blocks
3. Medium: aiming for 6 blocks
4. Economical: aiming for lowest fee possible without the transaction being purged from mempools

### Hot wallet securiy

- An optional pin from 4 to 8 digits can be set for access to the app.
- The PIN is optional to prevent users from being accidentally locked out of a wallet without having first performed a backup.
- Private keys are stored in secure storage and only accessed via the applicatiom when signing transactions, viewing the wallet’s private keys for back-up (mnemonic or xpriv). This prevents malicious applications from accessing the private keys.
- BIP39 passphrase is also stored in secure storage, and can be viewed only via the application.
- When initializing the app, a single-sig hot wallet wallet is created. By default, this wallet does not have a BIP39 passphrase.
- Users can create additional wallets and add an optional BIP39 passphrase.
- A warning is displayed until the user has tested his backup by successfully entering his mnemonic.

### Hardware wallets and watch-only wallets

- Users can import watch-only wallets via QR code, copy-pasting an Xpub/Ypub/Zpub, uploading a Coldcard file or via NFC (for Coldcard).
- Users can create PSBTs from watch-only wallets for offline signing.
- Users can broadcast PSBTs signed in an offline wallet.

### Privacy and utxo management (coin selection)

- Users can create labels for receiving addresses. Transactions sent to a receiving address that has a label will inherit the label of the receiving address.
- Users can label outbound transactions. The change address of these transactions will inherit the label of the outbound transaction.
- Coin selection: users can select which utxos will be spent for each transaction. The UTXOs will have the labels of the transactions that created them. When enabling coin selection, only the selected utxos will be used to create a transaction.
- Users can optionally connect to their own electrum server.
- The default electrum server of Bull Bitcoin does not keep logs. The secondary default electrum server of Blockstream is also believed not to keep logs.
- Users can free a specific UTXO. It will be added to a list of unspendable utxos, and will never be used when making transcations unless specific overried. Unfreezing a utxo will make the utxo spendable again.
- Combination of "send full amount" and "coin selection": a user can specific a utxo and spend that utxo's entire balance. The network fee will be deducted from the amount sent. This prevents the creation of any change output when moving a utxo from one wallet to another.

### Roadmap

- Extract and display transaction details of a PSBT file before broadcasting.
- A specific UTXO can be frozen. When freezed it will be added to a list of unspendable UTXOs and will never be used for spending, unless manually selected.
- Wallet translation in French and Spanish.
- Store encrypted backup of wallets on the device.
- Encrypted cloud wallet backups for registered Bull Bitcoin users, with a scheme similar to photon-sdk.
- Display passphrase and encryption password strength estimator.
- Real-time notification of inbound payments via the mempool websocket server.
- Optional push notifications for inbound transactions and transaction confirmations.
- Integration of Payjoin Client
- Shielded transactions for registered Bull Bitcoin users [trusted swap]
- Receive Lightning Network payments with automated conversion to on-chain funds [trusted swap].
- Integration of compact blocks syncing with the Bitcoin Network, which protects users’ network privacy.
- Integration of the Lightning Network Development Kit, allowing the user to create a self-custodial Lightning Wallet.
- Integration of a Lightning Service Provider which would allow the user to seamlessly open balanced Lightning Network channels.

## Acknowledgements

- Most of the code is by Morteza.
- Credits to i5hi for contributions and advice.
- Thanks Kexkey and BitcoinZavior for their advice.
- Big thanks to Spiral, BitcoinZavior for creating BDK-flutter, Thunderbiscuit for BDK-ffi and the BDK team for making this project possible.
- Thanks to the Electrum project for creating the backend Bitcoin network interface.
- Thanks to the Mempool project for their fee estimation API and blockchain explorer interface.
- Thanks to the Bitcoin Core developers for the underlying node software.
- Thanks to Blue Wallet for the inspiration for the user interface.
55 changes: 55 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
include: package:lint/analysis_options.yaml
# package: flutter_lints/flutter.yaml

linter:
rules:
file_names: false
curly_braces_in_flow_control_structures: false
avoid_classes_with_only_static_members: false
sort_constructors_first: true
prefer_single_quotes: true
avoid_void_async: false
sized_box_for_whitespace: false
prefer_interpolation_to_compose_strings: false
avoid_print: false
# always_specify_types: true
# const_initialized_with_non_constant_value: false
# import_of_legacy_library_into_null_safe: false
avoid_positional_boolean_parameters: false
use_string_buffers: false
use_build_context_synchronously: false
depend_on_referenced_packages: false
join_return_with_assignment: false
unnecessary_string_escapes: false
avoid_dynamic_calls: false
non_constant_identifier_names: false



analyzer:
enable-experiment:
- records
exclude:
- lib/**/*.g.dart
- lib/**/*.freezed.dart
- maintainance/**
- pubspec.yaml




# include: package:flutter_lints/flutter.yaml

# linter:

# rules:
# depend_on_referenced_packages:false

# analyzer:
# exclude:
# - "**/*.g.dart"
# # strong-mode:
# # implicit-casts: false
# # implicit-dynamic: false
# errors:
# invalid_annotation_target: ignore
13 changes: 13 additions & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java

# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
**/*.keystore
**/*.jks
Loading

0 comments on commit 07aa7d3

Please sign in to comment.