Giter VIP home page Giter VIP logo

chia-crypto-utils's Introduction

Chia Crypto Utils

This repository provides an object model for working with Chia primitives serving as a basis for a Chia client.

  • Generating hardened and unhardened keys from a 24 word mnemonic seed
  • Standard transaction (XCH) coin spend
  • CAT
  • PlotNFT
  • NFT
  • Offer
  • Integration tests using the Chia simulator
  • Serialization and deserialization to and from Bytes for easy integration into secure storage
  • Atomic swap between Chia and Bitcoin

Dependencies

This repository is written in Dart to enable mobile and web usage. You may install either the Dart SDK or the Flutter SDK, which also includes Dart.

Build and Test

dart test
00:00 +0: test/wallet_service_test.dart: (suite)
  Skip: Integration test
00:08 +223 ~1: test/utils_test/utils_test.dart: should generate correct puzzle hashes from mnemonic
Fingerprint: 3109357790
Master public key (m): 901acd53bf61a63120f15442baf0f2a656267b08ba42c511b9bb543e31c32a9b49a0e0aa5e897bc81878d703fcd889f3
Farmer public key (m/12381/8444/0/0): 8351d5afd1ab40bf37565d25600c9b147dcda344e19d413b2c468316d1efd312f61a1eca02a74f8d5f0d6e79911c23ca
Pool public key (m/12381/8444/1/0): 926c9b71f4cfc3f8a595fc77d7edc509e2f426704489eaba6f86728bc391c628c402e00190ba3617931649d8c53b5520
First wallet address: txch1v8vergyvwugwv0tmxwnmeecuxh3tat5jaskkunnn79zjz0muds0qlg2szv
01:02 +896 ~1: All tests passed!

For integration tests, execute the following script:

bash ./integration_test/run_tests.sh
00:28 +6: integration_test/network/mainnet_test.dart(suite)
  Skip: Test provided for reference, not nominally run
00:28 +6 ~1: integration_test/network/testnet10_test.dart: (suite)
  Skip: Test provided for reference, not nominally run
00:47 +14 ~2: All tests passed!

To run integration tests from VS Code UI, add the following json file to chia-crypto-utils root

simulator_gen_path.json

{
    "path":"absolute_path_to_simulator_gen_folder"
}

Example

 // Initialize keychain
const mnemonic = 'abandon broom kind...';

final keychainSecret = KeychainCoreSecret.fromMnemonicString(mnemonic);

final keychain = WalletKeychain.fromCoreSecret(
  keychainSecret,
  walletSize: 50,
);

// Initialize full node
final certBytes = File('CERT_PATH').readAsBytesSync();
final keyBytes = File('KEY_PATH').readAsBytesSync();

final fullNode = ChiaFullNodeInterface.fromURL(
  'FULL_NODE_URL',
  certBytes: Bytes(certBytes),
  keyBytes: Bytes(keyBytes),
);

final wallet = ColdWallet(
  fullNode: fullNode,
  keychain: keychain,
);

await wallet.sendXch(
  Address('RECEIVER_ADDRESS').toPuzzlehash(),
  amount: 1000000000,
);

Coverage

Dependencies

Install Flutter and add the flutter tool to your path.

LCOV is used to create a coverage report in HTML format.

Generate Coverage Report

Run tests

bash ./integration_test/run_tests.sh
flutter test test --coverage --coverage-path=coverage/test.info

Merge coverage files

lcov --add-tracefile coverage/test.info --add-tracefile coverage/integration_test.info --output-file coverage/merged_coverage.info

Generate coverage report

genhtml coverage/merged_coverage.info -o coverage

View the coverage report

open coverage/index.html

chia-crypto-utils's People

Contributors

adrianscott avatar aweigold avatar darkverbito avatar kranfix avatar meeragjoshi avatar nvjoshi2 avatar rightsexyorc avatar rigidity avatar scotopic avatar tobicrackit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.