A Dart package for interacting with CashFusion servers.
- Do not test this with a wallet with tokens.
Do not import/inject CashToken, SLP, and other non-standard outputs into this package. Fusiondart itself does not currently check for tokens and their use in CashFusion transactions will almost certainly lead to their loss.
- Testnet support
- Connect to CashFusion servers
- Send and receive CashFusion messages and status updates
- Register for CashFusion tiers
- Send and receive CashFusion transactions
FusionDart uses coinlib for cryptocurrency calculations, which needs to be built. Build it according to their documentation (macOS instructions here).
pubspec.lock is resolved with Flutter 3.44.8 (Dart 3.12.2), the version Stack Wallet uses. The bitbox dependency pulls in the Flutter SDK, which pins some transitive packages such as meta and vector_math, so other Flutter versions rewrite the lockfile.
dart test -x slow skips the slow tests.
See cypherstack/stack_wallet/lib/services/mixins/fusion_wallet_interface.dart for a working example. It follows this basic pattern:
import 'package:fusiondart/fusiondart.dart';
// Use server host and port which ultimately come from text fields.
fusion.FusionParams serverParams = fusion.FusionParams(
serverHost: "fusion.servo.cash",
serverPort: 8789,
serverSsl: true,
genesisHashHex: "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943",
mode: fusion.FusionMode.normal, // normal, fanout, or consolidate.
torForOver: false,
enableDebugPrint: true, // Set to false for release.
);
// Instantiate a Fusion object with custom parameters.
_mainFusionObject = fusion.Fusion(serverParams);
// Pass wallet functions to the Fusion object.
await _mainFusionObject!.initFusion(
getTransactionsByAddress: _getTransactionsByAddress,
getUnusedReservedChangeAddresses: _getUnusedReservedChangeAddresses,
getSocksProxyAddress: _getSocksProxyAddress,
getChainHeight: _getChainHeight,
updateStatusCallback: _updateStatus,
checkUtxoExists: _checkUtxoExists,
getTransactionJson: _getTransactionJson,
getPrivateKeyForPubKey: _getPrivateKeyForPubKey,
broadcastTransaction: _broadcastTransaction,
unReserveAddresses: _unReserveAddresses,
);
// Fuse UTXOs.
await _mainFusionObject!.fuse(
inputsFromWallet: coinList,
network: fusion.Utilities.testNet,
);You will need to define the injected methods _getTransactionsByAddress, _getUnusedReservedChangeAddresses, etc.
See https://github.com/cypherstack/fusiondart/issues for a list of issues to which you may contribute. Please PR against the staging branch.
This section describes how to generate Dart files based on the fusion.proto file.
- Ensure that you have the
protoccommand-line tool installed. - Navigate to the directory containing your
fusion.protofile.
-
Open your terminal and navigate to the directory where your
fusion.protofile is located. -
Run the following script (fusiondart/lib/src/protobuf/build-proto-fusion.sh) to generate the Dart files:
#!/bin/bash # This script will build the dart files based on fusion.proto. # The path to your .proto file. Adjust this if necessary. PROTO_FILE="fusion.proto" # Run the protoc command. protoc --dart_out=grpc:. $PROTO_FILE
-
After running the script, Dart files will be generated in the same directory as your
.protofile. -
Manually copy any generated Dart files that you need to your
libfolder.