Skip to content

cypherstack/fusiondart

Repository files navigation

FusionDart

A Dart package for interacting with CashFusion servers.

WARNING

  • 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.

Features

  • Testnet support
  • Connect to CashFusion servers
  • Send and receive CashFusion messages and status updates
  • Register for CashFusion tiers
  • Send and receive CashFusion transactions

Getting started

Building

FusionDart uses coinlib for cryptocurrency calculations, which needs to be built. Build it according to their documentation (macOS instructions here).

Usage

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.

Contributing

See https://github.com/cypherstack/fusiondart/issues for a list of issues to which you may contribute. Please PR against the staging branch.

Building Dart Files from fusion.proto

This section describes how to generate Dart files based on the fusion.proto file.

Prerequisites

  • Ensure that you have the protoc command-line tool installed.
  • Navigate to the directory containing your fusion.proto file.

Steps

  1. Open your terminal and navigate to the directory where your fusion.proto file is located.

  2. 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
  3. After running the script, Dart files will be generated in the same directory as your .proto file.

  4. Manually copy any generated Dart files that you need to your lib folder.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published