Showing preview only (2,379K chars total). Download the full file or copy to clipboard to get everything.
Repository: 0xcregis/anychain
Branch: main
Commit: f7ed658d501c
Files: 177
Total size: 2.2 MB
Directory structure:
gitextract_yq5pvl5m/
├── .github/
│ └── workflows/
│ ├── lint-pr.yml
│ ├── release.yml
│ └── rust.yml
├── .gitignore
├── Cargo.toml
├── LICENSE
├── Makefile
├── README.md
├── crates/
│ ├── anychain-bitcoin/
│ │ ├── Cargo.toml
│ │ ├── README.md
│ │ └── src/
│ │ ├── address.rs
│ │ ├── amount.rs
│ │ ├── format.rs
│ │ ├── lib.rs
│ │ ├── network/
│ │ │ ├── bitcoin.rs
│ │ │ ├── bitcoin_testnet.rs
│ │ │ ├── bitcoincash.rs
│ │ │ ├── bitcoincash_testnet.rs
│ │ │ ├── dogecoin.rs
│ │ │ ├── dogecoin_testnet.rs
│ │ │ ├── litecoin.rs
│ │ │ ├── litecoin_testnet.rs
│ │ │ └── mod.rs
│ │ ├── public_key.rs
│ │ ├── transaction.rs
│ │ └── witness_program.rs
│ ├── anychain-cardano/
│ │ ├── Cargo.toml
│ │ ├── README.md
│ │ ├── examples/
│ │ │ └── transfer-ada.rs
│ │ ├── src/
│ │ │ ├── address.rs
│ │ │ ├── amount.rs
│ │ │ ├── format.rs
│ │ │ ├── lib.rs
│ │ │ ├── network.rs
│ │ │ ├── public_key.rs
│ │ │ ├── transaction.rs
│ │ │ └── util.rs
│ │ └── tests/
│ │ └── test_derive.rs
│ ├── anychain-core/
│ │ ├── Cargo.toml
│ │ ├── README.md
│ │ └── src/
│ │ ├── address.rs
│ │ ├── amount.rs
│ │ ├── error.rs
│ │ ├── format.rs
│ │ ├── lib.rs
│ │ ├── network.rs
│ │ ├── no_std/
│ │ │ ├── io.rs
│ │ │ └── mod.rs
│ │ ├── public_key.rs
│ │ ├── transaction.rs
│ │ └── utilities/
│ │ ├── crypto.rs
│ │ └── mod.rs
│ ├── anychain-ethereum/
│ │ ├── Cargo.toml
│ │ ├── README.md
│ │ └── src/
│ │ ├── address.rs
│ │ ├── format.rs
│ │ ├── lib.rs
│ │ ├── network/
│ │ │ ├── mainnet.rs
│ │ │ ├── mod.rs
│ │ │ └── testnet.rs
│ │ ├── public_key.rs
│ │ ├── transaction/
│ │ │ ├── contract.rs
│ │ │ ├── eip1559.rs
│ │ │ ├── eip3009.rs
│ │ │ ├── eip7702.rs
│ │ │ ├── legacy.rs
│ │ │ └── mod.rs
│ │ └── util.rs
│ ├── anychain-filecoin/
│ │ ├── Cargo.toml
│ │ ├── README.md
│ │ └── src/
│ │ ├── address.rs
│ │ ├── amount.rs
│ │ ├── format.rs
│ │ ├── lib.rs
│ │ ├── public_key.rs
│ │ ├── transaction.rs
│ │ └── utilities/
│ │ ├── crypto.rs
│ │ └── mod.rs
│ ├── anychain-kms/
│ │ ├── .gitignore
│ │ ├── Cargo.toml
│ │ ├── README.md
│ │ └── src/
│ │ ├── bip32/
│ │ │ ├── child_number.rs
│ │ │ ├── derivation_path.rs
│ │ │ ├── error.rs
│ │ │ ├── extended_key/
│ │ │ │ ├── attrs.rs
│ │ │ │ ├── extended_private_key.rs
│ │ │ │ ├── extended_public_key.rs
│ │ │ │ └── mod.rs
│ │ │ ├── mod.rs
│ │ │ ├── prefix.rs
│ │ │ ├── private_key.rs
│ │ │ └── public_key.rs
│ │ ├── bip39/
│ │ │ ├── crypto.rs
│ │ │ ├── error.rs
│ │ │ ├── langs/
│ │ │ │ ├── chinese_simplified.txt
│ │ │ │ ├── chinese_traditional.txt
│ │ │ │ ├── english.txt
│ │ │ │ ├── french.txt
│ │ │ │ ├── italian.txt
│ │ │ │ ├── japanese.txt
│ │ │ │ ├── korean.txt
│ │ │ │ └── spanish.txt
│ │ │ ├── language.rs
│ │ │ ├── mnemonic.rs
│ │ │ ├── mnemonic_type.rs
│ │ │ ├── mod.rs
│ │ │ ├── seed.rs
│ │ │ └── util.rs
│ │ ├── crypto.rs
│ │ ├── error.rs
│ │ └── lib.rs
│ ├── anychain-neo/
│ │ ├── Cargo.toml
│ │ └── src/
│ │ ├── address.rs
│ │ ├── format.rs
│ │ ├── lib.rs
│ │ ├── public_key.rs
│ │ └── transaction.rs
│ ├── anychain-polkadot/
│ │ ├── Cargo.toml
│ │ ├── README.md
│ │ └── src/
│ │ ├── address.rs
│ │ ├── format.rs
│ │ ├── lib.rs
│ │ ├── network/
│ │ │ ├── kusama.rs
│ │ │ ├── mod.rs
│ │ │ ├── polkadot.rs
│ │ │ ├── rococo.rs
│ │ │ └── westend.rs
│ │ ├── public_key.rs
│ │ ├── transaction.rs
│ │ └── utilities/
│ │ ├── crypto.rs
│ │ └── mod.rs
│ ├── anychain-ripple/
│ │ ├── Cargo.toml
│ │ ├── README.md
│ │ └── src/
│ │ ├── address.rs
│ │ ├── format.rs
│ │ ├── lib.rs
│ │ ├── public_key.rs
│ │ └── transaction.rs
│ └── anychain-tron/
│ ├── Cargo.toml
│ ├── README.md
│ └── src/
│ ├── abi.rs
│ ├── address.rs
│ ├── format.rs
│ ├── lib.rs
│ ├── protocol/
│ │ ├── Discover.rs
│ │ ├── Tron.rs
│ │ ├── account_contract.rs
│ │ ├── asset_issue_contract.rs
│ │ ├── balance_contract.rs
│ │ ├── common.rs
│ │ ├── exchange_contract.rs
│ │ ├── market_contract.rs
│ │ ├── mod.rs
│ │ ├── proposal_contract.rs
│ │ ├── shield_contract.rs
│ │ ├── smart_contract.rs
│ │ ├── storage_contract.rs
│ │ ├── vote_asset_contract.rs
│ │ └── witness_contract.rs
│ ├── public_key.rs
│ ├── transaction.rs
│ └── trx.rs
├── docs/
│ ├── design-cn.md
│ └── design-en.md
├── examples/
│ ├── anychain-bitcoin-cli/
│ │ ├── Cargo.toml
│ │ ├── README.md
│ │ └── src/
│ │ └── main.rs
│ ├── anychain-bitcoin-client/
│ │ ├── Cargo.toml
│ │ └── src/
│ │ └── main.rs
│ ├── anychain-ethereum-cli/
│ │ ├── Cargo.toml
│ │ ├── README.md
│ │ └── src/
│ │ └── main.rs
│ └── anychain-neo-cli/
│ ├── Cargo.toml
│ ├── README.md
│ └── src/
│ └── main.rs
├── lib.rs
└── rust-toolchain.toml
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/workflows/lint-pr.yml
================================================
name: PR
on:
pull_request_target:
types:
- opened
- edited
- synchronize
permissions:
contents: read
jobs:
main:
name: Lint
permissions:
pull-requests: read # for amannn/action-semantic-pull-request to analyze PRs
statuses: write # for amannn/action-semantic-pull-request to mark status of analyzed PR
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
================================================
FILE: .github/workflows/release.yml
================================================
name: Build Binary
on:
push:
tags:
# Regex for a version number such as 0.2.1
- "[0-9]+.[0-9]+.[0-9]+"
permissions:
contents: write
jobs:
build-and-upload:
name: Build and upload
runs-on: ${{ matrix.os }}
strategy:
matrix:
# You can add more, for any target you'd like!
include:
- build: linux
os: ubuntu-latest
target: x86_64-unknown-linux-musl
- build: macos
os: macos-latest
target: x86_64-apple-darwin
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get the release version from the tag
shell: bash
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Install Rust
# Or @nightly if you want
uses: dtolnay/rust-toolchain@stable
# Arguments to pass in
with:
# Make Rust compile to our target (defined in the matrix)
targets: ${{ matrix.target }}
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --verbose --release --target ${{ matrix.target }}
- name: Build archive
shell: bash
run: |
# Replace with the name of your binary
binary_name="anychain-bitcoin-cli"
dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}"
mkdir "$dirname"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname"
else
mv "target/${{ matrix.target }}/release/$binary_name" "$dirname"
fi
if [ "${{ matrix.os }}" = "windows-latest" ]; then
7z a "$dirname.zip" "$dirname"
echo "ASSET=$dirname.zip" >> $GITHUB_ENV
else
tar -czf "$dirname.tar.gz" "$dirname"
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
fi
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
${{ env.ASSET }}
================================================
FILE: .github/workflows/rust.yml
================================================
name: Rust CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
rust-version: [ 1.95.0 ]
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Cache Cargo dependencies
uses: actions/cache@v5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Install Protoc
uses: arduino/setup-protoc@v3
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust-version }}
- name: Check formatting
run: cargo fmt -- --check
- name: cargo clippy
run: cargo clippy --workspace --all-targets --tests -- -D warnings
- name: Build and test
run: cargo test --all-features
================================================
FILE: .gitignore
================================================
# Generated by Cargo
# will have compiled files and executables
debug/
target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
# Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
# intellij files
.idea/
.vscode/
# MaxOS files
.DS_Store
*.swp
bak/*
================================================
FILE: Cargo.toml
================================================
[workspace]
resolver = "2"
members = [
"crates/anychain-core",
"crates/anychain-bitcoin",
"crates/anychain-ethereum",
"crates/anychain-tron",
"crates/anychain-filecoin",
"crates/anychain-polkadot",
"crates/anychain-ripple",
#"crates/anychain-neo",
"crates/anychain-cardano",
"crates/anychain-kms",
"examples/*",
]
[workspace.package]
authors = ["Shawndslee", "cregis.com"]
edition = "2021"
homepage = "https://www.cregis.com"
license = "MIT/Apache-2.0"
repository = "https://github.com/0xcregis/anychain"
[workspace.dependencies]
sha3 = "0.10.1"
thiserror = "1.0"
ripemd = "0.1.1"
blake2b_simd = "1.0.0"
bech32 = "0.9.0"
hex = "0.4.2"
libsecp256k1 = "0.7.1"
ed25519-dalek = { version = "2", features = ["hazmat"] }
#ed25519-dalek = "1.0.1"
curve25519-dalek = { version = "4.1.3", features = ["group"] }
base58 = { version = "0.2" }
rand = { version = "0.8.6" }
rand_core = { version = "0.6.3", default-features = false }
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
sha2 = { version = "0.10.8", default-features = false }
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] }
lazy_static = "1.4.0"
num-bigint = "0.4.3"
anyhow = "1.0.75"
base64 = "0.21.5"
# bytes = "1.0"
protobuf = { version = "=3.7.2" }
chrono = "0.4"
clap = { version = "4.4.7", features = ["derive"] }
rustc-hash = "1.1.0"
hmac = "0.12.1"
pbkdf2 = { version = "0.12.1", default-features = false }
unicode-normalization = "0.1.22"
zeroize = { version = "1.8.1", default-features = false }
once_cell = { version = "1.18.0" }
subtle = { version = "2", default-features = false }
p256 = "0.13.2"
bs58 = { version = "0.4", default-features = false, features = ["check", "alloc"] }
# Ethereum
ethereum-types = "0.13.1"
rlp = { version = "0.5.2", features = ["derive"] }
ethabi = "17.2.0"
regex = { version = "1.3" }
primitive-types = { version = "0.11.1", features = ["rlp"] }
# Cardano
cml-chain = "6.2.0"
cml-crypto = "6.2.0"
cml-core = "6.2.0"
# Filecoin
arbitrary = { version = "1.4.1", features = ["derive"] }
bls-signatures = { version = "0.15.0" }
cid = { version = "0.11.2" }
data-encoding = "2.8.0"
data-encoding-macro = "0.1.17"
fvm_shared = { version = "~4.8.2" }
fvm_ipld_encoding = "0.5.4"
forest_encoding = "0.2.2"
num-derive = "0.4.2"
num-traits = { version = "0.2.19" }
unsigned-varint = "0.8.0"
[profile.release]
strip = true # Automatically strip symbols from the binary
opt-level = "s" # Optimize for size
lto = true # Enable link time optimization
codegen-units = 1 # Maximize size reduction optimizations
[workspace.lints.clippy]
uninlined_format_args = "allow"
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) [2013] [taiyi-research-institute]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: Makefile
================================================
.PHONY: all check clean
all: build
check: fmt test clippy
test:
(command -v cargo-nextest && cargo nextest run --all-features --workspace) || cargo test --all-features --workspace
fmt:
cargo fmt --all -- --check
clippy:
cargo clippy --workspace --all-targets --tests -- -D warnings
clean:
cargo clean
build:
cargo build --release
build-linux-server:
rustup target add x86_64-unknown-linux-musl
cargo build --release --target x86_64-unknown-linux-musl
rustup target add aarch64-unknown-linux-musl
cargo build --release --target aarch64-unknown-linux-musl
build-ios:
rustup target add aarch64-apple-ios
cargo build --release --target aarch64-apple-ios
================================================
FILE: README.md
================================================
## Anychain
[](https://github.com/uduncloud/anychain/actions/workflows/rust.yml)
### What is Anychain?
Anychain is a multi-chain supported blockchain development framework designed to simplify interactions with various blockchains such as Ethereum, Bitcoin, Tron, and more. It provides a suite of tools and libraries that enable developers to easily create, manage, and operate blockchain addresses, transactions, and smart contracts.
### What Can Anychain Do?
- **Multi-Chain Support**: Interact with multiple blockchain platforms, allowing developers to use different blockchains within the same project.
- **Address Management**: Easily create and verify blockchain addresses.
- **Transaction Generation**: Generate and sign transactions, supporting various cryptocurrencies.
- **Smart Contract Interaction**: Interact with smart contracts, call contract methods, and handle return values.
- **Bandwidth Estimation**: Estimate the bandwidth required for transactions, helping developers optimize transaction costs.
### Who Needs Anychain?
- **Blockchain Developers**: Developers looking to quickly build applications that interact with multiple blockchains.
- **Fintech Companies**: Companies that need to integrate various cryptocurrency payment and transaction functionalities.
- **Blockchain Researchers**: Academics and researchers who want to experiment and study different blockchains.
- **Startups**: Startups aiming to leverage blockchain technology to build innovative products.
### Why Choose Anychain?
- **Ease of Use**: Anychain offers a simple and intuitive API, allowing developers to get started quickly and reducing the learning curve.
- **Flexibility**: Supports multiple blockchains, enabling developers to choose the most suitable chain based on their needs.
- **Active Community**: Anychain has an active developer community that provides support and shares best practices.
- **High Performance**: An optimized codebase ensures efficient transaction processing and low latency.
### Features
#### Common Traits when it comes to building transactions for different blockchains, they are
* PublicKey
* Address
* Amount
* Transaction
* Network
* Format
#### Common crates used in building transactions for different blockchains, they are
* base58
* secp256k1
* hex
* rand
### Functions
* Build raw unsigned transactions for different blockchains according to parameters taken from the user of this library
* Build signed transactions for different blockchains by merging the raw transaction and the corresponding signature
taken from the user of this library
### Architecture & Design Doc
```mermaid
flowchart LR
A[iOS/Android App] --> |Link library| B[anychain-ffi-rust];
B --> |Wrap| C[anychain-bitcoin C library];
C --> |Implement| D[anychain-core];
```
[Design Principles for AnyChain Wallet SDK](docs/design-en.md)
### Build the source
cargo build --release
## Crates
| Name | Description | Crates.io | Documentation |
|-----------------------|------------------------|--------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------|
| [`anychain-core`] | Core types and traits. | [][anychain-core] | [][anychain-core-docs] |
| [`anychain-kms`] | BIP32、BIP39. | [][anychain-kms] | [][anychain-kms-docs] |
| [`anychain-bitcoin`] | Bitcoin impl. | [][anychain-bitcoin] | [][anychain-bitcoin-docs] |
| [`anychain-ethereum`] | Ethereum impl. | [][anychain-ethereum] | [][anychain-ethereum-docs] |
| [`anychain-filecoin`] | Filecoin impl. | [][anychain-filecoin] | [][anychain-filecoin-docs] |
| [`anychain-tron`] | Tron impl. | [][anychain-tron] | [][anychain-tron-docs] |
| [`anychain-ripple`] | Ripple impl. | [][anychain-ripple] | [][anychain-ripple-docs] |
| [`anychain-polkadot`] | Polkadot impl. | [][anychain-polkadot] | [][anychain-polkadot-docs] |
| [`anychain-solana`] | Solana impl. | [][anychain-solana] | [][anychain-solana-docs] |
| [`anychain-ton`] | Ton impl. | [][anychain-ton] | [][anychain-solana-docs] |
## Supported Chains
- Bitcoin
- BitcoinCash
- Dogecoin
- Litecoin
- Ethereum
- Filecoin
- Tron
- Ripple
- Arbitrum, Optimism, and Avalanche
- Polkadot
- Neo
- Solana
- Sui
- Aptos
- Sei
- Ton
## License
This project is licensed under the [MIT license][license].
## Contact
Feel free to join anychain sdk [Telegram](https://t.me/anychain_sdk) for discussions on code and research.
[`anychain-core`]: https://github.com/0xcregis/anychain/tree/main/anychain-core
[`anychain-kms`]: https://github.com/0xcregis/anychain/tree/main/anychain-kms
[`anychain-bitcoin`]: https://github.com/0xcregis/anychain/tree/main/anychain-bitcoin
[`anychain-ethereum`]: https://github.com/0xcregis/anychain/tree/main/anychain-ethereum
[`anychain-filecoin`]: https://github.com/0xcregis/anychain/tree/main/anychain-filecoin
[`anychain-tron`]: https://github.com/0xcregis/anychain/tree/main/anychain-tron
[`anychain-ripple`]: https://github.com/0xcregis/anychain/tree/main/anychain-ripple
[`anychain-polkadot`]: https://github.com/0xcregis/anychain/tree/main/anychain-polkadot
[`anychain-solana`]: https://github.com/0xcregis/anychain-solana
[`anychain-ton`]: https://github.com/0xcregis/anychain-ton
[anychain-core]: https://crates.io/crates/anychain-core
[anychain-kms]: https://crates.io/crates/anychain-kms
[anychain-bitcoin]: https://crates.io/crates/anychain-bitcoin
[anychain-ethereum]: https://crates.io/crates/anychain-ethereum
[anychain-filecoin]: https://crates.io/crates/anychain-filecoin
[anychain-tron]: https://crates.io/crates/anychain-tron
[anychain-ripple]: https://crates.io/crates/anychain-ripple
[anychain-polkadot]: https://crates.io/crates/anychain-polkadot
[anychain-solana]: https://crates.io/crates/anychain-solana
[anychain-ton]: https://crates.io/crates/anychain-ton
[anychain-core-docs]: https://docs.rs/anychain-core
[anychain-kms-docs]: https://docs.rs/anychain-kms
[anychain-bitcoin-docs]: https://docs.rs/anychain-bitcoin
[anychain-ethereum-docs]: https://docs.rs/anychain-ethereum
[anychain-filecoin-docs]: https://docs.rs/anychain-filecoin
[anychain-tron-docs]: https://docs.rs/anychain-tron
[anychain-ripple-docs]: https://docs.rs/anychain-ripple
[anychain-polkadot-docs]: https://docs.rs/anychain-polkadot
[anychain-solana-docs]: https://docs.rs/anychain-solana
[anychain-ton-docs]: https://docs.rs/anychain-ton
[license]: https://github.com/0xcregis/anychain/blob/main/LICENSE
================================================
FILE: crates/anychain-bitcoin/Cargo.toml
================================================
[package]
name = "anychain-bitcoin"
description = "A Rust library for Bitcoin-focused cryptocurrency wallets, enabling seamless transactions on the Bitcoin blockchain"
version = "0.1.15"
keywords = ["bitcoin", "blockchain", "wallet", "transactions"]
categories = ["cryptography::cryptocurrencies"]
# Workspace inherited keys
authors = { workspace = true }
edition = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
[dependencies]
anychain-core = { path = "../anychain-core", version = "0.1.8" }
base58 = { workspace = true }
bech32 = { workspace = true }
serde = { workspace = true }
sha2 = { workspace = true }
hex = { workspace = true }
thiserror = { workspace = true }
libsecp256k1 = { workspace = true }
rand = { workspace = true }
[features]
default = ["std"]
std = ["anychain-core/std"]
[lints]
workspace = true
================================================
FILE: crates/anychain-bitcoin/README.md
================================================
# anychain-bitcoin
anychain-bitcoin is a Rust crate that provides a simple and efficient way to interact with the Bitcoin blockchain. This library aims to make it easy for developers to build applications that require Bitcoin data and functionality without having to deal with the complexities of the underlying protocol.
## Features
- Easy-to-use API for querying and interacting with the Bitcoin blockchain
- Support for mainnet, testnet, and regtest networks
- Efficient and optimized for performance
- Comprehensive documentation and examples
## Installation
To use anychain-bitcoin in your Rust project, add the following to your Cargo.toml file:
```toml
[dependencies]
anychain-bitcoin = "0.1.8"
```
Then, import the crate in your code:
```rust
extern crate anychain_bitcoin;
```
## Usage
Here's a simple example of how to use anychain-bitcoin to get the balance of a Bitcoin address:
Addr
```rust
use anychain_bitcoin::{Bitcoin, Address};
fn main() {
let bitcoin = Bitcoin::new();
let address = Address::from_str("1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa").unwrap();
let balance = bitcoin.get_balance(&address).unwrap();
println!("Balance: {} satoshis", balance);
}
```
For more examples and detailed usage instructions, please refer to the [documentation](https://docs.rs/anychain-bitcoin).
## Contributing
We welcome contributions from the community! If you'd like to contribute to anychain-bitcoin, please follow these steps:
1. Fork the repository
2. Create a new branch for your changes
3. Make your changes and commit them to your branch
4. Submit a pull request to the main repository
Please make sure to write tests for your changes and follow the Rust coding style.
## License
anychain-bitcoin is licensed under the MIT License. See [LICENSE](LICENSE) for more information
================================================
FILE: crates/anychain-bitcoin/src/address.rs
================================================
use crate::{BitcoinFormat, BitcoinNetwork, BitcoinPublicKey, Opcode, Prefix, WitnessProgram};
use anychain_core::{
crypto::{checksum, hash160},
Address, AddressError,
};
use anychain_core::{no_std::*, PublicKey};
use base58::{FromBase58, ToBase58};
use bech32::{self, u5, FromBase32, ToBase32, Variant};
use core::hash::Hash;
use core::{fmt, marker::PhantomData, str::FromStr};
use sha2::{Digest, Sha256};
/// Represents a Bitcoin address
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct BitcoinAddress<N: BitcoinNetwork> {
/// The Bitcoin address
address: String,
/// The format of the address
format: BitcoinFormat,
/// PhantomData
_network: PhantomData<N>,
}
pub static BASE32_ENCODE_TABLE: [u8; 32] = [
b'q', b'p', b'z', b'r', b'y', b'9', b'x', b'8', b'g', b'f', b'2', b't', b'v', b'd', b'w', b'0',
b's', b'3', b'j', b'n', b'5', b'4', b'k', b'h', b'c', b'e', b'6', b'm', b'u', b'a', b'7', b'l',
];
pub static BASE32_DECODE_TABLE: [i8; 128] = [
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
15, -1, 10, 17, 21, 20, 26, 30, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 29, -1, 24, 13, 25, 9, 8, 23, -1, 18, 22, 31, 27, 19, -1, 1, 0, 3, 16, 11, 28, 12, 14, 6,
4, 2, -1, -1, -1, -1, -1,
];
fn checksum_bch(feed: Vec<u8>) -> [u8; 5] {
let mut c = 1u64;
for d in feed.iter() {
let c0 = (c >> 35) as u8;
c = ((c & 0x07ffffffff) << 5) ^ (*d as u64);
if c0 & 0x01 != 0 {
c ^= 0x98f2bc8e61;
}
if c0 & 0x02 != 0 {
c ^= 0x79b76d99e2;
}
if c0 & 0x04 != 0 {
c ^= 0xf33e5fb3c4;
}
if c0 & 0x08 != 0 {
c ^= 0xae2eabe2a8;
}
if c0 & 0x10 != 0 {
c ^= 0x1e4f43e470;
}
}
c ^= 1;
let mut ret = [0u8; 5];
for (i, byte) in ret.iter_mut().enumerate() {
*byte = (c >> (8 * i)) as u8;
}
ret
}
fn compute_checksum_bch(payload: &str, prefix: &str) -> Result<String, AddressError> {
let mut payload = payload.as_bytes().to_vec();
for byte in payload.clone() {
match BASE32_DECODE_TABLE.get(byte as usize) {
Some(val) if *val != -1 => {}
_ => {
return Err(AddressError::Message(format!(
"Invalid base32 character '{}' for Bitcoin cash",
byte as char
)))
}
}
}
payload
.iter_mut()
.for_each(|byte| *byte = BASE32_DECODE_TABLE[*byte as usize] as u8);
let prefix = prefix.as_bytes().to_vec();
let prefix: Vec<u8> = prefix.iter().map(|byte| byte & 0x1f).collect();
let template = vec![0u8; 8];
let mut feed = prefix;
feed.push(0);
feed.extend(&payload);
feed.extend(&template);
let mut chechsum = checksum_bch(feed).to_vec();
chechsum.reverse();
let chechsum: Vec<u8> = chechsum
.to_base32()
.iter()
.map(|byte| BASE32_ENCODE_TABLE[byte.to_u8() as usize])
.collect();
Ok(String::from_utf8(chechsum)?)
}
impl<N: BitcoinNetwork> Address for BitcoinAddress<N> {
type SecretKey = libsecp256k1::SecretKey;
type Format = BitcoinFormat;
type PublicKey = BitcoinPublicKey<N>;
/// Returns the address corresponding to the given Bitcoin private key.
fn from_secret_key(
secret_key: &Self::SecretKey,
format: &Self::Format,
) -> Result<Self, AddressError> {
Self::PublicKey::from_secret_key(secret_key).to_address(format)
}
/// Returns the address corresponding to the given Bitcoin public key.
fn from_public_key(
public_key: &Self::PublicKey,
format: &Self::Format,
) -> Result<Self, AddressError> {
match format {
BitcoinFormat::P2PKH => Self::p2pkh(public_key),
BitcoinFormat::P2WSH => Err(AddressError::IncompatibleFormats(
String::from("non-script"),
String::from("p2wsh address"),
)),
BitcoinFormat::P2SH_P2WPKH => Self::p2sh_p2wpkh(public_key),
BitcoinFormat::Bech32 => Self::bech32(public_key),
BitcoinFormat::CashAddr => Self::cash_addr(public_key),
}
}
}
impl<N: BitcoinNetwork> BitcoinAddress<N> {
/// Generate a P2PKH address from a hash160.
pub fn p2pkh_from_hash(hash: &[u8]) -> Result<Self, AddressError> {
if hash.len() != 20 {
return Err(AddressError::Message("Illegal hash160 length".to_string()));
}
let mut data = [0u8; 25];
data[0] = N::to_address_prefix(BitcoinFormat::P2PKH)?.version();
data[1..21].copy_from_slice(hash);
let checksum = &checksum(&data[..21])[..4];
data[21..].copy_from_slice(checksum);
Ok(Self {
address: data.to_base58(),
format: BitcoinFormat::P2PKH,
_network: PhantomData,
})
}
/// Generate a P2SH_P2WPKH address from a hash160
pub fn p2sh_p2wpkh_from_hash(hash: &[u8]) -> Result<Self, AddressError> {
if hash.len() != 20 {
return Err(AddressError::Message("Illegal hash160 length".to_string()));
}
let mut data = [0u8; 25];
data[0] = N::to_address_prefix(BitcoinFormat::P2SH_P2WPKH)?.version();
data[1..21].copy_from_slice(hash);
let checksum = &checksum(&data[..21])[..4];
data[21..].copy_from_slice(checksum);
Ok(Self {
address: data.to_base58(),
format: BitcoinFormat::P2SH_P2WPKH,
_network: PhantomData,
})
}
// Generate a P2WSH address in Bech32 format from a sha256 script hash
pub fn p2wsh_from_hash(hash: &[u8]) -> Result<Self, AddressError> {
if hash.len() != 32 {
return Err(AddressError::Message("Illegal sha256 length".to_string()));
}
let v = N::to_address_prefix(BitcoinFormat::P2WSH)?.version();
let version = u5::try_from_u8(v)?;
let mut data = vec![version];
data.extend_from_slice(&hash.to_vec().to_base32());
let prefix = N::to_address_prefix(BitcoinFormat::Bech32)?.prefix();
let bech32 = bech32::encode(&prefix, data, Variant::Bech32)?;
Ok(Self {
address: bech32,
format: BitcoinFormat::P2WSH,
_network: PhantomData,
})
}
/// Generate a Bech32 address from a hash160
pub fn bech32_from_hash(hash: &[u8]) -> Result<Self, AddressError> {
if hash.len() != 20 {
return Err(AddressError::Message("Illegal hash160 length".to_string()));
}
let data = [
vec![u5::try_from_u8(0)?], // version byte: 0
hash.to_base32(),
]
.concat();
let prefix = N::to_address_prefix(BitcoinFormat::Bech32)?.prefix();
let bech32 = bech32::encode(&prefix, data, Variant::Bech32)?;
Ok(Self {
address: bech32,
format: BitcoinFormat::Bech32,
_network: PhantomData,
})
}
/// Generate a CashAddr address from a hash160
pub fn cash_addr_from_hash(hash: &[u8]) -> Result<Self, AddressError> {
if hash.len() != 20 {
return Err(AddressError::Message("Illegal hash160 length".to_string()));
}
let mut payload = vec![0u8]; // payload starts with version byte: 0
payload.extend(hash);
let payload: Vec<u8> = payload
.to_base32()
.iter()
.map(|byte| BASE32_ENCODE_TABLE[byte.to_u8() as usize])
.collect();
let payload = String::from_utf8(payload)?;
let prefix = N::to_address_prefix(BitcoinFormat::CashAddr)?.prefix();
let checksum = compute_checksum_bch(&payload, &prefix)?;
Ok(Self {
address: format!("{}:{}{}", prefix, payload, checksum),
format: BitcoinFormat::CashAddr,
_network: PhantomData,
})
}
// Generate a P2TR address in Bech32 format from a sha256 script hash
pub fn p2tr_from_hash(hash: &[u8]) -> Result<Self, AddressError> {
if hash.len() != 32 {
return Err(AddressError::Message("Illegal sha256 length".to_string()));
}
let v = 1;
let version = u5::try_from_u8(v)?;
let mut data = vec![version];
data.extend_from_slice(&hash.to_vec().to_base32());
let prefix = N::to_address_prefix(BitcoinFormat::Bech32)?.prefix();
let bech32 = bech32::encode(&prefix, data, Variant::Bech32m)?;
Ok(Self {
address: bech32,
format: BitcoinFormat::Bech32,
_network: PhantomData,
})
}
/// Generate a P2PKH address from a given Bitcoin public key.
pub fn p2pkh(public_key: &<Self as Address>::PublicKey) -> Result<Self, AddressError> {
let hash = hash160(&public_key.serialize());
Self::p2pkh_from_hash(&hash)
}
// Generate a P2WSH address in Bech32 format from a given Bitcoin script
pub fn p2wsh(original_script: &[u8]) -> Result<Self, AddressError> {
let hash = Sha256::digest(original_script).to_vec();
Self::p2wsh_from_hash(&hash)
}
/// Generate a P2SH_P2WPKH address from a given Bitcoin public key.
pub fn p2sh_p2wpkh(public_key: &<Self as Address>::PublicKey) -> Result<Self, AddressError> {
let hash = hash160(&Self::create_redeem_script(public_key));
Self::p2sh_p2wpkh_from_hash(&hash)
}
/// Generate a Bech32 address from a given Bitcoin public key.
pub fn bech32(public_key: &<Self as Address>::PublicKey) -> Result<Self, AddressError> {
let hash = hash160(&public_key.serialize());
Self::bech32_from_hash(&hash)
}
/// Generate a CashAddr address from a given Bitcoin public key.
pub fn cash_addr(public_key: &<Self as Address>::PublicKey) -> Result<Self, AddressError> {
let hash = hash160(&public_key.serialize());
Self::cash_addr_from_hash(&hash)
}
/// Return the format of the Bitcoin address.
pub fn format(&self) -> BitcoinFormat {
self.format.clone()
}
/// Generate a redeem script from a given Bitcoin public key.
pub fn create_redeem_script(public_key: &<Self as Address>::PublicKey) -> [u8; 22] {
let mut redeem = [0u8; 22];
redeem[1] = Opcode::OP_PUSHBYTES_20 as u8;
redeem[2..].copy_from_slice(&hash160(&public_key.serialize()));
redeem
}
/// Decode the 'script_pub_key' to a bitcoin address
pub fn from_script_pub_key(script_pub_key: &[u8]) -> Result<Self, AddressError> {
if script_pub_key.len() == 25
&& script_pub_key[0] == Opcode::OP_DUP as u8
&& script_pub_key[1] == Opcode::OP_HASH160 as u8
&& script_pub_key[2] == 20
&& script_pub_key[23] == Opcode::OP_EQUALVERIFY as u8
&& script_pub_key[24] == Opcode::OP_CHECKSIG as u8
{
// we are handling a p2pkh script
if N::NAME.starts_with("bitcoin cash") {
BitcoinAddress::<N>::cash_addr_from_hash(&script_pub_key[3..23])
} else {
BitcoinAddress::<N>::p2pkh_from_hash(&script_pub_key[3..23])
}
} else if script_pub_key.len() == 23
&& script_pub_key[0] == Opcode::OP_HASH160 as u8
&& script_pub_key[1] == 20
&& script_pub_key[22] == Opcode::OP_EQUAL as u8
{
// we are handling a p2sh_p2wpkh script
BitcoinAddress::<N>::p2sh_p2wpkh_from_hash(&script_pub_key[2..22])
} else if script_pub_key.len() == 34 && script_pub_key[0] == 0 && script_pub_key[1] == 32 {
// we are handling a p2wsh script
BitcoinAddress::<N>::p2wsh_from_hash(&script_pub_key[2..])
} else if script_pub_key.len() == 34 && script_pub_key[0] == 81 && script_pub_key[1] == 32 {
// we are handling a p2tr script
BitcoinAddress::<N>::p2tr_from_hash(&script_pub_key[2..])
} else if script_pub_key.len() == 22 && script_pub_key[0] == 0 && script_pub_key[1] == 20 {
// we are handling a bech32 script
BitcoinAddress::<N>::bech32_from_hash(&script_pub_key[2..])
} else {
Err(AddressError::Message(
"Illegal utxo script public key".to_string(),
))
}
}
}
impl<N: BitcoinNetwork> FromStr for BitcoinAddress<N> {
type Err = AddressError;
fn from_str(address: &str) -> Result<Self, Self::Err> {
if address.starts_with("bitcoincash") || address.starts_with("bchtest") {
// we are processing a bitcoin cash address in CashAddr format
let prefix = address.split(':').collect::<Vec<&str>>()[0];
// check if the address prefix corresponds to the correct network.
let _ = N::from_address_prefix(Prefix::from_prefix(prefix))?;
if address.len() != prefix.len() + 1 + 34 + 8 {
return Err(AddressError::InvalidCharacterLength(
address.len() - prefix.len() - 1,
));
}
let payload = &address[prefix.len() + 1..prefix.len() + 1 + 34];
let checksum_provided = &address[address.len() - 8..address.len()];
// check if the payload produces the provided checksum
let checksum_gen = compute_checksum_bch(payload, prefix)?;
if checksum_provided != checksum_gen {
return Err(AddressError::InvalidChecksum(
checksum_provided.to_string(),
checksum_gen,
));
}
Ok(BitcoinAddress {
address: address.to_string(),
format: BitcoinFormat::CashAddr,
_network: PhantomData,
})
} else if address.starts_with("bc1")
|| address.starts_with("tb1")
|| address.starts_with("ltc1")
|| address.starts_with("tltc1")
{
// we are processing an address in Bech32 format
let (hrp, data, _) = bech32::decode(address)?;
if data.is_empty() {
return Err(AddressError::InvalidAddress(address.to_owned()));
}
// check if the address prefix corresponds to the correct network.
let _ = N::from_address_prefix(Prefix::from_prefix(&hrp))?;
let version = data[0].to_u8();
let mut program = Vec::from_base32(&data[1..])?;
let mut data = vec![version, program.len() as u8];
data.append(&mut program);
// check if the witness program is valid.
let _ = WitnessProgram::new(data.as_slice())?;
Ok(Self {
address: address.to_string(),
format: BitcoinFormat::Bech32,
_network: PhantomData,
})
} else {
let has_uppercase = |s: &str| {
for c in s.chars() {
if c.is_ascii_uppercase() {
return true;
}
}
false
};
if has_uppercase(address) {
// we are processing an address in p2pkh or p2sh_p2wpkh format
let data = address.from_base58()?;
if data.len() != 25 {
return Err(AddressError::InvalidByteLength(data.len()));
}
let version = Prefix::from_version(data[0]);
// check if the address prefix corresponds to the correct network
let _ = N::from_address_prefix(version.clone())?;
let format = BitcoinFormat::from_address_prefix(version)?;
// check if the payload produces the provided checksum
match format {
BitcoinFormat::P2PKH | BitcoinFormat::P2SH_P2WPKH => {
let checksum_gen = &checksum(&data[..21])[..4];
let checksum_provided = &data[21..];
if *checksum_gen != *checksum_provided {
return Err(AddressError::InvalidChecksum(
[data[..21].to_vec(), checksum_gen.to_vec()]
.concat()
.to_base58(),
address.to_string(),
));
}
}
_ => {
return Err(AddressError::Message(format!(
"Unrecognized version byte {}",
data[0],
)))
}
}
Ok(Self {
address: address.to_string(),
format,
_network: PhantomData,
})
} else {
// we are processing a bitcoin cash address in CashAddr format without an explicit prefix
let prefix = N::to_address_prefix(BitcoinFormat::CashAddr)?.prefix();
if address.len() != 42 {
return Err(AddressError::InvalidCharacterLength(address.len()));
}
let payload = &address[..34];
let checksum_provided = &address[34..];
// check if the payload produces the provided checksum
let checksum_gen = compute_checksum_bch(payload, &prefix)?;
if checksum_provided != checksum_gen {
return Err(AddressError::InvalidChecksum(
checksum_provided.to_string(),
checksum_gen,
));
}
Ok(Self {
address: address.to_string(),
format: BitcoinFormat::CashAddr,
_network: PhantomData,
})
}
}
}
}
impl<N: BitcoinNetwork> fmt::Display for BitcoinAddress<N> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.address)
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::{create_script_pub_key, network::*};
use anychain_core::{hex, Network};
use rand::thread_rng;
fn test_from_str<N: BitcoinNetwork>(expected_address: &str, expected_format: &BitcoinFormat) {
let address = BitcoinAddress::<N>::from_str(expected_address).unwrap();
assert_eq!(expected_address, address.to_string());
assert_eq!(*expected_format, address.format);
}
fn test_to_str<N: BitcoinNetwork>(expected_address: &str, address: &BitcoinAddress<N>) {
assert_eq!(expected_address, address.to_string());
}
mod p2pkh_mainnet_compressed {
use super::*;
type N = Bitcoin;
const KEYPAIRS: [(&str, &str); 5] = [
(
"L2o7RUmise9WoxNzmnVZeK83Mmt5Nn1NBpeftbthG5nsLWCzSKVg",
"1GUwicFwsZbdE3XyJYjmPryiiuTiK7mZgS",
),
(
"KzjKw25tuQoiDyQjUG38ZRNBdnfr5eMBnTsU4JahrVDwFCpRZP1J",
"1J2shZV5b53GRVmTqmr3tJhkVbBML29C1z",
),
(
"L2N8YRtxNMAVFAtxBt9PFSADtdvbmzFFHLSU61CtLdhYhrCGPfWh",
"13TdfCiGPagApSJZu1o1Y3mpfqpp6oK2GB",
),
(
"KwXH1Mu4FBtGN9nRn2VkBpienaVGZKvCAkZAdE96kK71dHR1oDRs",
"1HaeDGHf3A2Uxeh3sKjVLYTn1hnEyuzLjF",
),
(
"KwN7qiBnU4GNhboBhuPaPaFingTDKU4r27pGggwQYz865TvBT74V",
"12WMrNLRosydPNNYM96dwk9jDv8rDRom3J",
),
];
#[test]
fn from_str() {
KEYPAIRS.iter().for_each(|(_, address)| {
test_from_str::<N>(address, &BitcoinFormat::P2PKH);
});
}
#[test]
fn to_str() {
KEYPAIRS.iter().for_each(|(_, expected_address)| {
let address = BitcoinAddress::<N>::from_str(expected_address).unwrap();
test_to_str(expected_address, &address);
});
}
}
mod p2pkh_mainnet_uncompressed {
use super::*;
type N = Bitcoin;
const KEYPAIRS: [(&str, &str); 5] = [
(
"5K9VY2kaJ264Pj4ygobGLk7JJMgZ2i6wQ9FFKEBxoFtKeAXPHYm",
"18Bap2Lh5HJckiZcg8SYXoF5iPxkUoCN8u",
),
(
"5KiudZRwr9wH5auJaW66WK3CGR1UzL7ZXiicvZEEaFScbbEt9Qs",
"192JSK8wNP867JGxHNHay3obNSXqEyyhtx",
),
(
"5KCxYELatMGyVZfZFcSAw1Hz4ngiURKS22x7ydNRxcXfUzhgWMH",
"1NoZQSmjYHUZMbqLerwmT4xfe8A6mAo8TT",
),
(
"5KT9CMP2Kgh2Afi8GbmFAHJXsH5DhcpH9KY3aH4Hkv5W6dASy7F",
"1NyGFd49x4nqoau8RJvjf9tGZkoUNjwd5a",
),
(
"5J4cXobHh2cF2MHpLvTFjEHZCtrNHzyDzKGE8LuST2VWP129pAE",
"17nsg1F155BR6ie2miiLrSnMhF8GWcGq6V",
),
];
#[test]
fn from_str() {
KEYPAIRS.iter().for_each(|(_, address)| {
test_from_str::<N>(address, &BitcoinFormat::P2PKH);
});
}
#[test]
fn to_str() {
KEYPAIRS.iter().for_each(|(_, expected_address)| {
let address = BitcoinAddress::<N>::from_str(expected_address).unwrap();
test_to_str(expected_address, &address);
});
}
}
mod p2pkh_testnet_compressed {
use super::*;
type N = BitcoinTestnet;
const KEYPAIRS: [(&str, &str); 5] = [
(
"cSCkpm1oSHTUtX5CHdQ4FzTv9qxLQWKx2SXMg22hbGSTNVcsUcCX",
"mwCDgjeRgGpfTMY1waYAJF2dGz4Q5XAx6w",
),
(
"cNp5uMWdh68Nk3pwShjxsSwhGPoCYgFvE1ANuPsk6qhcT4Jvp57n",
"myH91eNrQKuuM7TeQYYddzL4URn6HiYbxW",
),
(
"cN9aUHNMMLT9yqBJ3S5qnEPtP11nhT7ivkFK1FqNYQMozZPgMTjJ",
"mho8tsQtF7fx2bPKudMcXvGpUVYRHHiH4m",
),
(
"cSRpda6Bhog5SUyot96HSwSzn7FZNWzudKzoCzkgZrf9hUaL3Ass",
"n3DgWHuAkg7eiPGH5gP8jeg3SbHBhuPJWS",
),
(
"cTqLNf3iCaW61ofgmyf4ZxChUL8DZoCEPmNTCKRsexLSdNuGWQT1",
"mjhMXrTdq4X1dcqTaNDjwGdVaJEGBKpCRj",
),
];
#[test]
fn from_str() {
KEYPAIRS.iter().for_each(|(_, address)| {
test_from_str::<N>(address, &BitcoinFormat::P2PKH);
});
}
#[test]
fn to_str() {
KEYPAIRS.iter().for_each(|(_, expected_address)| {
let address = BitcoinAddress::<N>::from_str(expected_address).unwrap();
test_to_str(expected_address, &address);
});
}
}
mod p2pkh_testnet_uncompressed {
use super::*;
type N = BitcoinTestnet;
const KEYPAIRS: [(&str, &str); 5] = [
(
"934pVYUzZ7Sm4ZSP7MtXaQXAcMhZHpFHFBvzfW3epFgk5cWeYih",
"my55YLK4BmM8AyUW5px2HSSKL4yzUE5Pho",
),
(
"91dTfyLPPneZA6RsAXqNuT6qTQdAuuGVCUjmBtzgd1Tnd4RQT5K",
"mw4afqNgGjn34okVmv9qH2WkvhfyTyNbde",
),
(
"92GweXA6j4RCF3zHXGGy2ShJq6T7u9rrjmuYd9ktLHgNrWznzUC",
"moYi3FQZKtcc66edT3uMwVQCcswenpNscU",
),
(
"92QAQdzrEDkMExM9hHV5faWqKTdXcTgXguRBcyAyYqFCjVzhDLE",
"mpRYQJ64ofurTCA3KKkaCjjUNqjYkUvB4w",
),
(
"92H9Kf4ikaqNAJLc5tbwvbmiBWJzNDGtYmnvrigZeDVD3aqJ85Q",
"mvqRXtgQKqumMosPY3dLvhdYsQJV2AswkA",
),
];
#[test]
fn from_str() {
KEYPAIRS.iter().for_each(|(_, address)| {
test_from_str::<N>(address, &BitcoinFormat::P2PKH);
});
}
#[test]
fn to_str() {
KEYPAIRS.iter().for_each(|(_, expected_address)| {
let address = BitcoinAddress::<N>::from_str(expected_address).unwrap();
test_to_str(expected_address, &address);
});
}
}
mod p2sh_p2wpkh_mainnet {
use super::*;
type N = Bitcoin;
const KEYPAIRS: [(&str, &str); 5] = [
(
"L3YPi4msjWdkqiH3ojfg3nwDmNYBrDScAtcugYBJSgsc3HTcqqjP",
"38EMCierP738rgYVHjj1qJANHKgx1166TN",
),
(
"KxxFoGgBdqqyGznT6he2wKYcFKm5urSANec7qjLeu3caEadSo5pv",
"3Kc9Vqzi4eUn42g1KWewVPvtTpWpUwjNFv",
),
(
"KziUnVFNBniwmvei7JvNJNcQZ27TDZe5VNn7ieRNK7QgMEVfKdo9",
"3C2niRgmFP2kz47AAWASqq5nWobDke1AfJ",
),
(
"Kx5veRe18jnV1rZiJA7Xerh5qLpwnbjV38r83sKcF1W9d1K2TGSp",
"3Pai7Ly86pddxxwZ7rUhXjRJwog4oKqNYK",
),
(
"L4RrcBy6hZMw3xD4eAFXDTWPhasd9N3rYrYgfiR9pnGuLdv7UsWZ",
"3LW5tQGWBCiRLfCgk1FEUpwKoymFF8Lk7P",
),
];
#[test]
fn from_str() {
KEYPAIRS.iter().for_each(|(_, address)| {
test_from_str::<N>(address, &BitcoinFormat::P2SH_P2WPKH);
});
}
#[test]
fn to_str() {
KEYPAIRS.iter().for_each(|(_, expected_address)| {
let address = BitcoinAddress::<N>::from_str(expected_address).unwrap();
test_to_str(expected_address, &address);
});
}
}
mod p2sh_p2wpkh_testnet {
use super::*;
type N = BitcoinTestnet;
const KEYPAIRS: [(&str, &str); 5] = [
(
"cSoLwgnCNXck57BGxdGRV4SQ42EUExV6ykdMK1RKwcEaB9MDZWki",
"2N9e892o8DNZs25xHBwRPZLsrZK3dBsrH3d",
),
(
"cQEUStvLToCNEQ6QGPyTmGFCTiMWWzQDkkj2tUPEiAzafybgUyu4",
"2MwX52EZPfK1sq12H3ikgTybrUvKG62b9rV",
),
(
"cRv6jkNhTNEL7563ezNuwWP9W7gEcjh19YbmHtTbrDUQsXF5PjoG",
"2N2XaYpYxX6C6attRQ1NXJUgZdm861CPHJ7",
),
(
"cNyZJwad53Y38RthGrmYyoHAtsT7cPisjW92HJ4RcAP1mC6xBpSm",
"2N3HzUQ4DzfEbxYp3XtpEKBBSdBS1uc2DLk",
),
(
"cUqEZZwzvdWv6pmnWV5eb68hNeWt3jDZgtCGf66rqk3bnbsXArVE",
"2N5isk4qJHAKfLV987ePAqjLobJkrWVCuhj",
),
];
#[test]
fn from_str() {
KEYPAIRS.iter().for_each(|(_, address)| {
test_from_str::<N>(address, &BitcoinFormat::P2SH_P2WPKH);
});
}
#[test]
fn to_str() {
KEYPAIRS.iter().for_each(|(_, expected_address)| {
let address = BitcoinAddress::<N>::from_str(expected_address).unwrap();
test_to_str(expected_address, &address);
});
}
}
mod bech32_mainnet {
use super::*;
type N = Bitcoin;
const KEYPAIRS: [(&str, &str); 5] = [
(
"KyQ2StwnZ644hRLXdMrRUBGKT9WJcVVhnuzz2u528VHeAr5kFimR",
"bc1qztqceddvavsxdgju4cz6z42tawu444m8uttmxg",
),
(
"L3aeYHnEBqNt6tKTgUyweY9HvZ3mcLMsq7KQZkSu9Mj8Z1JN9oC2",
"bc1q0s92yg9m0zqjjc07z5lhhlu3k6ue93fgzku2wy",
),
(
"L3w7zoPzip7o6oXz3zVLNHbT2UyLBWuVG7uaEZDqneRjgjw9vmCE",
"bc1q7rzq3xup0hdklkg6p8harn97zszuqwuaqc9l8t",
),
(
"L2C75eEmRTU8yWeSwtQ6xeumoNVmCb2uEMfzuo5dkdMwpUWwYtRU",
"bc1qgw90ly6jkpprh6g8atk5cxnwcavh4e0p2k3h65",
),
(
"L2CJfT3w1VPDDLQfJKTmSb6gtSGyE1HxWYsitaq5Y1XLXTMC5Qmx",
"bc1qgfzgf6pzuk7y88zk54nxluzg6dv9jett9suzuf",
),
];
const INVALID: [&str; 7] = [
"bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t5", // invalid checksum
"BC13W508D6QEJXTDG4Y5R3ZARVARY0C5XW7KN40WF2", // invalid witness version
"bc1rw5uspcuh", // invalid program length
"bc10w508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7kw5rljs90", // invalid program length
"BC1QR508D6QEJXTDG4Y5R3ZARVARYV98GJ9P", // invalid program length for witness version 0 (per BIP141)
"bc1zw508d6qejxtdg4y5r3zarvaryvqyzf3du", // invalid padding
"bc1gmk9yu", // empty data section
];
#[test]
fn from_invalid_address() {
INVALID.iter().for_each(|invalid_bech32| {
assert!(BitcoinAddress::<N>::from_str(invalid_bech32).is_err());
});
}
#[test]
fn from_str() {
KEYPAIRS.iter().for_each(|(_, address)| {
test_from_str::<N>(address, &BitcoinFormat::Bech32);
});
}
#[test]
fn to_str() {
KEYPAIRS.iter().for_each(|(_, expected_address)| {
let address = BitcoinAddress::<N>::from_str(expected_address).unwrap();
test_to_str(expected_address, &address);
});
}
}
mod bech32_testnet {
use super::*;
type N = BitcoinTestnet;
const KEYPAIRS: [(&str, &str); 5] = [
(
"cVQmTtLoCjDJAXVj778xyww1ZbpJQt7Vq9sDt8Mdmw97Rg7TaNes",
"tb1qmkvfprg8pkr3apv9gyykmhe26fexyla076ss0g",
),
(
"cTxHRG8MgrnSQstuMs5VnQcFBjrs67NmiJGo1kevnJDS7QFGLUAi",
"tb1qfe0dnfpxp4c9lfdjzvmf5q72jg83emgknmcxxd",
),
(
"cSN1N2Vmhg9jPSUpXyQj8WbNUgeLHbC3Yj8SFX2N834YMepMwNZH",
"tb1qx4jm2s3ks5vadh2ja3flsn4ckjzhdxmxmmrrzx",
),
(
"cMvmoqYYzr4dgzNZ22PvaqSnNx98evXc1b7m8FfK9SdCqhiWdP2c",
"tb1ql0g42pusevlgd0jh9gyr32s0h0pe96wpnrqg3m",
),
(
"cVodD5ifcBjYVUs19GLwz6YzU2hUhdNagBx9QQcZp7TgjLuuFYn3",
"tb1qwnh7hu5qfrjsk9pyn3vvmzr48v4l8kp4ug0txn",
),
];
const INVALID: [&str; 3] = [
"tc1qw508d6qejxtdg4y5r3zarvary0c5xw7kg3g4ty", // invalid hrp
"tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sL5k7", // Mixed case
"tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3pjxtptv",
];
#[test]
fn from_invalid_address() {
INVALID.iter().for_each(|invalid_bech32| {
assert!(BitcoinAddress::<N>::from_str(invalid_bech32).is_err());
});
}
#[test]
fn from_str() {
KEYPAIRS.iter().for_each(|(_, address)| {
test_from_str::<N>(address, &BitcoinFormat::Bech32);
});
}
#[test]
fn to_str() {
KEYPAIRS.iter().for_each(|(_, expected_address)| {
let address = BitcoinAddress::<N>::from_str(expected_address).unwrap();
test_to_str(expected_address, &address);
});
}
}
mod p2wsh_mainnet {
use super::*;
type N = Bitcoin;
#[test]
fn test_addr() {
let script = "210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ac";
let script_hex = hex::decode(script).unwrap();
let new_address = BitcoinAddress::<N>::p2wsh(&script_hex).unwrap();
println!("address:{}", new_address);
}
}
mod p2wsh_testnet {
use super::*;
type N = BitcoinTestnet;
const SCRIPTPAIRS: [(&str, &str); 2] = [
(
"210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ac",
"tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7",
),
(
"210253be79afe84fd9342c1f52024379b6da6299ea98844aee23838e8e678a765f7cac",
"tb1qhmdep02f0jpjxs36ckyzjtfesknu8a8xmhnva7f3vw95t9g6q4ksaqhl9x",
),
];
#[test]
fn from_str() {
SCRIPTPAIRS.iter().for_each(|(script, address)| {
let script_hex = hex::decode(script).unwrap();
let new_address = BitcoinAddress::<N>::p2wsh(&script_hex).unwrap();
assert_eq!(new_address.to_string(), address.to_string());
assert_eq!(new_address.format, BitcoinFormat::P2WSH);
});
}
#[test]
fn to_str() {
SCRIPTPAIRS.iter().for_each(|(_, expected_address)| {
let address = BitcoinAddress::<N>::from_str(expected_address).unwrap();
test_to_str(expected_address, &address);
});
}
}
#[test]
fn f() {
let secret_key = [
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1,
];
let secret_key = libsecp256k1::SecretKey::parse(&secret_key).unwrap();
let formats = [
BitcoinFormat::P2PKH,
BitcoinFormat::P2SH_P2WPKH,
// BitcoinFormat::Bech32,
// BitcoinFormat::CashAddr
];
for format in formats {
let address = BitcoinAddress::<Bitcoin>::from_secret_key(&secret_key, &format).unwrap();
println!("{} {} address = \n{}\n", Bitcoin::NAME, format, address);
let address =
BitcoinAddress::<BitcoinTestnet>::from_secret_key(&secret_key, &format).unwrap();
println!(
"{} {} address = \n{}\n",
BitcoinTestnet::NAME,
format,
address
);
let address =
BitcoinAddress::<BitcoinCash>::from_secret_key(&secret_key, &format).unwrap();
println!("{} {} address = \n{}\n", BitcoinCash::NAME, format, address);
let address =
BitcoinAddress::<BitcoinCashTestnet>::from_secret_key(&secret_key, &format)
.unwrap();
println!(
"{} {} address = \n{}\n",
BitcoinCashTestnet::NAME,
format,
address
);
let address =
BitcoinAddress::<Litecoin>::from_secret_key(&secret_key, &format).unwrap();
println!("{} {} address = \n{}\n", Litecoin::NAME, format, address);
let address =
BitcoinAddress::<LitecoinTestnet>::from_secret_key(&secret_key, &format).unwrap();
println!(
"{} {} address = \n{}\n",
LitecoinTestnet::NAME,
format,
address
);
let address =
BitcoinAddress::<Dogecoin>::from_secret_key(&secret_key, &format).unwrap();
println!("{} {} address = \n{}\n", Dogecoin::NAME, format, address);
let address =
BitcoinAddress::<DogecoinTestnet>::from_secret_key(&secret_key, &format).unwrap();
println!(
"{} {} address = \n{}\n",
DogecoinTestnet::NAME,
format,
address
);
}
}
#[test]
fn ff() {
let addr1 = "qzuu4gwvj0xjy4p7xj7n5gn4ewk4m3ujeqx3crgj59";
let addr2 = "qpkxa3xypl6rfp4nzewh9xrqnv90n2yxrcr0pmwas4";
let addr3 = "bchtest:qzuu4gwvj0xjy4p7xj7n5gn4ewk4m3ujeqx3crgj59";
let addr4 = "bitcoincash:qpkxa3xypl6rfp4nzewh9xrqnv90n2yxrcr0pmwas4";
let addr5 = "2MvtZ4txAvbaWRW2gXRmmrcUpQfsqNgpfUm";
let addr1 = BitcoinAddress::<BitcoinCashTestnet>::from_str(addr1).unwrap();
let addr2 = BitcoinAddress::<BitcoinCash>::from_str(addr2).unwrap();
let addr3 = BitcoinAddress::<BitcoinCashTestnet>::from_str(addr3).unwrap();
let addr4 = BitcoinAddress::<BitcoinCash>::from_str(addr4).unwrap();
let addr5 = BitcoinAddress::<BitcoinTestnet>::from_str(addr5).unwrap();
println!(
"address1 = {}\naddress2 = {}\naddress3 = {}\naddress4 = {}\naddress5 = {}",
addr1, addr2, addr3, addr4, addr5,
);
}
#[test]
fn test_decode_script() {
let mut rng = thread_rng();
let sk = libsecp256k1::SecretKey::random(&mut rng);
let addr = BitcoinAddress::<Bitcoin>::from_secret_key(&sk, &BitcoinFormat::P2PKH).unwrap();
println!("{}", addr);
let script = create_script_pub_key(&addr).unwrap();
let addr = BitcoinAddress::<Bitcoin>::from_script_pub_key(&script).unwrap();
println!("{}", addr);
let sk = libsecp256k1::SecretKey::random(&mut rng);
let addr =
BitcoinAddress::<Bitcoin>::from_secret_key(&sk, &BitcoinFormat::P2SH_P2WPKH).unwrap();
println!("{}", addr);
let script = create_script_pub_key(&addr).unwrap();
let addr = BitcoinAddress::<Bitcoin>::from_script_pub_key(&script).unwrap();
println!("{}", addr);
let sk = libsecp256k1::SecretKey::random(&mut rng);
let addr = BitcoinAddress::<Bitcoin>::from_secret_key(&sk, &BitcoinFormat::Bech32).unwrap();
println!("{}", addr);
let script = create_script_pub_key(&addr).unwrap();
let addr = BitcoinAddress::<Bitcoin>::from_script_pub_key(&script).unwrap();
println!("{}", addr);
let sk = libsecp256k1::SecretKey::random(&mut rng);
let addr =
BitcoinAddress::<Bitcoin>::p2wsh_from_hash(&Sha256::digest(sk.serialize())).unwrap();
println!("{}", addr);
let script = create_script_pub_key(&addr).unwrap();
let addr = BitcoinAddress::<Bitcoin>::from_script_pub_key(&script).unwrap();
println!("{}", addr);
let sk = libsecp256k1::SecretKey::random(&mut rng);
let addr =
BitcoinAddress::<BitcoinCash>::from_secret_key(&sk, &BitcoinFormat::CashAddr).unwrap();
println!("{}", addr);
let script = create_script_pub_key(&addr).unwrap();
let addr = BitcoinAddress::<BitcoinCash>::from_script_pub_key(&script).unwrap();
println!("{}", addr);
}
}
================================================
FILE: crates/anychain-bitcoin/src/amount.rs
================================================
use anychain_core::{Amount, AmountError};
use core::fmt;
use serde::Serialize;
use std::ops::{Add, Sub};
// Number of satoshis (base unit) per BTC
const COIN: i64 = 1_0000_0000;
/// Represents the amount of Bitcoin in satoshis
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
pub struct BitcoinAmount(pub i64);
pub enum Denomination {
// sat
Satoshi,
// uBTC (bit)
MicroBit,
// mBTC
MilliBit,
// cBTC
CentiBit,
// dBTC
DeciBit,
// BTC
Bitcoin,
}
impl Denomination {
/// The number of decimal places more than a satoshi.
fn precision(self) -> u32 {
match self {
Denomination::Satoshi => 0,
Denomination::MicroBit => 2,
Denomination::MilliBit => 5,
Denomination::CentiBit => 6,
Denomination::DeciBit => 7,
Denomination::Bitcoin => 8,
}
}
}
impl fmt::Display for Denomination {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{}",
match self {
Denomination::Satoshi => "satoshi",
Denomination::MicroBit => "uBTC",
Denomination::MilliBit => "mBTC",
Denomination::CentiBit => "cBTC",
Denomination::DeciBit => "dBTC",
Denomination::Bitcoin => "BTC",
}
)
}
}
impl Amount for BitcoinAmount {}
impl BitcoinAmount {
/// The zero amount.
pub const ZERO: BitcoinAmount = BitcoinAmount(0);
/// Exactly one satoshi.
pub const ONE_SAT: BitcoinAmount = BitcoinAmount(1);
/// Exactly one bitcoin.
pub const ONE_BTC: BitcoinAmount = BitcoinAmount(COIN);
pub fn from_satoshi(satoshis: i64) -> Result<Self, AmountError> {
Ok(Self(satoshis))
}
pub fn from_ubtc(ubtc_value: i64) -> Result<Self, AmountError> {
let satoshis = ubtc_value * 10_i64.pow(Denomination::MicroBit.precision());
Self::from_satoshi(satoshis)
}
pub fn from_mbtc(mbtc_value: i64) -> Result<Self, AmountError> {
let satoshis = mbtc_value * 10_i64.pow(Denomination::MilliBit.precision());
Self::from_satoshi(satoshis)
}
pub fn from_cbtc(cbtc_value: i64) -> Result<Self, AmountError> {
let satoshis = cbtc_value * 10_i64.pow(Denomination::CentiBit.precision());
Self::from_satoshi(satoshis)
}
pub fn from_dbtc(dbtc_value: i64) -> Result<Self, AmountError> {
let satoshis = dbtc_value * 10_i64.pow(Denomination::DeciBit.precision());
Self::from_satoshi(satoshis)
}
pub fn from_btc(btc_value: i64) -> Result<Self, AmountError> {
let satoshis = btc_value * 10_i64.pow(Denomination::Bitcoin.precision());
Self::from_satoshi(satoshis)
}
}
impl Add for BitcoinAmount {
type Output = Result<Self, AmountError>;
fn add(self, rhs: Self) -> Self::Output {
Self::from_satoshi(self.0 + rhs.0)
}
}
impl Sub for BitcoinAmount {
type Output = Result<Self, AmountError>;
fn sub(self, rhs: Self) -> Self::Output {
Self::from_satoshi(self.0 - rhs.0)
}
}
impl fmt::Display for BitcoinAmount {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.0)
}
}
#[cfg(test)]
mod tests {
use super::*;
fn test_from_satoshi(sat_value: i64, expected_amount: BitcoinAmount) {
let amount = BitcoinAmount::from_satoshi(sat_value).unwrap();
assert_eq!(expected_amount, amount)
}
fn test_from_ubtc(ubtc_value: i64, expected_amount: BitcoinAmount) {
let amount = BitcoinAmount::from_ubtc(ubtc_value).unwrap();
assert_eq!(expected_amount, amount)
}
fn test_from_mbtc(mbtc_value: i64, expected_amount: BitcoinAmount) {
let amount = BitcoinAmount::from_mbtc(mbtc_value).unwrap();
assert_eq!(expected_amount, amount)
}
fn test_from_cbtc(cbtc_value: i64, expected_amount: BitcoinAmount) {
let amount = BitcoinAmount::from_cbtc(cbtc_value).unwrap();
assert_eq!(expected_amount, amount)
}
fn test_from_dbtc(dbtc_value: i64, expected_amount: BitcoinAmount) {
let amount = BitcoinAmount::from_dbtc(dbtc_value).unwrap();
assert_eq!(expected_amount, amount)
}
fn test_from_btc(btc_value: i64, expected_amount: BitcoinAmount) {
let amount = BitcoinAmount::from_btc(btc_value).unwrap();
assert_eq!(expected_amount, amount)
}
fn test_addition(a: &i64, b: &i64, result: &i64) {
let a = BitcoinAmount::from_satoshi(*a).unwrap();
let b = BitcoinAmount::from_satoshi(*b).unwrap();
let result = BitcoinAmount::from_satoshi(*result).unwrap();
assert_eq!(result, a.add(b).unwrap());
}
fn test_subtraction(a: &i64, b: &i64, result: &i64) {
let a = BitcoinAmount::from_satoshi(*a).unwrap();
let b = BitcoinAmount::from_satoshi(*b).unwrap();
let result = BitcoinAmount::from_satoshi(*result).unwrap();
assert_eq!(result, a.sub(b).unwrap());
}
pub struct AmountDenominationTestCase {
satoshi: i64,
micro_bit: i64,
milli_bit: i64,
centi_bit: i64,
deci_bit: i64,
bitcoin: i64,
}
mod valid_conversions {
use super::*;
const TEST_AMOUNTS: [AmountDenominationTestCase; 5] = [
AmountDenominationTestCase {
satoshi: 0,
micro_bit: 0,
milli_bit: 0,
centi_bit: 0,
deci_bit: 0,
bitcoin: 0,
},
AmountDenominationTestCase {
satoshi: 100000000,
micro_bit: 1000000,
milli_bit: 1000,
centi_bit: 100,
deci_bit: 10,
bitcoin: 1,
},
AmountDenominationTestCase {
satoshi: 100000000000,
micro_bit: 1000000000,
milli_bit: 1000000,
centi_bit: 100000,
deci_bit: 10000,
bitcoin: 1000,
},
AmountDenominationTestCase {
satoshi: 123456700000000,
micro_bit: 1234567000000,
milli_bit: 1234567000,
centi_bit: 123456700,
deci_bit: 12345670,
bitcoin: 1234567,
},
AmountDenominationTestCase {
satoshi: 2100000000000000,
micro_bit: 21000000000000,
milli_bit: 21000000000,
centi_bit: 2100000000,
deci_bit: 210000000,
bitcoin: 21000000,
},
];
#[test]
fn test_satoshi_conversion() {
TEST_AMOUNTS.iter().for_each(|amounts| {
test_from_satoshi(amounts.satoshi, BitcoinAmount(amounts.satoshi))
});
}
#[test]
fn test_ubtc_conversion() {
TEST_AMOUNTS.iter().for_each(|amounts| {
test_from_ubtc(amounts.micro_bit, BitcoinAmount(amounts.satoshi))
});
}
#[test]
fn test_mbtc_conversion() {
TEST_AMOUNTS.iter().for_each(|amounts| {
test_from_mbtc(amounts.milli_bit, BitcoinAmount(amounts.satoshi))
});
}
#[test]
fn test_cbtc_conversion() {
TEST_AMOUNTS.iter().for_each(|amounts| {
test_from_cbtc(amounts.centi_bit, BitcoinAmount(amounts.satoshi))
});
}
#[test]
fn test_dbtc_conversion() {
TEST_AMOUNTS.iter().for_each(|amounts| {
test_from_dbtc(amounts.deci_bit, BitcoinAmount(amounts.satoshi))
});
}
#[test]
fn test_btc_conversion() {
TEST_AMOUNTS
.iter()
.for_each(|amounts| test_from_btc(amounts.bitcoin, BitcoinAmount(amounts.satoshi)));
}
}
mod valid_arithmetic {
use super::*;
const TEST_VALUES: [(i64, i64, i64); 7] = [
(0, 0, 0),
(1, 2, 3),
(100000, 0, 100000),
(123456789, 987654321, 1111111110),
(100000000000000, 2000000000000000, 2100000000000000),
(-100000000000000, -2000000000000000, -2100000000000000),
(1000000, -1000000, 0),
];
#[test]
fn test_valid_addition() {
TEST_VALUES
.iter()
.for_each(|(a, b, c)| test_addition(a, b, c));
}
#[test]
fn test_valid_subtraction() {
TEST_VALUES
.iter()
.for_each(|(a, b, c)| test_subtraction(c, b, a));
}
}
mod test_invalid {
use super::*;
mod test_invalid_conversion {
use super::*;
const INVALID_TEST_AMOUNTS: [AmountDenominationTestCase; 4] = [
AmountDenominationTestCase {
satoshi: 1,
micro_bit: 1,
milli_bit: 1,
centi_bit: 1,
deci_bit: 1,
bitcoin: 1,
},
AmountDenominationTestCase {
satoshi: 1,
micro_bit: 10,
milli_bit: 100,
centi_bit: 1000,
deci_bit: 1000000,
bitcoin: 100000000,
},
AmountDenominationTestCase {
satoshi: 123456789,
micro_bit: 1234567,
milli_bit: 1234,
centi_bit: 123,
deci_bit: 12,
bitcoin: 1,
},
AmountDenominationTestCase {
satoshi: 2100000000000000,
micro_bit: 21000000000000,
milli_bit: 21000000000,
centi_bit: 2100000000,
deci_bit: 210000000,
bitcoin: 20999999,
},
];
#[should_panic]
#[test]
fn test_invalid_ubtc_conversion() {
INVALID_TEST_AMOUNTS.iter().for_each(|amounts| {
test_from_ubtc(amounts.micro_bit, BitcoinAmount(amounts.satoshi))
});
}
#[should_panic]
#[test]
fn test_invalid_mbtc_conversion() {
INVALID_TEST_AMOUNTS.iter().for_each(|amounts| {
test_from_mbtc(amounts.milli_bit, BitcoinAmount(amounts.satoshi))
});
}
#[should_panic]
#[test]
fn test_invalid_cbtc_conversion() {
INVALID_TEST_AMOUNTS.iter().for_each(|amounts| {
test_from_cbtc(amounts.centi_bit, BitcoinAmount(amounts.satoshi))
});
}
#[should_panic]
#[test]
fn test_invalid_dbtc_conversion() {
INVALID_TEST_AMOUNTS.iter().for_each(|amounts| {
test_from_dbtc(amounts.deci_bit, BitcoinAmount(amounts.satoshi))
});
}
#[should_panic]
#[test]
fn test_invalid_btc_conversion() {
INVALID_TEST_AMOUNTS.iter().for_each(|amounts| {
test_from_btc(amounts.bitcoin, BitcoinAmount(amounts.satoshi))
});
}
}
mod invalid_arithmetic {
use super::*;
const TEST_VALUES: [(i64, i64, i64); 8] = [
(0, 0, 1),
(1, 2, 5),
(100000, 1, 100000),
(123456789, 123456789, 123456789),
(-1000, -1000, 2000),
(2100000000000000, 1, 2100000000000001),
(2100000000000000, 2100000000000000, 4200000000000000),
(-2100000000000000, -2100000000000000, -4200000000000000),
];
#[should_panic]
#[test]
fn test_invalid_addition() {
TEST_VALUES
.iter()
.for_each(|(a, b, c)| test_addition(a, b, c));
}
#[should_panic]
#[test]
fn test_invalid_subtraction() {
TEST_VALUES
.iter()
.for_each(|(a, b, c)| test_subtraction(a, b, c));
}
}
}
}
================================================
FILE: crates/anychain-bitcoin/src/format.rs
================================================
use crate::Prefix;
use anychain_core::no_std::*;
use anychain_core::{AddressError, Format};
use core::fmt;
use core::str::FromStr;
use serde::Serialize;
/// Represents the format of a Bitcoin address
#[derive(Serialize, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[allow(non_camel_case_types)]
pub enum BitcoinFormat {
/// Pay-to-Pubkey Hash, e.g. 1NoZQSmjYHUZMbqLerwmT4xfe8A6mAo8TT
P2PKH,
/// Pay-to-Script Hash, e.g. 34AgLJhwXrvmkZS1o5TrcdeevMt22Nar53
//P2SH,
/// Pay-to-Witness-Script Hash, e.g. bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3
P2WSH,
/// SegWit Pay-to-Witness-Public-Key Hash, e.g. 34AgLJhwXrvmkZS1o5TrcdeevMt22Nar53
P2SH_P2WPKH,
/// Bech32, e.g. bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k7grplx
Bech32,
/// CashAddr, e.g. bitcoincash:qpkxa3xypl6rfp4nzewh9xrqnv90n2yxrcr0pmwas4
CashAddr,
}
impl Format for BitcoinFormat {}
impl BitcoinFormat {
/// Returns the format of the given address prefix.
pub fn from_address_prefix(prefix: Prefix) -> Result<Self, AddressError> {
match prefix {
Prefix::AddressPrefix(prefix) => match prefix.as_str() {
"bc" | "tb" | "ltc" | "tltc" => Ok(Self::Bech32),
"bitcoincash" | "bchtest" => Ok(Self::CashAddr),
_ => Err(AddressError::Message(format!(
"Unrecognized address prefix {}",
prefix,
))),
},
Prefix::Version(version) => match version {
0x00 | 0x6f | 0x1e | 0x71 | 0x30 => Ok(Self::P2PKH),
0x05 | 0xc4 | 0x16 | 0x32 | 0x3a => Ok(Self::P2SH_P2WPKH),
_ => Err(AddressError::Message(format!(
"Unrecognized version byte {}",
version,
))),
},
}
}
}
impl fmt::Display for BitcoinFormat {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
BitcoinFormat::P2PKH => write!(f, "p2pkh"),
BitcoinFormat::P2WSH => write!(f, "p2wsh"),
BitcoinFormat::P2SH_P2WPKH => write!(f, "p2sh_p2wpkh"),
BitcoinFormat::Bech32 => write!(f, "bech32"),
BitcoinFormat::CashAddr => write!(f, "cash_addr"),
}
}
}
impl FromStr for BitcoinFormat {
type Err = AddressError;
fn from_str(format: &str) -> Result<Self, AddressError> {
match format {
"p2pkh" => Ok(BitcoinFormat::P2PKH),
"p2sh_p2wpkh" => Ok(BitcoinFormat::P2SH_P2WPKH),
"p2wsh" => Ok(BitcoinFormat::P2WSH),
"bech32" => Ok(BitcoinFormat::Bech32),
"cash_addr" => Ok(BitcoinFormat::CashAddr),
_ => Err(AddressError::Message(format!(
"Unrecognized bitcoin address format {}",
format,
))),
}
}
}
================================================
FILE: crates/anychain-bitcoin/src/lib.rs
================================================
#![cfg_attr(not(feature = "std"), no_std)]
#![warn(unused_extern_crates)]
// #![forbid(unsafe_code)]
#[macro_use]
extern crate thiserror;
pub mod address;
pub use self::address::*;
pub mod format;
pub use self::format::*;
pub mod network;
pub use self::network::*;
pub mod public_key;
pub use self::public_key::*;
pub mod witness_program;
pub use self::witness_program::*;
pub mod transaction;
pub use self::transaction::*;
pub mod amount;
pub use self::amount::*;
================================================
FILE: crates/anychain-bitcoin/src/network/bitcoin.rs
================================================
use crate::{BitcoinFormat, BitcoinNetwork, Prefix};
use anychain_core::no_std::*;
use anychain_core::{AddressError, Network, NetworkError};
use core::{fmt, str::FromStr};
use serde::Serialize;
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
pub struct Bitcoin;
impl Network for Bitcoin {
const NAME: &'static str = "bitcoin";
}
impl BitcoinNetwork for Bitcoin {
/// Returns the address prefix of the given network.
fn to_address_prefix(format: BitcoinFormat) -> Result<Prefix, AddressError> {
match format {
BitcoinFormat::P2PKH => Ok(Prefix::Version(0x00)),
BitcoinFormat::P2WSH => Ok(Prefix::Version(0x00)),
BitcoinFormat::P2SH_P2WPKH => Ok(Prefix::Version(0x05)),
BitcoinFormat::Bech32 => Ok(Prefix::AddressPrefix("bc".to_string())),
f => Err(AddressError::Message(format!(
"{} does not support address format {}",
Self::NAME,
f,
))),
}
}
/// Returns the network of the given address prefix.
fn from_address_prefix(prefix: Prefix) -> Result<Self, AddressError> {
match prefix {
Prefix::Version(version) => match version {
0x00 | 0x05 => Ok(Self),
_ => Err(AddressError::Message(format!(
"Invalid version byte {:#0x} for {} network",
version,
Self::NAME,
))),
},
Prefix::AddressPrefix(prefix) => match prefix.as_str() {
"bc" => Ok(Self),
_ => Err(AddressError::Message(format!(
"Invalid Bech32 prefix for {} network",
Self::NAME,
))),
},
}
}
}
impl FromStr for Bitcoin {
type Err = NetworkError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
Self::NAME => Ok(Self),
_ => Err(NetworkError::InvalidNetwork(s.into())),
}
}
}
impl fmt::Display for Bitcoin {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", Self::NAME)
}
}
================================================
FILE: crates/anychain-bitcoin/src/network/bitcoin_testnet.rs
================================================
use crate::{BitcoinFormat, BitcoinNetwork, Prefix};
use anychain_core::no_std::*;
use anychain_core::{AddressError, Network, NetworkError};
use core::{fmt, str::FromStr};
use serde::Serialize;
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
pub struct BitcoinTestnet;
impl Network for BitcoinTestnet {
const NAME: &'static str = "bitcoin testnet";
}
impl BitcoinNetwork for BitcoinTestnet {
/// Returns the address prefix of the given network.
fn to_address_prefix(format: BitcoinFormat) -> Result<Prefix, AddressError> {
match format {
BitcoinFormat::P2PKH => Ok(Prefix::Version(0x6f)),
BitcoinFormat::P2WSH => Ok(Prefix::Version(0x00)),
BitcoinFormat::P2SH_P2WPKH => Ok(Prefix::Version(0xc4)),
BitcoinFormat::Bech32 => Ok(Prefix::AddressPrefix("tb".to_string())),
f => Err(AddressError::Message(format!(
"{} does not support address format {}",
Self::NAME,
f,
))),
}
}
/// Returns the network of the given address prefix.
fn from_address_prefix(prefix: Prefix) -> Result<Self, AddressError> {
match prefix {
Prefix::Version(version) => match version {
0x6f | 0xc4 => Ok(Self),
_ => Err(AddressError::Message(format!(
"Invalid version byte {:#0x} for {} network",
version,
Self::NAME,
))),
},
Prefix::AddressPrefix(prefix) => match prefix.as_str() {
"tb" => Ok(Self),
_ => Err(AddressError::Message(format!(
"Invalid Bech32 prefix for {} network",
Self::NAME,
))),
},
}
}
}
impl FromStr for BitcoinTestnet {
type Err = NetworkError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
Self::NAME => Ok(Self),
_ => Err(NetworkError::InvalidNetwork(s.into())),
}
}
}
impl fmt::Display for BitcoinTestnet {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", Self::NAME)
}
}
================================================
FILE: crates/anychain-bitcoin/src/network/bitcoincash.rs
================================================
use crate::{BitcoinFormat, BitcoinNetwork, Prefix};
use anychain_core::no_std::*;
use anychain_core::{AddressError, Network, NetworkError};
use core::{fmt, str::FromStr};
use serde::Serialize;
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
pub struct BitcoinCash;
impl Network for BitcoinCash {
const NAME: &'static str = "bitcoin cash";
}
impl BitcoinNetwork for BitcoinCash {
/// Returns the address prefix of the given network.
fn to_address_prefix(format: BitcoinFormat) -> Result<Prefix, AddressError> {
match format {
BitcoinFormat::P2PKH => Ok(Prefix::Version(0x00)),
BitcoinFormat::P2WSH => Ok(Prefix::Version(0x00)),
BitcoinFormat::P2SH_P2WPKH => Ok(Prefix::Version(0x05)),
BitcoinFormat::Bech32 => Ok(Prefix::AddressPrefix("bc".to_string())),
BitcoinFormat::CashAddr => Ok(Prefix::AddressPrefix("bitcoincash".to_string())),
}
}
/// Returns the network of the given address prefix.
fn from_address_prefix(prefix: Prefix) -> Result<Self, AddressError> {
match prefix {
Prefix::Version(version) => match version {
0x00 | 0x05 => Ok(Self),
_ => Err(AddressError::Message(format!(
"Invalid version byte {:#0x} for {} network",
version,
Self::NAME,
))),
},
Prefix::AddressPrefix(prefix) => match prefix.as_str() {
"bc" | "bitcoincash" => Ok(Self),
_ => Err(AddressError::Message(format!(
"Invalid Bech32 or CashAddr prefix for {} network",
Self::NAME,
))),
},
}
}
}
impl FromStr for BitcoinCash {
type Err = NetworkError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
Self::NAME => Ok(Self),
_ => Err(NetworkError::InvalidNetwork(s.into())),
}
}
}
impl fmt::Display for BitcoinCash {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", Self::NAME)
}
}
================================================
FILE: crates/anychain-bitcoin/src/network/bitcoincash_testnet.rs
================================================
use crate::{BitcoinFormat, BitcoinNetwork, Prefix};
use anychain_core::no_std::*;
use anychain_core::{AddressError, Network, NetworkError};
use core::{fmt, str::FromStr};
use serde::Serialize;
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
pub struct BitcoinCashTestnet;
impl Network for BitcoinCashTestnet {
const NAME: &'static str = "bitcoin cash testnet";
}
impl BitcoinNetwork for BitcoinCashTestnet {
/// Returns the address prefix of the given network.
fn to_address_prefix(format: BitcoinFormat) -> Result<Prefix, AddressError> {
match format {
BitcoinFormat::P2PKH => Ok(Prefix::Version(0x6f)),
BitcoinFormat::P2WSH => Ok(Prefix::Version(0x00)),
BitcoinFormat::P2SH_P2WPKH => Ok(Prefix::Version(0xc4)),
BitcoinFormat::Bech32 => Ok(Prefix::AddressPrefix("tb".to_string())),
BitcoinFormat::CashAddr => Ok(Prefix::AddressPrefix("bchtest".to_string())),
}
}
/// Returns the network of the given address prefix.
fn from_address_prefix(prefix: Prefix) -> Result<Self, AddressError> {
match prefix {
Prefix::Version(version) => match version {
0x6f | 0xc4 => Ok(Self),
_ => Err(AddressError::Message(format!(
"Invalid version byte {:#0x} for {} network",
version,
Self::NAME,
))),
},
Prefix::AddressPrefix(prefix) => match prefix.as_str() {
"tb" | "bchtest" => Ok(Self),
_ => Err(AddressError::Message(format!(
"Invalid Bech32 or CashAddr prefix for {} network",
Self::NAME,
))),
},
}
}
}
impl FromStr for BitcoinCashTestnet {
type Err = NetworkError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
Self::NAME => Ok(Self),
_ => Err(NetworkError::InvalidNetwork(s.into())),
}
}
}
impl fmt::Display for BitcoinCashTestnet {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", Self::NAME)
}
}
================================================
FILE: crates/anychain-bitcoin/src/network/dogecoin.rs
================================================
use crate::{BitcoinFormat, BitcoinNetwork, Prefix};
use anychain_core::no_std::*;
use anychain_core::{AddressError, Network, NetworkError};
use core::{fmt, str::FromStr};
use serde::Serialize;
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
pub struct Dogecoin;
impl Network for Dogecoin {
const NAME: &'static str = "dogecoin";
}
impl BitcoinNetwork for Dogecoin {
/// Returns the address prefix of the given network.
fn to_address_prefix(format: BitcoinFormat) -> Result<Prefix, AddressError> {
match format {
BitcoinFormat::P2PKH => Ok(Prefix::Version(0x1e)),
BitcoinFormat::P2WSH => Ok(Prefix::Version(0x00)),
BitcoinFormat::P2SH_P2WPKH => Ok(Prefix::Version(0x16)),
f => Err(AddressError::Message(format!(
"{} does not support address format {}",
Self::NAME,
f,
))),
}
}
/// Returns the network of the given address prefix.
fn from_address_prefix(prefix: Prefix) -> Result<Self, AddressError> {
match prefix {
Prefix::Version(version) => match version {
0x1e | 0x16 => Ok(Self),
_ => Err(AddressError::Message(format!(
"Invalid version byte {:#0x} for {} network",
version,
Self::NAME,
))),
},
_ => Err(AddressError::Message(format!(
"{} does not support address format Bech32 or CashAddr",
Self::NAME,
))),
}
}
}
impl FromStr for Dogecoin {
type Err = NetworkError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
Self::NAME => Ok(Self),
_ => Err(NetworkError::InvalidNetwork(s.into())),
}
}
}
impl fmt::Display for Dogecoin {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", Self::NAME)
}
}
================================================
FILE: crates/anychain-bitcoin/src/network/dogecoin_testnet.rs
================================================
use crate::{BitcoinFormat, BitcoinNetwork, Prefix};
use anychain_core::no_std::*;
use anychain_core::{AddressError, Network, NetworkError};
use core::{fmt, str::FromStr};
use serde::Serialize;
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
pub struct DogecoinTestnet;
impl Network for DogecoinTestnet {
const NAME: &'static str = "dogecoin testnet";
}
pub static mut LOOP: u8 = 0;
impl BitcoinNetwork for DogecoinTestnet {
/// Returns the address prefix of the given network.
fn to_address_prefix(format: BitcoinFormat) -> Result<Prefix, AddressError> {
match format {
BitcoinFormat::P2PKH => Ok(Prefix::Version(0x71)),
BitcoinFormat::P2WSH => Ok(Prefix::Version(0x00)),
BitcoinFormat::P2SH_P2WPKH => Ok(Prefix::Version(0xc4)),
f => Err(AddressError::Message(format!(
"{} does not support address format {}",
Self::NAME,
f,
))),
}
}
/// Returns the network of the given address prefix.
fn from_address_prefix(prefix: Prefix) -> Result<Self, AddressError> {
match prefix {
Prefix::Version(version) => match version {
0x71 | 0xc4 => Ok(Self),
_ => Err(AddressError::Message(format!(
"Invalid version byte {:#0x} for {} network",
version,
Self::NAME,
))),
},
_ => Err(AddressError::Message(format!(
"{} does not support address format Bech32 or CashAddr",
Self::NAME,
))),
}
}
}
impl FromStr for DogecoinTestnet {
type Err = NetworkError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
Self::NAME => Ok(Self),
_ => Err(NetworkError::InvalidNetwork(s.into())),
}
}
}
impl fmt::Display for DogecoinTestnet {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", Self::NAME)
}
}
================================================
FILE: crates/anychain-bitcoin/src/network/litecoin.rs
================================================
use crate::{BitcoinFormat, BitcoinNetwork, Prefix};
use anychain_core::no_std::*;
use anychain_core::{AddressError, Network, NetworkError};
use core::{fmt, str::FromStr};
use serde::Serialize;
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
pub struct Litecoin;
impl Network for Litecoin {
const NAME: &'static str = "litecoin";
}
impl BitcoinNetwork for Litecoin {
/// Returns the address prefix of the given network.
fn to_address_prefix(format: BitcoinFormat) -> Result<Prefix, AddressError> {
match format {
BitcoinFormat::P2PKH => Ok(Prefix::Version(0x30)),
BitcoinFormat::P2WSH => Ok(Prefix::Version(0x00)),
BitcoinFormat::P2SH_P2WPKH => Ok(Prefix::Version(0x32)),
BitcoinFormat::Bech32 => Ok(Prefix::AddressPrefix("ltc".to_string())),
f => Err(AddressError::Message(format!(
"{} does not support address format {}",
Self::NAME,
f,
))),
}
}
/// Returns the network of the given address prefix.
fn from_address_prefix(prefix: Prefix) -> Result<Self, AddressError> {
match prefix {
Prefix::Version(version) => match version {
0x30 | 0x32 => Ok(Self),
_ => Err(AddressError::Message(format!(
"Invalid version byte {:#0x} for {} network",
version,
Self::NAME,
))),
},
Prefix::AddressPrefix(prefix) => match prefix.as_str() {
"ltc" => Ok(Self),
_ => Err(AddressError::Message(format!(
"Invalid Bech32 prefix for {} network",
Self::NAME,
))),
},
}
}
}
impl FromStr for Litecoin {
type Err = NetworkError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
Self::NAME => Ok(Self),
_ => Err(NetworkError::InvalidNetwork(s.into())),
}
}
}
impl fmt::Display for Litecoin {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", Self::NAME)
}
}
================================================
FILE: crates/anychain-bitcoin/src/network/litecoin_testnet.rs
================================================
use crate::{BitcoinFormat, BitcoinNetwork, Prefix};
use anychain_core::no_std::*;
use anychain_core::{AddressError, Network, NetworkError};
use core::{fmt, str::FromStr};
use serde::Serialize;
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
pub struct LitecoinTestnet;
impl Network for LitecoinTestnet {
const NAME: &'static str = "litecoin testnet";
}
impl BitcoinNetwork for LitecoinTestnet {
/// Returns the address prefix of the given network.
fn to_address_prefix(format: BitcoinFormat) -> Result<Prefix, AddressError> {
match format {
BitcoinFormat::P2PKH => Ok(Prefix::Version(0x6f)),
BitcoinFormat::P2WSH => Ok(Prefix::Version(0x00)),
BitcoinFormat::P2SH_P2WPKH => Ok(Prefix::Version(0x3a)),
BitcoinFormat::Bech32 => Ok(Prefix::AddressPrefix("tltc".to_string())),
f => Err(AddressError::Message(format!(
"{} does not support address format {}",
Self::NAME,
f,
))),
}
}
/// Returns the network of the given address prefix.
fn from_address_prefix(prefix: Prefix) -> Result<Self, AddressError> {
match prefix {
Prefix::Version(version) => match version {
0x6f | 0x3a => Ok(Self),
_ => Err(AddressError::Message(format!(
"Invalid version byte {:#0x} for {} network",
version,
Self::NAME,
))),
},
Prefix::AddressPrefix(prefix) => match prefix.as_str() {
"tltc" => Ok(Self),
_ => Err(AddressError::Message(format!(
"Invalid Bech32 prefix for {} network",
Self::NAME,
))),
},
}
}
}
impl FromStr for LitecoinTestnet {
type Err = NetworkError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
Self::NAME => Ok(Self),
_ => Err(NetworkError::InvalidNetwork(s.into())),
}
}
}
impl fmt::Display for LitecoinTestnet {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", Self::NAME)
}
}
================================================
FILE: crates/anychain-bitcoin/src/network/mod.rs
================================================
use crate::format::BitcoinFormat;
use anychain_core::no_std::*;
use anychain_core::{AddressError, Network};
pub mod bitcoin;
pub use self::bitcoin::*;
pub mod bitcoin_testnet;
pub use self::bitcoin_testnet::*;
pub mod bitcoincash;
pub use self::bitcoincash::*;
pub mod bitcoincash_testnet;
pub use self::bitcoincash_testnet::*;
pub mod litecoin;
pub use self::litecoin::*;
pub mod litecoin_testnet;
pub use self::litecoin_testnet::*;
pub mod dogecoin;
pub use self::dogecoin::*;
pub mod dogecoin_testnet;
pub use self::dogecoin_testnet::*;
/// The interface for a Bitcoin network.
pub trait BitcoinNetwork: Network {
/// Returns the address prefix of the given network.
fn to_address_prefix(format: BitcoinFormat) -> Result<Prefix, AddressError>;
/// Returns the network of the given address prefix.
fn from_address_prefix(prefix: Prefix) -> Result<Self, AddressError>;
}
#[derive(Clone)]
pub enum Prefix {
// address prefix of utxo compatible blockchains
AddressPrefix(String),
// version byte prepended to the hash160
Version(u8),
}
impl Prefix {
pub fn version(self) -> u8 {
if let Self::Version(version) = self {
version
} else {
panic!("Attempt to get version byte from an AddressPrefix");
}
}
pub fn prefix(self) -> String {
if let Self::AddressPrefix(prefix) = self {
prefix
} else {
panic!("Attempt to get prefix from a version");
}
}
pub fn from_version(version: u8) -> Self {
Self::Version(version)
}
pub fn from_prefix(prefix: &str) -> Self {
Self::AddressPrefix(prefix.to_string())
}
}
================================================
FILE: crates/anychain-bitcoin/src/public_key.rs
================================================
use crate::{BitcoinAddress, BitcoinFormat, BitcoinNetwork};
use anychain_core::{hex, Address, AddressError, PublicKey, PublicKeyError};
use core::{fmt, marker::PhantomData, str::FromStr};
/// Represents a Bitcoin public key
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BitcoinPublicKey<N: BitcoinNetwork> {
/// The ECDSA public key
public_key: libsecp256k1::PublicKey,
/// If true, the public key is serialized in compressed form
compressed: bool,
/// PhantomData
_network: PhantomData<N>,
}
impl<N: BitcoinNetwork> PublicKey for BitcoinPublicKey<N> {
type SecretKey = libsecp256k1::SecretKey;
type Address = BitcoinAddress<N>;
type Format = BitcoinFormat;
/// Returns the address corresponding to the given public key.
fn from_secret_key(secret_key: &Self::SecretKey) -> Self {
Self {
public_key: libsecp256k1::PublicKey::from_secret_key(secret_key),
compressed: true,
_network: PhantomData,
}
}
/// Returns the address of the corresponding private key.
fn to_address(&self, format: &Self::Format) -> Result<Self::Address, AddressError> {
Self::Address::from_public_key(self, format)
}
}
impl<N: BitcoinNetwork> BitcoinPublicKey<N> {
/// Returns a public key given a secp256k1 public key.
pub fn from_secp256k1_public_key(
public_key: libsecp256k1::PublicKey,
compressed: bool,
) -> Self {
Self {
public_key,
compressed,
_network: PhantomData,
}
}
/// Returns the secp256k1 public key of the public key.
pub fn to_secp256k1_public_key(&self) -> libsecp256k1::PublicKey {
self.public_key
}
/// Serialize the Bitcoin public key as a vector of u8
pub fn serialize(&self) -> Vec<u8> {
match self.compressed {
true => self.public_key.serialize_compressed().to_vec(),
false => self.public_key.serialize().to_vec(),
}
}
/// Returns `true` if the public key is in compressed form.
pub fn is_compressed(&self) -> bool {
self.compressed
}
}
impl<N: BitcoinNetwork> FromStr for BitcoinPublicKey<N> {
type Err = PublicKeyError;
fn from_str(public_key: &str) -> Result<Self, Self::Err> {
let compressed = public_key.len() == 66;
let p = hex::decode(public_key)
.map_err(|error| PublicKeyError::Crate("hex", format!("{:?}", error)))?;
let public_key = libsecp256k1::PublicKey::parse_slice(&p, None)
.map_err(|error| PublicKeyError::Crate("libsecp256k1", format!("{:?}", error)))?;
Ok(Self {
public_key,
compressed,
_network: PhantomData,
})
}
}
impl<N: BitcoinNetwork> fmt::Display for BitcoinPublicKey<N> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.compressed {
for s in &self.public_key.serialize_compressed()[..] {
write!(f, "{:02x}", s)?;
}
} else {
for s in &self.public_key.serialize()[..] {
write!(f, "{:02x}", s)?;
}
}
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::network::*;
fn test_to_address<N: BitcoinNetwork>(
expected_address: &BitcoinAddress<N>,
expected_format: &BitcoinFormat,
public_key: &BitcoinPublicKey<N>,
) {
let address = public_key.to_address(expected_format).unwrap();
assert_eq!(*expected_address, address);
}
fn test_from_str<N: BitcoinNetwork>(
expected_public_key: &str,
expected_address: &str,
expected_compressed: bool,
expected_format: &BitcoinFormat,
) {
let public_key = BitcoinPublicKey::<N>::from_str(expected_public_key).unwrap();
let address = public_key.to_address(expected_format).unwrap();
assert_eq!(expected_public_key, public_key.to_string());
assert_eq!(expected_compressed, public_key.compressed);
assert_eq!(expected_address, address.to_string());
assert_eq!(*expected_format, address.format());
}
fn test_to_str<N: BitcoinNetwork>(expected_public_key: &str, public_key: &BitcoinPublicKey<N>) {
assert_eq!(expected_public_key, public_key.to_string());
}
mod p2pkh_mainnet_compressed {
use super::*;
type N = Bitcoin;
const KEYPAIRS: [(&str, &str, &str); 5] = [
(
"L5hax5dZaByC3kJ4aLrZgnMXGSQReqRDYNqM1VAeXpqDRkRjX42H",
"039ed714bf521e96e3f3609b74da898e44d0fb64ba68c62c57852470ffc28e3db5",
"1uNM6oivjCJU2RcsNbfooVwcPjDRhjW7U",
),
(
"L4uNhZS86VLiKKGZZGNxwP7s67EfYfQ7S9bNnVfVbU9GBVVo2xoD",
"03a385ac59a31841764d55e7c8a243482a89073785524f0c45335afcf425d567b1",
"16sz5SMFeRfwaqY6wKzkiufwPmF1J7RhAx",
),
(
"KyH2BrThuUnzSXxDrDxQbpK277HxZfwPxVaCs5cwbzDEVNno2nts",
"028fa046ccfbb4ff134a5e0e8969d8085c6e2a1a52d793d351d4ddf02cd43d64b2",
"17QAwDwsLpehmCqSQXdHZb8vpsYVDnX7ic",
),
(
"KxEqpgCMencSHwiCG6xix9teUrB7JQNy2c7LKU56fZKZtP46nEca",
"02f7fb7e7d5dc97a5e1cd36b1ea3218234649f98f32cf08f45f8cd742860f676bf",
"1ESGcxbb96gQmJuEQsSapdk1jH6JaEnbU9",
),
(
"L2gCQPMpS5PqGvcBFMtYRT5S5jAo6WaNL1aPLvY2JkykkKSkqtm5",
"02aad3c8ee3dc6753a5284c97124f0047b2af0b91ba256b6262e07fcc2630f6b7f",
"1MRCogND3SKqa4xRZNpSC6iQxtwCpvmzfE",
),
];
#[test]
fn to_address() {
KEYPAIRS.iter().for_each(|(_, public_key, address)| {
let address = BitcoinAddress::<N>::from_str(address).unwrap();
let public_key = BitcoinPublicKey::<N>::from_str(public_key).unwrap();
test_to_address(&address, &BitcoinFormat::P2PKH, &public_key);
});
}
#[test]
fn from_str() {
KEYPAIRS
.iter()
.for_each(|(_, expected_public_key, expected_address)| {
test_from_str::<N>(
expected_public_key,
expected_address,
true,
&BitcoinFormat::P2PKH,
);
});
}
#[test]
fn to_str() {
KEYPAIRS.iter().for_each(|(_, expected_public_key, _)| {
let public_key = BitcoinPublicKey::<N>::from_str(expected_public_key).unwrap();
test_to_str(expected_public_key, &public_key);
});
}
}
mod p2pkh_mainnet_uncompressed {
use super::*;
type N = Bitcoin;
const KEYPAIRS: [(&str, &str, &str); 5] = [
(
"5KV26gjX4sYAkXvDnqZZuEyFUh1DKjgZ8wTKL7Fpm4ppJ8kpZQu",
"0489efe59c51e542f4cc7e2464ba3835d0a1a3daf351e70db57053c4712aca58796a933d1331078c364b94dd53aba2357a01f446c22efedcea8ebce2167a9e1df8",
"1KGHasyEpQZSHLea2GV3taTFZcw3uP7AAJ"
),
(
"5JUfnMYvM4g94psa1p2MUfQptbiouXYbb5oskjY7mZ151rXDFTi",
"04cf0ead0ea5df0700a4f063edf40397b377147d99f8f9404606e80dd931c819d2b571ab64754d27e69de5226f316e2dcab9f8b3b706d08104bcfe06f0e6dc7ff3",
"1Ja8ReiHyPwNdWHZdJZVN9ZV6cNzC8DbTy"
),
(
"5K2enrnWqJcQuHLeijT76YEqDagWo3cQLnPYk2CezrJ7A61QG5y",
"04a215f5764beef937296f6797407e51b8823eb418c3d65f48c0950ee775504c3539ca06ef419c7c70cbdf30930c25b5abb8040a89e089b786363c2bd78a07f464",
"1PvWPvCZV4mQACqXp3AsFvQHtyfq2eZG9c"
),
(
"5JnV7DtVZvwbVeRLvXQSzyg5WxMYJMEQbJk8VoYhzDTz4tawudY",
"04005e271fa3305bac32c5951fb84b35303b1231817e538aa5af6b145faae409a01f9e8c0330f4901577aacd43682fe2af39e69dcfaa7cff7390c006b3b66e90ad",
"1FCHrsTrzxJy3sq1pQKLBQojuvYyMBzs4g"
),
(
"5KVeWqioENjhaYZqXZX4nEfwEysJjXEvYfaeQx4pM2HK51ZW7Ur",
"04b6c8c8a6e9ad27366d8e6a0fa6c11f15ad7a8f15ac0c1d38c714df1f6b00b102773c7ebb0d718fc93808fdaf6c6b4ff6213909d50a94d5d6c8b472a9d1f30d99",
"1Hb6umXZs26hUZMt59nbkTAAfMpsmTkCBs"
)
];
#[test]
fn to_address() {
KEYPAIRS.iter().for_each(|(_, public_key, address)| {
let address = BitcoinAddress::<N>::from_str(address).unwrap();
let public_key = BitcoinPublicKey::<N>::from_str(public_key).unwrap();
test_to_address(&address, &BitcoinFormat::P2PKH, &public_key);
});
}
#[test]
fn from_str() {
KEYPAIRS
.iter()
.for_each(|(_, expected_public_key, expected_address)| {
test_from_str::<N>(
expected_public_key,
expected_address,
false,
&BitcoinFormat::P2PKH,
);
});
}
#[test]
fn to_str() {
KEYPAIRS.iter().for_each(|(_, expected_public_key, _)| {
let public_key = BitcoinPublicKey::<N>::from_str(expected_public_key).unwrap();
test_to_str(expected_public_key, &public_key);
});
}
}
mod p2pkh_testnet_compressed {
use super::*;
type N = BitcoinTestnet;
const KEYPAIRS: [(&str, &str, &str); 5] = [
(
"cNB6GpygWSZNRG5hotKjdAaNfgrzx984QYb2uj9rHpaCDkyy2aAz",
"02bc25a326a8fa59edd1a2adff51956ea3c61f404cff6e926225b3fe3b303561ac",
"mkerhifaLqJgAgrAjLomUStznPgVewNkka",
),
(
"cW4GQXEykwWJHVfRH8u25MzpzaU5XQDekdpdQbj9f9V7PLm25m4n",
"02e21263a700b22c16088dc45fb10d38cc8c4ebb4cdcb612e6551d972b60aa2446",
"n3NUsMjN3D6EWZ5nKZLvHnVwaAxfybQDq9",
),
(
"cSA6Mo1PYYK2uaDH22KoreQZdkSLobcrxZwnLcotDiYocCSjCVXy",
"0355210590fbe6dcb663c6166cd5cb169169e0d4bac76ce78d4ac29ddf683b2541",
"mzt1DhTJMzXarvJukPUxnfA1syVhDuZapf",
),
(
"cUVDoLpgXFYZGmjoyMusNEZJ174wk8ggjyH2Uo7L5nB1w5werAjX",
"0259b863ba239379d6ebee4074b6f9c9f7f23a581ff529aa8d1431d94cb2f3cd99",
"mxe1oRLS21dEqt6H77GPGUx59Zj4ucUBbc",
),
(
"cRhBWs3Bg9oXERSEY8GLaZjN7eb1FmkCnRdmwjCG2pVXVPUqXNiT",
"02826afccd44e32a9542f72a3a7753b99dbaf4a800bb70b6155510b1ce7a4bf607",
"mpvYGW4UNjYRaQ1adpE8ThYNXCVkWjhAPb",
),
];
#[test]
fn to_address() {
KEYPAIRS.iter().for_each(|(_, public_key, address)| {
let address = BitcoinAddress::<N>::from_str(address).unwrap();
let public_key = BitcoinPublicKey::<N>::from_str(public_key).unwrap();
test_to_address(&address, &BitcoinFormat::P2PKH, &public_key);
});
}
#[test]
fn from_str() {
KEYPAIRS
.iter()
.for_each(|(_, expected_public_key, expected_address)| {
test_from_str::<N>(
expected_public_key,
expected_address,
true,
&BitcoinFormat::P2PKH,
);
});
}
#[test]
fn to_str() {
KEYPAIRS.iter().for_each(|(_, expected_public_key, _)| {
let public_key = BitcoinPublicKey::<N>::from_str(expected_public_key).unwrap();
test_to_str(expected_public_key, &public_key);
});
}
}
mod p2pkh_testnet_uncompressed {
use super::*;
type N = BitcoinTestnet;
const KEYPAIRS: [(&str, &str, &str); 5] = [
(
"93W1kMkD1kAfevtDQ3LWortt8zjKqSSqonLxPvWFqg57arcwUru",
"048bb370869871417660abdacebf25f786e69c6e861b1c11346071cc9ad69690c2dc19fd3965455afc9a662feef3432b88cc99e31fa30ba93993ca21322e43e894",
"n4jx6NanXkXu7XSZrXBMKsFccxcp35UtJv"
),
(
"92FshhFbVnbtpbvpdzGmKEnNkToJnvm6L45LhDQqn1Kxjp8d4oR",
"04092301037dc083952053ccd320b5e12b30839fa0380d8a2c27547de4a527806962c5d1efc9e748cf6003fcc7ff0784caee9fa36d9b7ea330a613e4b71f8df0f9",
"n47WkmoSwebNXyvbkRdubZmFbGm5SbKh1A"
),
(
"92PbnSrnyLzS2HBNy4Vh2zg9hkVrztdxxDFihz92rBDyX25xF8N",
"043e8f6512364e73a695f2b14b284a1c58ca9cbac2d8dd7dcf15f135260e87f1d0f89270f5a8d76b4e611861d68c955dc1524df4c20bb080bf0c0f536383379f91",
"n3TWdpM742F8mxkcWQw8h2cifxyy82V2ov"
),
(
"92SbtaaCwUuHmzYGdi9xp5GbfUivbLHTAkqxeWaX88E1Q9HZJfs",
"0402acd5144558b5e779dead4c9e9b733e00b6e0554a243433bfccc730923a0beacd93f2b73c75f67d65fb830bde1cf101a8daea12ee3b659ef31fa274f52435d0",
"muFcYctkUkfWW55n2GMUafkw71kbZuduNv"
),
(
"91sSacE166SmPMoysEfZrQmM9aHgSfZbEfjmMf6nY8qBgvQMB1i",
"04c8d1e7d88969b4345c874f50af41b8d310dd666c0a3df52c46c238a345fbda73165fccdedffb67390e87e81040bff8415b8d7c5a6bbc441c89841cb74012501d",
"mwSgCKvDt3SoBxa3RZB1kXbxzX3oMvXxvT"
)
];
#[test]
fn to_address() {
KEYPAIRS.iter().for_each(|(_, public_key, address)| {
let address = BitcoinAddress::<N>::from_str(address).unwrap();
let public_key = BitcoinPublicKey::<N>::from_str(public_key).unwrap();
test_to_address(&address, &BitcoinFormat::P2PKH, &public_key);
});
}
#[test]
fn from_str() {
KEYPAIRS
.iter()
.for_each(|(_, expected_public_key, expected_address)| {
test_from_str::<N>(
expected_public_key,
expected_address,
false,
&BitcoinFormat::P2PKH,
);
});
}
#[test]
fn to_str() {
KEYPAIRS.iter().for_each(|(_, expected_public_key, _)| {
let public_key = BitcoinPublicKey::<N>::from_str(expected_public_key).unwrap();
test_to_str(expected_public_key, &public_key);
});
}
}
mod p2sh_p2wpkh_mainnet {
use super::*;
type N = Bitcoin;
const KEYPAIRS: [(&str, &str, &str); 5] = [
(
"KyTx39W9vjeGRRjvZna5bbFGEpuih9pG5KBnxUJN7bChpGHHZuJN",
"02468791fee1444df3a6e786e2f9da79198f8902387e1fa5a2c051950c4df51ab4",
"3QKTruktKRSmY3QfhoijwT1BU1npSGMQPG",
),
(
"L4EYurAwjsXiQrZ9XWdWdf5LDVAGAwGW58LtgZhGtR1cXUjS8oWD",
"024a185e896e5cf4cb0b441a18b5eac1a682e1848731449a5bb4c4a55c6d0fac3f",
"3JU5wvE4YrpZ5CgwpALBJB1C4YJjuZjXhj",
),
(
"KyMSREGeHw2fnaRhTn1Cq9HYot9QR9AyUX6z8RbRF5Zr98qdmTjJ",
"0337893947d9738d6d026bd5fa86d3c563ebc5840916d0ea50b143a83db7ef9de7",
"3NzBJJPE3gaq5T9bmLJR4iHhmSHTgJdus4",
),
(
"L5DtYc8LkDBQWWUAsWcgQZZqpVfUYCLyHZveGXKGT2hCS4pnnmqp",
"03eb86647457f2dfda66e7574d26cc4a6ecca472bc2ff331f333eb21614a0c58ee",
"3JUHwBJu1Figs4FesZPCgfBQKJC4GHjwPa",
),
(
"L4GoufTyWZoy1WDzRDacywokD28C7amVH9Jyfsyr8XZpR8Pog7gK",
"025195d4c21c7001103649f0bfb37f61a0da1e345e5847b005dbd10f0b7b7f9e6f",
"3L6rBuHhf3MzY1qEXMxeyY18bo8H8uKb4D",
),
];
#[test]
fn to_address() {
KEYPAIRS.iter().for_each(|(_, public_key, address)| {
let address = BitcoinAddress::<N>::from_str(address).unwrap();
let public_key = BitcoinPublicKey::<N>::from_str(public_key).unwrap();
test_to_address(&address, &BitcoinFormat::P2SH_P2WPKH, &public_key);
});
}
#[test]
fn from_str() {
KEYPAIRS
.iter()
.for_each(|(_, expected_public_key, expected_address)| {
test_from_str::<N>(
expected_public_key,
expected_address,
true,
&BitcoinFormat::P2SH_P2WPKH,
);
});
}
#[test]
fn to_str() {
KEYPAIRS.iter().for_each(|(_, expected_public_key, _)| {
let public_key = BitcoinPublicKey::<N>::from_str(expected_public_key).unwrap();
test_to_str(expected_public_key, &public_key);
});
}
}
mod p2sh_p2wpkh_testnet {
use super::*;
type N = BitcoinTestnet;
const KEYPAIRS: [(&str, &str, &str); 5] = [
(
"cPYtDeoeHg3wXp7hzcZ8Bu51HtN74yNdSDtdRuXamKCyzvU2oQM2",
"025718c5ebfbbb3566bf4757ca57822377eca9be9ace4d038052156dfe73f4c439",
"2Mt46mJZ8i7x2eiN77MekrD4UJg6GFt9mUh",
),
(
"cMyPKTkYyhZS9cvrxkJZKFLEtqML6suBuDyZfFKXqGeHvnEPaD3x",
"0236cd9b36cc3e08bf457ff6663b66d049ad942253d52bd5d939ea654d872bd5f3",
"2MvRwrFLhxfwP96t6z6Th28No4Va19fogj3",
),
(
"cTWWzheif86K9fouCo5gg1G4pEdGbLRrnHbY3uRr6AmhjKwNUrGh",
"021779b92c6a29c0bb554af8a059d51e08c900ca652fac13c1dab62da34016b722",
"2N1STUKnC6atTS2JttzdbP1891sCrD5i6xu",
),
(
"cV2L63nMM3WZwrU9EKFFP218XAQBhsDmEQ9uTw3vhMAz25Gna9nF",
"032a1af62e21831cc0951daf4f2e8f457bc59a4dc716e86f066b4de40020c9c8f1",
"2N8mGnLgSL8GUyDELStD4YVGawdai52ax9q",
),
(
"cTB6EeZgiGCziMQycbUCbn25AkipGACtY1Lyd1rAhGnTPEwHSHQT",
"027ebe9c4c3d976c490d34aad11d66558b052e6359925f8b33e51428dfdf59ad79",
"2N2JVpNUWsnV4MZMF11ewG2BVjhHoVNkv6K",
),
];
#[test]
fn to_address() {
KEYPAIRS.iter().for_each(|(_, public_key, address)| {
let address = BitcoinAddress::<N>::from_str(address).unwrap();
let public_key = BitcoinPublicKey::<N>::from_str(public_key).unwrap();
test_to_address(&address, &BitcoinFormat::P2SH_P2WPKH, &public_key);
});
}
#[test]
fn from_str() {
KEYPAIRS
.iter()
.for_each(|(_, expected_public_key, expected_address)| {
test_from_str::<N>(
expected_public_key,
expected_address,
true,
&BitcoinFormat::P2SH_P2WPKH,
);
});
}
#[test]
fn to_str() {
KEYPAIRS.iter().for_each(|(_, expected_public_key, _)| {
let public_key = BitcoinPublicKey::<N>::from_str(expected_public_key).unwrap();
test_to_str(expected_public_key, &public_key);
});
}
}
#[test]
fn test_p2pkh_invalid() {
type N = Bitcoin;
// Invalid public key length
let public_key = "0";
assert!(BitcoinPublicKey::<N>::from_str(public_key).is_err());
let public_key = "039ed714bf521e96e3f3609b74da898e44";
assert!(BitcoinPublicKey::<N>::from_str(public_key).is_err());
let public_key = "039ed714bf521e96e3f3609b74da898e44d0fb64ba68c62c57852470ffc28e3db";
assert!(BitcoinPublicKey::<N>::from_str(public_key).is_err());
let public_key =
"039ed714bf521e96e3f3609b74da898e44d0fb64ba68c62c57852470ffc28e3db5039ed714bf521e96e3f3609b74da898e44";
assert!(BitcoinPublicKey::<N>::from_str(public_key).is_err());
let public_key = "039ed714bf521e96e3f3609b74da898e44d0fb64ba68c62c57852470ffc28e3db5039ed714bf521e96e3f3609b74da898e44d0fb64ba68c62c57852470ffc28e3db5";
assert!(BitcoinPublicKey::<N>::from_str(public_key).is_err());
}
#[test]
fn test_p2sh_p2wpkh_invalid() {
type N = Bitcoin;
// Invalid public key length
let public_key = "0";
assert!(BitcoinPublicKey::<N>::from_str(public_key).is_err());
let public_key = "02468791fee1444df3a6e786e2f9da79198";
assert!(BitcoinPublicKey::<N>::from_str(public_key).is_err());
let public_key = "02468791fee1444df3a6e786e2f9da79198f8902387e1fa5a2c051950c4df51ab";
assert!(BitcoinPublicKey::<N>::from_str(public_key).is_err());
let public_key =
"02468791fee1444df3a6e786e2f9da79198f8902387e1fa5a2c051950c4df51ab402468791fee1444df3a6e786e2f9da79198";
assert!(BitcoinPublicKey::<N>::from_str(public_key).is_err());
let public_key = "02468791fee1444df3a6e786e2f9da79198f8902387e1fa5a2c051950c4df51ab402468791fee1444df3a6e786e2f9da79198f8902387e1fa5a2c051950c4df51ab4";
assert!(BitcoinPublicKey::<N>::from_str(public_key).is_err());
}
}
================================================
FILE: crates/anychain-bitcoin/src/transaction.rs
================================================
use crate::{
BitcoinAddress, BitcoinAmount, BitcoinFormat, BitcoinNetwork, BitcoinPublicKey, WitnessProgram,
BASE32_DECODE_TABLE,
};
use anychain_core::{
crypto::checksum as double_sha2, Transaction, TransactionError, TransactionId,
};
use anychain_core::{
hex,
no_std::{io::Read, *},
PublicKey,
};
use libsecp256k1::Signature;
use base58::FromBase58;
use bech32::{u5, FromBase32};
use core::{fmt, str::FromStr};
use serde::Serialize;
pub use sha2::{Digest, Sha256};
/// Returns the variable length integer of the given value.
/// `<https://en.bitcoin.it/wiki/Protocol_documentation#Variable_length_integer>`
pub fn variable_length_integer(value: u64) -> Result<Vec<u8>, TransactionError> {
match value {
// bounded by u8::max_value()
0..=252 => Ok(vec![value as u8]),
// bounded by u16::max_value()
253..=65535 => Ok([vec![0xfd], (value as u16).to_le_bytes().to_vec()].concat()),
// bounded by u32::max_value()
65536..=4294967295 => Ok([vec![0xfe], (value as u32).to_le_bytes().to_vec()].concat()),
// bounded by u64::max_value()
_ => Ok([vec![0xff], value.to_le_bytes().to_vec()].concat()),
}
}
/// Decode the value of a variable length integer.
/// `<https://en.bitcoin.it/wiki/Protocol_documentation#Variable_length_integer>`
pub fn read_variable_length_integer<R: Read>(mut reader: R) -> Result<usize, TransactionError> {
let mut flag = [0u8; 1];
let _ = reader.read(&mut flag)?;
match flag[0] {
0..=252 => Ok(flag[0] as usize),
0xfd => {
let mut size = [0u8; 2];
let _ = reader.read(&mut size)?;
match u16::from_le_bytes(size) {
s if s < 253 => Err(TransactionError::InvalidVariableSizeInteger(s as usize)),
s => Ok(s as usize),
}
}
0xfe => {
let mut size = [0u8; 4];
let _ = reader.read(&mut size)?;
match u32::from_le_bytes(size) {
s if s < 65536 => Err(TransactionError::InvalidVariableSizeInteger(s as usize)),
s => Ok(s as usize),
}
}
_ => {
let mut size = [0u8; 8];
let _ = reader.read(&mut size)?;
match u64::from_le_bytes(size) {
s if s < 4294967296 => {
Err(TransactionError::InvalidVariableSizeInteger(s as usize))
}
s => Ok(s as usize),
}
}
}
}
pub struct BitcoinVector;
impl BitcoinVector {
/// Read and output a vector with a variable length integer
pub fn read<R: Read, E, F>(mut reader: R, func: F) -> Result<Vec<E>, TransactionError>
where
F: Fn(&mut R) -> Result<E, TransactionError>,
{
let count = read_variable_length_integer(&mut reader)?;
(0..count).map(|_| func(&mut reader)).collect()
}
/// Read and output a vector with a variable length integer and the integer itself
pub fn read_witness<R: Read, E, F>(
mut reader: R,
func: F,
) -> Result<(usize, Result<Vec<E>, TransactionError>), TransactionError>
where
F: Fn(&mut R) -> Result<E, TransactionError>,
{
let count = read_variable_length_integer(&mut reader)?;
Ok((count, Self::read(reader, func)))
}
}
/// Generate the script_pub_key of a corresponding address
pub fn create_script_pub_key<N: BitcoinNetwork>(
address: &BitcoinAddress<N>,
) -> Result<Vec<u8>, TransactionError> {
match address.format() {
BitcoinFormat::P2PKH => {
let bytes = &address.to_string().from_base58()?;
// Trim the prefix (1st byte) and the checksum (last 4 bytes)
let pub_key_hash = bytes[1..(bytes.len() - 4)].to_vec();
let mut script = vec![];
script.push(Opcode::OP_DUP as u8);
script.push(Opcode::OP_HASH160 as u8);
script.extend(variable_length_integer(pub_key_hash.len() as u64)?);
script.extend(pub_key_hash);
script.push(Opcode::OP_EQUALVERIFY as u8);
script.push(Opcode::OP_CHECKSIG as u8);
Ok(script)
}
BitcoinFormat::P2SH_P2WPKH => {
let script_bytes = &address.to_string().from_base58()?;
let script_hash = script_bytes[1..(script_bytes.len() - 4)].to_vec();
let mut script = vec![];
script.push(Opcode::OP_HASH160 as u8);
script.extend(variable_length_integer(script_hash.len() as u64)?);
script.extend(script_hash);
script.push(Opcode::OP_EQUAL as u8);
Ok(script)
}
BitcoinFormat::P2WSH => {
let (_, data, _) = bech32::decode(&address.to_string())?;
let (v, script) = data.split_at(1);
let script = Vec::from_base32(script)?;
let mut script_bytes = vec![v[0].to_u8(), script.len() as u8];
script_bytes.extend(script);
Ok(script_bytes)
}
BitcoinFormat::Bech32 => {
let (_, data, _) = bech32::decode(&address.to_string())?;
let (v, program) = data.split_at(1);
let program = Vec::from_base32(program)?;
let mut program_bytes = vec![v[0].to_u8(), program.len() as u8];
program_bytes.extend(program);
Ok(WitnessProgram::new(&program_bytes)?.to_scriptpubkey())
}
BitcoinFormat::CashAddr => {
let address = address.to_string();
let prefix = N::to_address_prefix(BitcoinFormat::CashAddr)?.prefix();
let start = if address.starts_with(&prefix) {
prefix.len() + 1
} else {
0
};
// trim the prefix and the checksum
let bytes_u8 = address.as_bytes()[start..address.len() - 8].to_vec();
let bytes_u5: Vec<u5> = bytes_u8
.iter()
.map(|byte| u5::try_from_u8(BASE32_DECODE_TABLE[*byte as usize] as u8).unwrap())
.collect();
let payload = Vec::<u8>::from_base32(&bytes_u5)?;
// trim the version byte, left the public key hash
let hash = payload[1..].to_vec();
let mut script = vec![];
script.push(Opcode::OP_DUP as u8);
script.push(Opcode::OP_HASH160 as u8);
script.extend(variable_length_integer(hash.len() as u64)?);
script.extend(hash);
script.push(Opcode::OP_EQUALVERIFY as u8);
script.push(Opcode::OP_CHECKSIG as u8);
Ok(script)
}
}
}
/// Construct and return the OP_RETURN script for the data
/// output of a tx that spends 'amount' basic units of omni
/// layer asset as indicated by 'property_id'.
pub fn create_script_op_return(property_id: u32, amount: i64) -> Result<Vec<u8>, TransactionError> {
let mut script = vec![];
let msg_type: u16 = 0;
let msg_version: u16 = 0;
script.push(Opcode::OP_RETURN as u8);
script.push(Opcode::OP_PUSHBYTES_20 as u8);
script.push(b'o');
script.push(b'm');
script.push(b'n');
script.push(b'i');
script.append(&mut msg_version.to_be_bytes().to_vec());
script.append(&mut msg_type.to_be_bytes().to_vec());
script.append(&mut property_id.to_be_bytes().to_vec());
script.append(&mut amount.to_be_bytes().to_vec());
Ok(script)
}
/// Represents a Bitcoin signature hash
/// `<https://en.bitcoin.it/wiki/OP_CHECKSIG>`
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
#[allow(non_camel_case_types)]
pub enum SignatureHash {
/// Signs all inputs and outputs.
SIGHASH_ALL = 0x01,
/// Signs all inputs and none of the outputs.
/// (e.g. "blank check" transaction, where any address can redeem the output)
SIGHASH_NONE = 0x02,
/// Signs all inputs and one corresponding output per input.
/// (e.g. signing vin 0 will result in signing vout 0)
SIGHASH_SINGLE = 0x03,
SIGHASH_ALL_SIGHASH_FORKID = 0x41,
SIGHASH_NONE_SIGHASH_FORKID = 0x42,
SIGHASH_SINGLE_SIGHASH_FORKID = 0x43,
/// Signs only one input and all outputs.
/// Allows anyone to add or remove other inputs, forbids changing any outputs.
/// (e.g. "crowdfunding" transaction, where the output is the "goal" address)
SIGHASH_ALL_SIGHASH_ANYONECANPAY = 0x81,
/// Signs only one input and none of the outputs.
/// Allows anyone to add or remove other inputs or any outputs.
/// (e.g. "dust collector" transaction, where "dust" can be aggregated and spent together)
SIGHASH_NONE_SIGHASH_ANYONECANPAY = 0x82,
/// Signs only one input and one corresponding output per input.
/// Allows anyone to add or remove other inputs.
SIGHASH_SINGLE_SIGHASH_ANYONECANPAY = 0x83,
SIGHASH_ALL_SIGHASH_FORKID_SIGHASH_ANYONECANPAY = 0xc1,
SIGHASH_NONE_SIGHASH_FORKID_SIGHASH_ANYONECANPAY = 0xc2,
SIGHASH_SINGLE_SIGHASH_FORKID_SIGHASH_ANYONECANPAY = 0xc3,
}
impl fmt::Display for SignatureHash {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
SignatureHash::SIGHASH_ALL => write!(f, "SIGHASH_ALL"),
SignatureHash::SIGHASH_NONE => write!(f, "SIGHASH_NONE"),
SignatureHash::SIGHASH_SINGLE => write!(f, "SIGHASH_SINGLE"),
SignatureHash::SIGHASH_ALL_SIGHASH_FORKID => {
write!(f, "SIGHASH_ALL | SIGHASH_FORKID")
}
SignatureHash::SIGHASH_NONE_SIGHASH_FORKID => {
write!(f, "SIGHASH_NONE | SIGHASH_FORKID")
}
SignatureHash::SIGHASH_SINGLE_SIGHASH_FORKID => {
write!(f, "SIGHASH_SINGLE | SIGHASH_FORKID")
}
SignatureHash::SIGHASH_ALL_SIGHASH_ANYONECANPAY => {
write!(f, "SIGHASH_ALL | SIGHASH_ANYONECANPAY")
}
SignatureHash::SIGHASH_NONE_SIGHASH_ANYONECANPAY => {
write!(f, "SIGHASH_NONE | SIGHASH_ANYONECANPAY")
}
SignatureHash::SIGHASH_SINGLE_SIGHASH_ANYONECANPAY => {
write!(f, "SIGHASH_SINGLE | SIGHASH_ANYONECANPAY")
}
SignatureHash::SIGHASH_ALL_SIGHASH_FORKID_SIGHASH_ANYONECANPAY => {
write!(f, "SIGHASH_ALL | SIGHASH_FORKID | SIGHASH_ANYONECANPAY")
}
SignatureHash::SIGHASH_NONE_SIGHASH_FORKID_SIGHASH_ANYONECANPAY => {
write!(f, "SIGHASH_NONE | SIGHASH_FORKID | SIGHASH_ANYONECANPAY")
}
SignatureHash::SIGHASH_SINGLE_SIGHASH_FORKID_SIGHASH_ANYONECANPAY => {
write!(f, "SIGHASH_SINGLE | SIGHASH_FORKID | SIGHASH_ANYONECANPAY")
}
}
}
}
impl SignatureHash {
pub fn from_byte(byte: &u8) -> Self {
match byte {
0x02 => SignatureHash::SIGHASH_NONE,
0x03 => SignatureHash::SIGHASH_SINGLE,
0x41 => SignatureHash::SIGHASH_ALL_SIGHASH_FORKID,
0x42 => SignatureHash::SIGHASH_NONE_SIGHASH_FORKID,
0x43 => SignatureHash::SIGHASH_SINGLE_SIGHASH_FORKID,
0x81 => SignatureHash::SIGHASH_ALL_SIGHASH_ANYONECANPAY,
0x82 => SignatureHash::SIGHASH_NONE_SIGHASH_ANYONECANPAY,
0x83 => SignatureHash::SIGHASH_SINGLE_SIGHASH_ANYONECANPAY,
0xc1 => SignatureHash::SIGHASH_ALL_SIGHASH_FORKID_SIGHASH_ANYONECANPAY,
0xc2 => SignatureHash::SIGHASH_NONE_SIGHASH_FORKID_SIGHASH_ANYONECANPAY,
0xc3 => SignatureHash::SIGHASH_SINGLE_SIGHASH_FORKID_SIGHASH_ANYONECANPAY,
_ => SignatureHash::SIGHASH_ALL,
}
}
}
/// Represents the commonly used script opcodes
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize)]
#[allow(non_camel_case_types)]
pub enum Opcode {
OP_DUP = 0x76,
OP_HASH160 = 0xa9,
OP_CHECKSIG = 0xac,
OP_EQUAL = 0x87,
OP_EQUALVERIFY = 0x88,
OP_RETURN = 0x6a,
OP_PUSHBYTES_20 = 0x14,
}
impl fmt::Display for Opcode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Opcode::OP_DUP => write!(f, "OP_DUP"),
Opcode::OP_HASH160 => write!(f, "OP_HASH160"),
Opcode::OP_CHECKSIG => write!(f, "OP_CHECKSIG"),
Opcode::OP_EQUAL => write!(f, "OP_EQUAL"),
Opcode::OP_EQUALVERIFY => write!(f, "OP_EQUALVERIFY"),
Opcode::OP_RETURN => write!(f, "OP_RETURN"),
Opcode::OP_PUSHBYTES_20 => write!(f, "OP_PUSHBYTES_20"),
}
}
}
/// Represents a Bitcoin transaction outpoint
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Outpoint {
/// Hash of the previous transaction (32 bytes) (uses reversed hash order from Bitcoin RPC)
pub reverse_transaction_id: Vec<u8>,
/// The index of certain utxo in the previous transaction (4 bytes)
pub index: u32,
}
impl Outpoint {
/// Returns a new Bitcoin transaction outpoint
pub fn new(reverse_transaction_id: Vec<u8>, index: u32) -> Self {
Self {
reverse_transaction_id,
index,
}
}
}
/// Represents a Bitcoin transaction input
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BitcoinTransactionInput<N: BitcoinNetwork> {
/// The outpoint (36 bytes)
pub outpoint: Outpoint,
/// The balance of the utxo pointed by this input (used for SegWit transaction signatures)
pub balance: Option<BitcoinAmount>,
/// The address of the utxo pointed by this input
pub address: Option<BitcoinAddress<N>>,
/// The address format of the utxo pointed by this input
pub format: Option<BitcoinFormat>,
/// The 'scriptPubkey' of the utxo pointed by this input
pub script_pub_key: Option<Vec<u8>>,
/// An optional redeem script in case of an SegWit utxo
pub redeem_script: Option<Vec<u8>>,
/// The transaction input script (variable size)
pub script_sig: Vec<u8>,
/// The sequence number (4 bytes) (0xFFFFFFFF unless lock > 0)
/// Also used in replace-by-fee (BIP 125)
pub sequence: Vec<u8>,
/// The signature hash (4 bytes) (used in signing raw transaction only)
pub sighash_code: SignatureHash,
/// The witnesses in a SegWit transaction
pub witnesses: Vec<Vec<u8>>,
/// If true, the input has been signed
pub is_signed: bool,
/// Provide more flexibility for multiple signatures (for P2WSH)
pub additional_witness: Option<(Vec<u8>, bool)>,
/// Option for additional witness stack script args
pub witness_script_data: Option<Vec<u8>>,
}
impl<N: BitcoinNetwork> BitcoinTransactionInput<N> {
const DEFAULT_SEQUENCE: [u8; 4] = [0xf2, 0xff, 0xff, 0xff];
/// Returns a new Bitcoin transaction input.
pub fn new(
transaction_id: Vec<u8>,
index: u32,
public_key: Option<BitcoinPublicKey<N>>,
format: Option<BitcoinFormat>,
address: Option<BitcoinAddress<N>>,
balance: Option<BitcoinAmount>,
sighash: SignatureHash,
) -> Result<Self, TransactionError> {
if transaction_id.len() != 32 {
return Err(TransactionError::InvalidTransactionId(transaction_id.len()));
}
// Byte-wise reverse of computed SHA-256 hash values
// https://bitcoin.org/en/developer-reference#hash-byte-order
let mut reverse_transaction_id = transaction_id;
reverse_transaction_id.reverse();
let format = match format {
Some(f) => Some(f),
None => Some(BitcoinFormat::P2PKH),
};
let (address, script_pub_key, redeem_script) = match public_key {
Some(pk) => {
let addr = pk.to_address(&format.clone().unwrap())?;
if let Some(v) = address {
if v != addr {
return Err(TransactionError::Message(format!(
"Provided address {} does not match the provided public key {}",
addr, pk,
)));
}
}
let script_pub_key = create_script_pub_key(&addr)?;
let redeem_script = match format {
Some(BitcoinFormat::P2SH_P2WPKH) => {
Some(BitcoinAddress::<N>::create_redeem_script(&pk).to_vec())
}
_ => None,
};
(Some(addr), Some(script_pub_key), redeem_script)
}
None => match address {
Some(addr) => {
let script_pub_key = create_script_pub_key(&addr)?;
(Some(addr), Some(script_pub_key), None)
}
None => (None, None, None),
},
};
Ok(Self {
outpoint: Outpoint::new(reverse_transaction_id, index),
balance,
address,
format,
script_pub_key,
redeem_script,
script_sig: vec![],
sequence: BitcoinTransactionInput::<N>::DEFAULT_SEQUENCE.to_vec(),
sighash_code: sighash,
witnesses: vec![],
is_signed: false,
additional_witness: None,
witness_script_data: None,
})
}
pub fn set_public_key(
&mut self,
public_key: BitcoinPublicKey<N>,
format: BitcoinFormat,
) -> Result<(), TransactionError> {
let address = public_key.to_address(&format)?;
self.format = Some(format.clone());
self.script_pub_key = Some(create_script_pub_key(&address)?);
self.address = Some(address);
self.redeem_script = match format {
BitcoinFormat::P2SH_P2WPKH => {
Some(BitcoinAddress::<N>::create_redeem_script(&public_key).to_vec())
}
_ => None,
};
Ok(())
}
pub fn set_redeem_script(&mut self, redeem_script: Vec<u8>) -> Result<(), TransactionError> {
self.redeem_script = Some(redeem_script);
Ok(())
}
pub fn set_format(&mut self, format: BitcoinFormat) -> Result<(), TransactionError> {
self.format = Some(format);
Ok(())
}
pub fn set_balance(&mut self, balance: i64) -> Result<(), TransactionError> {
self.balance = Some(BitcoinAmount(balance));
Ok(())
}
pub fn set_sequence(&mut self, sequence: u32) -> Result<(), TransactionError> {
self.sequence = u32::to_le_bytes(sequence).to_vec();
Ok(())
}
pub fn set_sighash(&mut self, sighash: SignatureHash) -> Result<(), TransactionError> {
self.sighash_code = sighash;
Ok(())
}
pub fn get_address(&self) -> Option<BitcoinAddress<N>> {
self.address.clone()
}
pub fn get_format(&self) -> Option<BitcoinFormat> {
self.format.clone()
}
pub fn get_balance(&self) -> Option<BitcoinAmount> {
self.balance
}
pub fn get_sequence(&self) -> u32 {
let sequence: [u8; 4] = self.sequence.clone().try_into().unwrap();
u32::from_le_bytes(sequence)
}
pub fn get_sighash(&self) -> SignatureHash {
self.sighash_code
}
/// Read and output a Bitcoin transaction input
pub fn read<R: Read>(mut reader: &mut R) -> Result<Self, TransactionError> {
let mut transaction_hash = [0u8; 32];
let mut vin = [0u8; 4];
let mut sequence = [0u8; 4];
let _ = reader.read(&mut transaction_hash)?;
let _ = reader.read(&mut vin)?;
let outpoint = Outpoint::new(transaction_hash.to_vec(), u32::from_le_bytes(vin));
let script_sig: Vec<u8> = BitcoinVector::read(&mut reader, |s| {
let mut byte = [0u8; 1];
let _ = s.read(&mut byte)?;
Ok(byte[0])
})?;
let _ = reader.read(&mut sequence)?;
let script_sig_len = read_variable_length_integer(&script_sig[..])?;
let sighash_code = SignatureHash::from_byte(&match script_sig_len {
0 => 0x01,
length => script_sig[length],
});
Ok(Self {
outpoint,
balance: None,
address: None,
format: None,
script_pub_key: None,
redeem_script: None,
script_sig: script_sig.to_vec(),
sequence: sequence.to_vec(),
sighash_code,
witnesses: vec![],
is_signed: !script_sig.is_empty(),
additional_witness: None,
witness_script_data: None,
})
}
/// Returns the serialized transaction input.
pub fn serialize(&self, raw: bool) -> Result<Vec<u8>, TransactionError> {
let mut input = vec![];
input.extend(&self.outpoint.reverse_transaction_id);
input.extend(&self.outpoint.index.to_le_bytes());
match raw {
true => input.extend(vec![0x00]),
false => match self.script_sig.len() {
0 => match &self.address {
Some(address) => match address.format() {
BitcoinFormat::P2PKH => {
let script_pub_key = match &self.script_pub_key {
Some(script) => script,
None => {
return Err(TransactionError::MissingOutpointScriptPublicKey)
}
};
input.extend(variable_length_integer(script_pub_key.len() as u64)?);
input.extend(script_pub_key);
}
_ => input.extend(vec![0x00]),
},
None => input.extend(vec![0x00]),
},
_ => {
input.extend(variable_length_integer(self.script_sig.len() as u64)?);
input.extend(&self.script_sig);
}
},
};
input.extend(&self.sequence);
Ok(input)
}
/// Insert 'signature' and 'public_key' into this input to make it signed
pub fn sign(
&mut self,
signature: Vec<u8>,
public_key: Vec<u8>,
) -> Result<(), TransactionError> {
let mut signature = Signature::parse_standard_slice(&signature)
.map_err(|error| TransactionError::Crate("libsecp256k1", format!("{:?}", error)))?
.serialize_der()
.as_ref()
.to_vec();
signature.push(self.sighash_code as u8);
let signature = [variable_length_integer(signature.len() as u64)?, signature].concat();
let public_key = [
variable_length_integer(public_key.len() as u64)?,
public_key,
]
.concat();
match self.get_format().unwrap() {
BitcoinFormat::P2PKH | BitcoinFormat::CashAddr => {
self.script_sig = [signature, public_key].concat()
}
BitcoinFormat::P2SH_P2WPKH => {
let input_script = match &self.redeem_script {
Some(script) => script.clone(),
None => {
return Err(TransactionError::Message(
"Missing redeem script".to_string(),
))
}
};
self.script_sig = [
variable_length_integer(input_script.len() as u64)?,
input_script,
]
.concat();
self.witnesses.append(&mut vec![signature, public_key]);
}
BitcoinFormat::Bech32 => self.witnesses.append(&mut vec![signature, public_key]),
BitcoinFormat::P2WSH => {
return Err(TransactionError::Message(
"P2WSH signing not supported".to_string(),
))
}
}
self.is_signed = true;
Ok(())
}
}
/// Represents a Bitcoin transaction output
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct BitcoinTransactionOutput {
/// The amount (in Satoshi)
pub amount: BitcoinAmount,
/// The public key script
pub script_pub_key: Vec<u8>,
}
impl BitcoinTransactionOutput {
/// Returns a Bitcoin transaction output.
pub fn new<N: BitcoinNetwork>(
address: BitcoinAddress<N>,
amount: BitcoinAmount,
) -> Result<Self, TransactionError> {
Ok(Self {
amount,
script_pub_key: create_script_pub_key::<N>(&address)?,
})
}
/// Returns the data output for a tx that spends 'amount' basic
/// units of omni-layer asset as indicated by 'property_id'.
pub fn omni_data_output(
property_id: u32,
amount: BitcoinAmount,
) -> Result<Self, TransactionError> {
let data_output = BitcoinTransactionOutput {
amount: BitcoinAmount(0),
script_pub_key: create_script_op_return(property_id, amount.0)?,
};
Ok(data_output)
}
/// Read and output a Bitcoin transaction output
pub fn read<R: Read>(mut reader: &mut R) -> Result<Self, TransactionError> {
let mut amount = [0u8; 8];
let _ = reader.read(&mut amount)?;
let script_pub_key: Vec<u8> = BitcoinVector::read(&mut reader, |s| {
let mut byte = [0u8; 1];
let _ = s.read(&mut byte)?;
Ok(byte[0])
})?;
Ok(Self {
amount: BitcoinAmount::from_satoshi(u64::from_le_bytes(amount) as i64)?,
script_pub_key,
})
}
/// Returns the serialized transaction output.
pub fn serialize(&self) -> Result<Vec<u8>, TransactionError> {
let mut output = vec![];
output.extend(&self.amount.0.to_le_bytes());
output.extend(variable_length_integer(self.script_pub_key.len() as u64)?);
output.extend(&self.script_pub_key);
Ok(output)
}
}
/// Represents an Bitcoin transaction id and witness transaction id
/// `<https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#transaction-id>`
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct BitcoinTransactionId {
pub txid: Vec<u8>,
pub wtxid: Vec<u8>,
}
impl TransactionId for BitcoinTransactionId {}
impl fmt::Display for BitcoinTransactionId {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", &hex::encode(&self.txid))
}
}
/// Represents the Bitcoin transaction parameters
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BitcoinTransactionParameters<N: BitcoinNetwork> {
/// The version number (4 bytes)
pub version: u32,
/// The transaction inputs
pub inputs: Vec<BitcoinTransactionInput<N>>,
/// The transaction outputs
pub outputs: Vec<BitcoinTransactionOutput>,
/// The lock time (4 bytes)
pub lock_time: u32,
/// An optional 2 bytes to indicate SegWit transactions
pub segwit_flag: bool,
}
impl<N: BitcoinNetwork> BitcoinTransactionParameters<N> {
/// Returns a BitcoinTransactionParameters given the inputs and outputs
pub fn new(
inputs: Vec<BitcoinTransactionInput<N>>,
outputs: Vec<BitcoinTransactionOutput>,
) -> Result<Self, TransactionError> {
Ok(Self {
version: 2,
inputs,
outputs,
lock_time: 0,
segwit_flag: false,
})
}
/// Read and output the Bitcoin transaction parameters
pub fn read<R: Read>(mut reader: R) -> Result<Self, TransactionError> {
let mut version = [0u8; 4];
let _ = reader.read(&mut version)?;
let mut inputs = BitcoinVector::read(&mut reader, BitcoinTransactionInput::<N>::read)?;
let segwit_flag = match inputs.is_empty() {
true => {
let mut flag = [0u8; 1];
let _ = reader.read(&mut flag)?;
match flag[0] {
1 => {
inputs =
BitcoinVector::read(&mut reader, BitcoinTransactionInput::<N>::read)?;
true
}
_ => return Err(TransactionError::InvalidSegwitFlag(flag[0] as usize)),
}
}
false => false,
};
let outputs = BitcoinVector::read(&mut reader, BitcoinTransactionOutput::read)?;
// if segwit_flag {
// for input in &mut inputs {
// let witnesses: Vec<Vec<u8>> = BitcoinVector::read(&mut reader, |s| {
// let (size, witness) = BitcoinVector::read_witness(s, |sr| {
// let mut byte = [0u8; 1];
// let _ = sr.read(&mut byte)?;
// Ok(byte[0])
// })?;
// Ok([variable_length_integer(size as u64)?, witness?].concat())
// })?;
// if !witnesses.is_empty() {
// input.sighash_code =
// SignatureHash::from_byte(&witnesses[0][&witnesses[0].len() - 1]);
// input.is_signed = true;
// }
// input.witnesses = witnesses;
// }
// }
let params = BitcoinTransactionParameters::<N> {
version: u32::from_le_bytes(version),
inputs,
outputs,
lock_time: 0,
segwit_flag,
};
Ok(params)
}
}
/// Represents a Bitcoin transaction
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BitcoinTransaction<N: BitcoinNetwork> {
/// The transaction parameters (version, inputs, outputs, lock_time, segwit_flag)
pub parameters: BitcoinTransactionParameters<N>,
}
impl<N: BitcoinNetwork> fmt::Display for BitcoinTransaction<N> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", hex::encode(self.to_bytes().unwrap()))
}
}
impl<N: BitcoinNetwork> Transaction for BitcoinTransaction<N> {
type Address = BitcoinAddress<N>;
type Format = BitcoinFormat;
type PublicKey = BitcoinPublicKey<N>;
type TransactionId = BitcoinTransactionId;
type TransactionParameters = BitcoinTransactionParameters<N>;
/// Returns an unsigned transaction given the transaction parameters.
fn new(parameters: &Self::TransactionParameters) -> Result<Self, TransactionError> {
Ok(Self {
parameters: parameters.clone(),
})
}
/// Returns a transaction given the transaction bytes.
/// Note:: Raw transaction hex does not include enough
fn from_bytes(transaction: &[u8]) -> Result<Self, TransactionError> {
Ok(Self {
parameters: Self::TransactionParameters::read(transaction)?,
})
}
/// Returns the transaction in bytes.
fn to_bytes(&self) -> Result<Vec<u8>, TransactionError> {
let mut transaction = self.parameters.version.to_le_bytes().to_vec();
if self.parameters.segwit_flag {
transaction.extend(vec![0x00, 0x01]);
}
transaction.extend(variable_length_integer(self.parameters.inputs.len() as u64)?);
let mut has_witness = false;
for input in &self.parameters.inputs {
if !has_witness {
has_witness = !input.witnesses.is_empty();
}
transaction.extend(input.serialize(!input.is_signed)?);
}
transaction.extend(variable_length_integer(
self.parameters.outputs.len() as u64
)?);
for output in &self.parameters.outputs {
transaction.extend(output.serialize()?);
}
if has_witness {
for input in &self.parameters.inputs {
match input.witnesses.len() {
0 => transaction.extend(vec![0x00]),
_ => {
transaction.extend(variable_length_integer(input.witnesses.len() as u64)?);
for witness in &input.witnesses {
transaction.extend(witness);
}
}
};
}
}
transaction.extend(&self.parameters.lock_time.to_le_bytes());
Ok(transaction)
}
/// Returns the transaction id.
fn to_transaction_id(&self) -> Result<Self::TransactionId, TransactionError> {
let mut txid = double_sha2(&self.to_transaction_bytes_without_witness()?).to_vec();
let mut wtxid = double_sha2(&self.to_bytes()?).to_vec();
txid.reverse();
wtxid.reverse();
Ok(Self::TransactionId { txid, wtxid })
}
fn sign(&mut self, _signature: Vec<u8>, _recid: u8) -> Result<Vec<u8>, TransactionError> {
panic!(
"trait method sign() deprecated for bitcoin, use custom methods for signature\
insertion in its own impl block instead."
);
}
}
impl<N: BitcoinNetwork> BitcoinTransaction<N> {
/// Return the P2PKH hash preimage of the raw transaction.
pub fn p2pkh_hash_preimage(
&self,
vin: usize,
sighash: SignatureHash,
) -> Result<Vec<u8>, TransactionError> {
let mut preimage = self.parameters.version.to_le_bytes().to_vec();
preimage.extend(variable_length_integer(self.parameters.inputs.len() as u64)?);
for (index, input) in self.parameters.inputs.iter().enumerate() {
preimage.extend(input.serialize(index != vin)?);
}
preimage.extend(variable_length_integer(
self.parameters.outputs.len() as u64
)?);
for output in &self.parameters.outputs {
preimage.extend(output.serialize()?);
}
preimage.extend(&self.parameters.lock_time.to_le_bytes());
preimage.extend(&(sighash as u32).to_le_bytes());
Ok(preimage)
}
/// Return the SegWit hash preimage of the raw transaction
/// `<https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki#specification>`
pub fn segwit_hash_preimage(
&self,
vin: usize,
sighash: SignatureHash,
) -> Result<Vec<u8>, TransactionError> {
let mut prev_outputs = vec![];
let mut prev_sequences = vec![];
let mut outputs = vec![];
for input in &self.parameters.inputs {
prev_outputs.extend(&input.outpoint.reverse_transaction_id);
prev_outputs.extend(&input.outpoint.index.to_le_bytes());
prev_sequences.extend(&input.sequence);
}
for output in &self.parameters.outputs {
outputs.extend(&output.serialize()?);
}
let input = &self.parameters.inputs[vin];
let format = match &input.address {
Some(address) => address.format(),
None => return Err(TransactionError::MissingOutpointAddress),
};
let script = match format {
BitcoinFormat::Bech32 => match &input.script_pub_key {
Some(script) => script[1..].to_vec(),
None => return Err(TransactionError::MissingOutpointScriptPublicKey),
},
BitcoinFormat::CashAddr => match &input.script_pub_key {
Some(script) => script.to_vec(),
None => return Err(TransactionError::MissingOutpointScriptPublicKey),
},
BitcoinFormat::P2WSH => match &input.redeem_script {
Some(redeem_script) => redeem_script.to_vec(),
None => return Err(TransactionError::InvalidInputs("P2WSH".into())),
},
BitcoinFormat::P2SH_P2WPKH => match &input.redeem_script {
Some(redeem_script) => redeem_script[1..].to_vec(),
None => return Err(TransactionError::InvalidInputs("P2SH_P2WPKH".into())),
},
_ => return Err(TransactionError::UnsupportedPreimage("P2PKH".into())),
};
let mut script_code = vec![];
if format == BitcoinFormat::P2WSH || format == BitcoinFormat::CashAddr {
script_code.extend(script);
} else {
script_code.push(Opcode::OP_DUP as u8);
script_code.push(Opcode::OP_HASH160 as u8);
script_code.extend(script);
script_code.push(Opcode::OP_EQUALVERIFY as u8);
script_code.push(Opcode::OP_CHECKSIG as u8);
}
let script_code = [
variable_length_integer(script_code.len() as u64)?,
script_code,
]
.concat();
let hash_prev_outputs = double_sha2(&prev_outputs);
let hash_sequence = double_sha2(&prev_sequences);
let hash_outputs = double_sha2(&outputs);
let balance = match &input.balance {
Some(balance) => balance.0.to_le_bytes(),
None => return Err(TransactionError::MissingOutpointAmount),
};
let mut preimage = vec![];
preimage.extend(&self.parameters.version.to_le_bytes());
preimage.extend(hash_prev_outputs);
preimage.extend(hash_sequence);
preimage.extend(&input.outpoint.reverse_transaction_id);
preimage.extend(&input.outpoint.index.to_le_bytes());
preimage.extend(&script_code);
preimage.extend(&balance);
preimage.extend(&input.sequence);
preimage.extend(hash_outputs);
preimage.extend(&self.parameters.lock_time.to_le_bytes());
preimage.extend(&(sighash as u32).to_le_bytes());
Ok(preimage)
}
/// Returns the transaction with the traditional serialization (no witness).
pub fn to_transaction_bytes_without_witness(&self) -> Result<Vec<u8>, TransactionError> {
let mut transaction = self.parameters.version.to_le_bytes().to_vec();
transaction.extend(variable_length_integer(self.parameters.inputs.len() as u64)?);
for input in &self.parameters.inputs {
transaction.extend(input.serialize(false)?);
}
transaction.extend(variable_length_integer(
self.parameters.outputs.len() as u64
)?);
for output in &self.parameters.outputs {
transaction.extend(output.serialize()?);
}
transaction.extend(&self.parameters.lock_time.to_le_bytes());
Ok(transaction)
}
pub fn input(
&mut self,
index: u32,
) -> Result<&mut BitcoinTransactionInput<N>, TransactionError> {
if index as usize >= self.parameters.inputs.len() {
return Err(TransactionError::Message(format!(
"you are referring to input {}, which is out of bound",
index
)));
}
Ok(&mut self.parameters.inputs[index as usize])
}
pub fn digest(&mut self, index: u32) -> Result<Vec<u8>, TransactionError> {
let input = self.input(index)?;
let sighash = input.sighash_code;
match input.get_address() {
Some(addr) => {
let preimage = match addr.format() {
BitcoinFormat::P2PKH => self.p2pkh_hash_preimage(index as usize, sighash)?,
_ => self.segwit_hash_preimage(index as usize, sighash)?,
};
Ok(double_sha2(&preimage).to_vec())
}
None => Err(TransactionError::MissingOutpointAddress),
}
}
pub fn set_segwit(&mut self) -> Result<(), TransactionError> {
for input in self.parameters.inputs.clone() {
if self.parameters.segwit_flag {
break;
}
if input.is_signed {
match input.get_format() {
Some(BitcoinFormat::P2SH_P2WPKH) | Some(BitcoinFormat::Bech32) => {
self.parameters.segwit_flag = true
}
_ => {}
}
}
}
Ok(())
}
}
impl<N: BitcoinNetwork> FromStr for BitcoinTransaction<N> {
type Err = TransactionError;
fn from_str(transaction: &str) -> Result<Self, Self::Err> {
Self::from_bytes(&hex::decode(transaction)?)
}
}
================================================
FILE: crates/anychain-bitcoin/src/witness_program.rs
================================================
//!
//! WitnessProgram
//!
//! This module contains the representation of a Bitcoin witness program and utility functions
//! related to the representation of such programs.
//!
//! If the version byte is 0, and the witness program is 20 bytes:
//! - It is interpreted as a pay-to-witness-public-key-hash (P2WPKH) program.
//! - The witness must consist of exactly 2 items (≤ 520 bytes each). The first one a signature, and the second one a public key.
//! - The HASH160 of the public key must match the 20-byte witness program.
//! - After normal script evaluation, the signature is verified against the public key with CHECKSIG operation. The verification must result in a single TRUE on the stack.
//!
//! If the version byte is 0, and the witness program is 32 bytes:
//! - It is interpreted as a pay-to-witness-script-hash (P2WSH) program.
//! - The witness must consist of an input stack to feed to the script, followed by a serialized script (witnessScript).
//! - The witnessScript (≤ 10,000 bytes) is popped off the initial witness stack. SHA256 of the witnessScript must match the 32-byte witness program.
//! - The witnessScript is deserialized, and executed after normal script evaluation with the remaining witness stack (≤ 520 bytes for each stack item).
//! - The script must not fail, and result in exactly a single TRUE on the stack.
//!
//! If the version byte is 0, but the witness program is neither 20 nor 32 bytes, the script must fail.
//!
use anychain_core::no_std::*;
use anychain_core::{hex, AddressError, TransactionError};
use core::str::FromStr;
#[derive(Debug, Error, PartialEq, Eq)]
pub enum WitnessProgramError {
#[error("invalid program length {0}")]
InvalidProgramLength(usize),
#[error("invalid program length {0} for script version {1}")]
InvalidProgramLengthForVersion(usize, u8),
#[error("invalid version {0}")]
InvalidVersion(u8),
#[error("invalid program length: {{ expected: {0:?}, found: {1:?} }}")]
MismatchedProgramLength(usize, usize),
#[error("error decoding program from hex string")]
ProgramDecodingError,
}
impl From<WitnessProgramError> for AddressError {
fn from(error: WitnessProgramError) -> Self {
AddressError::Crate("WitnessProgram", format!("{:?}", error))
}
}
impl From<WitnessProgramError> for TransactionError {
fn from(error: WitnessProgramError) -> Self {
TransactionError::Crate("WitnessProgram", format!("{:?}", error))
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct WitnessProgram {
/// The version byte
pub version: u8,
/// The witness program bytes
pub program: Vec<u8>,
}
impl WitnessProgram {
/// Returns a new witness program given a program with a version, data size, and data.
pub fn new(program: &[u8]) -> Result<Self, WitnessProgramError> {
if program.len() < 2 {
return Err(WitnessProgramError::InvalidProgramLength(program.len()));
}
// https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#Decoding
let data_size = program[1] as usize;
let data = program[2..].to_vec();
if data_size != data.len() {
return Err(WitnessProgramError::MismatchedProgramLength(
data.len(),
data_size,
));
}
let program = Self {
version: program[0],
program: data,
};
match program.validate() {
Ok(()) => Ok(program),
Err(e) => Err(e),
}
}
pub fn validate(&self) -> Result<(), WitnessProgramError> {
if self.program.len() < 2 || self.program.len() > 40 {
return Err(WitnessProgramError::InvalidProgramLength(
self.program.len(),
));
}
if self.version > 16 {
return Err(WitnessProgramError::InvalidVersion(self.version));
}
// P2SH_P2WPKH start with 0x0014
// P2SH_P2WSH starts with 0x0020
// https://bitcoincore.org/en/segwit_wallet_dev/#creation-of-p2sh-p2wpkh-address
if self.version == 0 && !(self.program.len() == 20 || self.program.len() == 32) {
return Err(WitnessProgramError::InvalidProgramLengthForVersion(
self.program.len(),
self.version,
));
}
Ok(())
}
/// Returns the witness program's scriptpubkey as a byte vector.
pub fn to_scriptpubkey(&self) -> Vec<u8> {
let mut output = Vec::with_capacity(self.program.len() + 2);
let encoded_version = if self.version > 0 {
self.version + 0x50
} else {
self.version
};
output.push(encoded_version);
output.push(self.program.len() as u8);
output.extend_from_slice(&self.program);
output
}
}
impl FromStr for WitnessProgram {
type Err = WitnessProgramError;
/// Returns a witness program given its hex representation.
fn from_str(s: &str) -> Result<Self, Self::Err> {
WitnessProgram::new(&match hex::decode(s) {
Ok(bytes) => bytes,
Err(_) => return Err(WitnessProgramError::ProgramDecodingError),
})
}
}
#[cfg(test)]
mod tests {
use super::*;
fn test_from_str(program_str: &str, expected_version: u8, expected_program: &[u8]) {
let witness_program = WitnessProgram::from_str(program_str).unwrap();
assert_eq!(expected_version, witness_program.version);
assert_eq!(expected_program.to_vec(), witness_program.program);
}
fn test_to_scriptpubkey(version: u8, program: &[u8], expected_scriptpubkey: &[u8]) {
let witness_program = WitnessProgram {
version,
program: program.to_vec(),
};
assert_eq!(
expected_scriptpubkey.to_vec(),
witness_program.to_scriptpubkey()
);
}
mod p2sh_p2wpkh {
use super::*;
const VALID_P2SH_P2WPKH_PROGRAMS: [(&str, u8, &[u8], &[u8]); 1] = [(
"0014751e76e8199196d454941c45d1b3a323f1433bd6",
0x00,
&[
0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3,
0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6,
],
&[
0x00, 0x14, 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x1c, 0x45,
0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6,
],
)];
#[test]
fn from_str() {
VALID_P2SH_P2WPKH_PROGRAMS.iter().for_each(
|&(program_str, expected_version, expected_program, _)| {
test_from_str(program_str, expected_version, expected_program);
},
);
}
#[test]
fn to_scriptpubkey() {
VALID_P2SH_P2WPKH_PROGRAMS.iter().for_each(
|&(_, version, program, expected_scriptpubkey)| {
test_to_scriptpubkey(version, program, expected_scriptpubkey);
},
);
}
}
mod p2sh_p2wsh {
use super::*;
const VALID_P2SH_P2WSH_PROGRAMS: [(&str, u8, &[u8], &[u8]); 1] = [(
"00201863143c14c5166804bd19203356da136c985678cd4d27a1b8c6329604903262",
0x00,
&[
0x18, 0x63, 0x14, 0x3c, 0x14, 0xc5, 0x16, 0x68, 0x04, 0xbd, 0x19, 0x20, 0x33, 0x56,
0xda, 0x13, 0x6c, 0x98, 0x56, 0x78, 0xcd, 0x4d, 0x27, 0xa1, 0xb8, 0xc6, 0x32, 0x96,
0x04, 0x90, 0x32, 0x62,
],
&[
0x00, 0x20, 0x18, 0x63, 0x14, 0x3c, 0x14, 0xc5, 0x16, 0x68, 0x04, 0xbd, 0x19, 0x20,
0x33, 0x56, 0xda, 0x13, 0x6c, 0x98, 0x56, 0x78, 0xcd, 0x4d, 0x27, 0xa1, 0xb8, 0xc6,
0x32, 0x96, 0x04, 0x90, 0x32, 0x62,
],
)];
#[test]
fn from_str() {
VALID_P2SH_P2WSH_PROGRAMS.iter().for_each(
|&(program_str, expected_version, expected_program, _)| {
test_from_str(program_str, expected_version, expected_program);
},
);
}
#[test]
fn to_scriptpubkey() {
VALID_P2SH_P2WSH_PROGRAMS.iter().for_each(
|&(_, version, program, expected_scriptpubkey)| {
test_to_scriptpubkey(version, program, expected_scriptpubkey);
},
);
}
}
mod version_1 {
use super::*;
const VALID_OP_1_PROGRAMS: [(&str, u8, &[u8], &[u8]); 1] = [(
"0128751e76e8199196d454941c45d1b3a323f1433bd6751e76e8199196d454941c45d1b3a323f1433bd6",
0x01,
&[
0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3,
0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6, 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4,
0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6,
],
&[
0x51, 0x28, 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x1c, 0x45,
0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6, 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91,
0x96, 0xd4, 0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6,
],
)];
#[test]
fn from_str() {
VALID_OP_1_PROGRAMS.iter().for_each(
|&(program_str, expected_version, expected_program, _)| {
test_from_str(program_str, expected_version, expected_program);
},
);
}
#[test]
fn to_scriptpubkey() {
VALID_OP_1_PROGRAMS
.iter()
.for_each(|&(_, version, program, expected_scriptpubkey)| {
test_to_scriptpubkey(version, program, expected_scriptpubkey);
});
}
}
mod test_invalid {
use super::*;
mod new {
use super::*;
const INVALID_VERSION_PROGRAM: &[u8] = &[0x19, 0x03, 0x00, 0x00, 0x00];
const INVALID_LENGTH_FOR_VERSION: &[u8] = &[
0x00, 0x0f, // Version 0, data length is incorrect
0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3,
0xa3,
];
const INVALID_LENGTH_PROGRAM: &[u8] = &[0x19];
const INVALID_LENGTH_PROGRAM_TOO_LONG: &[u8] = &[
0x00, 0x29, 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91, 0x96, 0xd4, 0x54, 0x94, 0x1c, 0x45,
0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6, 0x75, 0x1e, 0x76, 0xe8, 0x19, 0x91,
0x96, 0xd4, 0x54, 0x94, 0x1c, 0x45, 0xd1, 0xb3, 0xa3, 0x23, 0xf1, 0x43, 0x3b, 0xd6,
0x00,
];
#[test]
fn new_invalid_version() {
let witness_program_error =
WitnessProgram::new(INVALID_VERSION_PROGRAM).unwrap_err();
assert_eq!(
WitnessProgramError::InvalidVersion(0x19),
witness_program_error
);
}
#[test]
fn new_invalid_length() {
let witness_program_error =
WitnessProgram::new(INVALID_LENGTH_PROGRAM).unwrap_err();
assert_eq!(
WitnessProgramError::InvalidProgramLength(1),
witness_program_error
);
}
#[test]
fn new_invalid_program_length_for_version() {
let witness_program_error =
WitnessProgram::new(INVALID_LENGTH_FOR_VERSION).unwrap_err();
assert_eq!(
WitnessProgramError::InvalidProgramLengthForVersion(15, 0x00),
witness_program_error
);
}
#[test]
fn new_invalid_program_length_too_long() {
let witness_program_error =
WitnessProgram::new(INVALID_LENGTH_PROGRAM_TOO_LONG).unwrap_err();
assert_eq!(
WitnessProgramError::InvalidProgramLength(41),
witness_program_error
);
}
}
mod from_str {
use super::*;
const INVALID_P2SH_P2WPKH_PROGRAM_LENGTH: &str =
"0014751e76e8199196d454941c45d1b3a323f143";
const INVALID_P2SH_P2WSH_PROGRAM_LENGTH: &str =
"00201863143c14c5166804bd19203356da136c985678cd4d27a1b8c632960490";
const INVALID_OP_1_PROGRAM_LENGTH: &str =
"0128751e76e8199196d454941c45d1b3a323f1433bd6751e76e8199196d454941c45d1b3a323f143";
const INVALID_HEX_STR: &str = "001122zzxxyy";
#[test]
fn from_str_invalid_p2sh_p2wpkh_program_len() {
let witness_program_error =
WitnessProgram::from_str(INVALID_P2SH_P2WPKH_PROGRAM_LENGTH).unwrap_err();
assert_eq!(
WitnessProgramError::MismatchedProgramLength(18, 20),
witness_program_error
);
}
#[test]
fn from_str_invalid_p2sh_p2wsh_program_len() {
let witness_program_error =
WitnessProgram::from_str(INVALID_P2SH_P2WSH_PROGRAM_LENGTH).unwrap_err();
assert_eq!(
WitnessProgramError::MismatchedProgramLength(30, 32),
witness_program_error
);
}
#[test]
fn from_str_invalid_op_1_program_len() {
let witness_program_error =
WitnessProgram::from_str(INVALID_OP_1_PROGRAM_LENGTH).unwrap_err();
assert_eq!(
WitnessProgramError::MismatchedProgramLength(38, 40),
witness_program_error
);
}
#[test]
fn from_str_invalid_hex_str() {
let witness_program_error = WitnessProgram::from_str(INVALID_HEX_STR).unwrap_err();
assert_eq!(
WitnessProgramError::ProgramDecodingError,
witness_program_error
);
}
}
}
}
================================================
FILE: crates/anychain-cardano/Cargo.toml
================================================
[package]
name = "anychain-cardano"
description = "A Rust library for Cardano-focused cryptocurrency wallets, enabling seamless transactions on the Solana blockchain"
version = "0.1.5"
keywords = ["cardano", "ada", "blockchain", "wallet", "transactions"]
categories = ["cryptography::cryptocurrencies"]
# Workspace inherited keys
authors = { workspace = true }
edition = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
[[example]]
name = "transfer-ada"
path = "examples/transfer-ada.rs"
[dependencies]
anychain-core = { path = "../anychain-core", version = "0.1.8" }
#anychain-kms = { path = "../anychain-kms", version = "0.1.17" }
serde = { workspace = true }
ed25519-dalek = { workspace = true }
curve25519-dalek = { workspace = true }
group = "0.13.0"
# Cardano specific depends
cml-chain = { workspace = true }
cml-crypto = { workspace = true }
cml-core = { workspace = true }
#rand_core.workspace = true
[dev-dependencies]
hex = "0.4.3"
bip39 = "2.1.0"
blockfrost = "1.0.5"
tokio = { version = "1.0", features = ["full"] }
[features]
default = ["std"]
std = ["anychain-core/std"]
[lints]
workspace = true
================================================
FILE: crates/anychain-cardano/README.md
================================================
# anychain-cardano
anychain-cardano is a Rust library that provides a simple and unified interface for interacting with the Cardano
blockchain.
## License
anychain-cardano released under the MIT License. See the [LICENSE](LICENSE) file for more information.
================================================
FILE: crates/anychain-cardano/examples/transfer-ada.rs
================================================
use blockfrost::{BlockFrostSettings, BlockfrostAPI, BlockfrostResult, Pagination};
// use cml_chain::builders::tx_builder::TransactionUnspentOutput;
use cml_chain::transaction::TransactionInput;
use cml_crypto::TransactionHash;
// const MNEMONIC_ALICE: &str = "oak anchor meadow nerve limb true banner lock arena brisk width lottery frame walnut barrel innocent enhance feature one gate parade small alert hollow";
const MNEMONIC_ALICE: &str = "toe deal rival umbrella oak inch water hover option lawn essence panda wealth morning summer change soon casino spot decline rural unknown quarter disagree";
// const MNEMONIC_BOB: &str = "oak anchor meadow nerve limb true banner lock arena brisk width lottery frame walnut barrel innocent enhance feature one gate parade small alert hollow";
const MNEMONIC_BOB: &str = "rifle suffer defense test system measure dismiss ketchup enemy all iron clean assist tail rule razor cup source divert field that spatial food drop";
struct CardanoTransactionParameters {
send_address: cml_chain::address::Address, // Sender's address
recv_address: cml_chain::address::Address, // Receiver's address
sender_private_key: String, // Sender's private key
amount: u64, // Amount to transfer in lovelace
ttl: u64, // Time-to-live (slot number)
transaction_input: TransactionInput, // Transaction hash
transaction_output_amount: u64,
}
mod generating_keys {
use bip39::Mnemonic;
use cml_chain::address::{Address, BaseAddress};
use cml_chain::certs::StakeCredential;
use cml_chain::genesis::network_info::NetworkInfo;
use cml_crypto::{Bip32PrivateKey, Bip32PublicKey};
fn derive_key(
private_key: &Bip32PrivateKey,
account: u32,
chain: u32,
index: u32,
) -> Bip32PublicKey {
private_key
.derive(harden(1852))
.derive(harden(1815))
.derive(harden(account))
.derive(chain)
.derive(index)
.to_public()
}
pub fn create_account(mnemonic_str: &str) -> Address {
// Parse the mnemonic
let mnemonic = Mnemonic::parse_normalized(mnemonic_str)
.unwrap_or_else(|e| panic!("Failed to parse mnemonic: {:?}", e));
// Derive entropy and private key
let entropy = mnemonic.to_entropy();
let bip32_private_key = Bip32PrivateKey::from_bip39_entropy(&entropy, &[]);
// Derive spend and stake keys
let spend = derive_key(&bip32_private_key, 0, 0, 0);
let stake = derive_key(&bip32_private_key, 0, 2, 0);
// Create base address
let spend_cred = StakeCredential::new_pub_key(spend.to_raw_key().hash());
let stake_cred = StakeCredential::new_pub_key(stake.to_raw_key().hash());
BaseAddress::new(
NetworkInfo::testnet().network_id(),
spend_cred.clone(),
stake_cred.clone(),
)
.to_address()
}
pub fn create_signing_key(mnemonic_str: &str) -> String {
let mnemonic = Mnemonic::parse_normalized(mnemonic_str)
.unwrap_or_else(|e| panic!("Failed to parse mnemonic: {:?}", e));
let entropy = mnemonic.to_entropy();
let bip32_private_key = Bip32PrivateKey::from_bip39_entropy(&entropy, &[]);
bip32_private_key
.derive(harden(1852))
.derive(harden(1815))
.derive(harden(0))
.derive(0)
.derive(0)
.to_raw_key()
.to_bech32()
}
fn harden(index: u32) -> u32 {
index | 0x80_00_00_00
}
}
mod tx_builder {
use super::CardanoTransactionParameters;
use cml_chain::builders::input_builder::SingleInputBuilder;
use cml_chain::builders::output_builder::TransactionOutputBuilder;
use cml_chain::builders::tx_builder::{
choose_change_selection_algo, ChangeSelectionAlgo, TransactionBuilder,
TransactionBuilderConfigBuilder,
};
use cml_chain::crypto::hash::hash_transaction;
use cml_chain::crypto::utils::make_vkey_witness;
use cml_chain::fees::LinearFee;
use cml_chain::genesis::network_info::plutus_alonzo_cost_models;
use cml_chain::plutus::ExUnitPrices;
use cml_chain::transaction::{TransactionOutput, TransactionWitnessSet};
use cml_chain::utils::NetworkId;
use cml_chain::{SubCoin, Value};
use cml_core::serialization::Serialize;
const MAX_VALUE_SIZE: u32 = 4000;
const MAX_TX_SIZE: u32 = 8000;
fn create_linear_fee(coefficient: u64, constant: u64) -> LinearFee {
LinearFee::new(coefficient, constant, 0)
}
fn create_default_linear_fee() -> LinearFee {
// create_linear_fee(500, 2)
create_linear_fee(1000, 2)
}
fn create_tx_builder_full(
linear_fee: LinearFee,
pool_deposit: u64,
key_deposit: u64,
max_val_size: u32,
coins_per_utxo_byte: u64,
) -> TransactionBuilder {
let cfg = TransactionBuilderConfigBuilder::default()
.fee_algo(linear_fee)
.pool_deposit(pool_deposit)
.key_deposit(key_deposit)
.max_value_size(max_val_size)
.max_tx_size(MAX_TX_SIZE)
.coins_per_utxo_byte(coins_per_utxo_byte)
.ex_unit_prices(ExUnitPrices::new(
SubCoin::new(577, 10000),
SubCoin::new(721, 10000000),
))
.collateral_percentage(150)
.max_collateral_inputs(3)
.cost_models(plutus_alonzo_cost_models())
.build()
.unwrap();
TransactionBuilder::new(cfg)
}
fn create_tx_builder(
linear_fee: LinearFee,
coins_per_utxo_byte: u64,
pool_deposit: u64,
key_deposit: u64,
) -> TransactionBuilder {
create_tx_builder_full(
linear_fee,
pool_deposit,
key_deposit,
MAX_VALUE_SIZE,
coins_per_utxo_byte,
)
}
fn create_tx_builder_with_fee(linear_fee: LinearFee) -> TransactionBuilder {
create_tx_builder(linear_fee, 1, 1, 1)
}
fn create_default_tx_builder() -> TransactionBuilder {
create_tx_builder_with_fee(create_default_linear_fee())
}
pub fn build_tx_with_change(params: &CardanoTransactionParameters) -> Vec<u8> {
let mut tx_builder = create_default_tx_builder();
let input = {
SingleInputBuilder::new(
params.transaction_input.clone(),
TransactionOutput::new(
params.send_address.clone(),
Value::from(params.transaction_output_amount),
None,
None,
),
)
.payment_key()
.unwrap()
};
tx_builder.add_input(input).unwrap();
tx_builder
.add_output(
TransactionOutputBuilder::new()
.with_address(params.recv_address.clone())
.next()
.unwrap()
.with_value(params.amount)
.build()
.unwrap(),
)
.unwrap();
// TODO: set fee
tx_builder.set_ttl(params.ttl + 200);
let change_addr = params.send_address.clone();
let added_change = choose_change_selection_algo(ChangeSelectionAlgo::Default)(
&mut tx_builder,
&change_addr,
false,
);
assert!(added_change.is_ok());
assert!(added_change.unwrap());
assert_eq!(
tx_builder
.get_explicit_input()
.unwrap()
.checked_add(&tx_builder.get_implicit_input().unwrap())
.unwrap(),
tx_builder
.get_explicit_output()
.unwrap()
.checked_add(&Value::from(tx_builder.get_fee_if_set().unwrap()))
.unwrap()
);
// assert_eq!(tx_builder.full_size().unwrap(), 294);
// assert_eq!(tx_builder.output_sizes(), vec![65, 65]);
// TODO: set network id
tx_builder.set_network_id(NetworkId::testnet());
let final_tx = tx_builder.build(ChangeSelectionAlgo::Default, &change_addr);
assert!(final_tx.is_ok());
let final_tx_builder = final_tx.unwrap();
let body = final_tx_builder.body();
let mut witness_set = TransactionWitnessSet::new();
let alice_private_key =
cml_crypto::PrivateKey::from_bech32(¶ms.sender_private_key).unwrap();
witness_set.vkeywitnesses = Some(
vec![make_vkey_witness(
&hash_transaction(&body),
&alice_private_key,
)]
.into(),
);
let final_tx = cml_chain::transaction::Transaction::new(body, witness_set, true, None);
let hex_encoded = hex::encode(final_tx.to_cbor_bytes());
dbg!("Hex Encoded Transaction: {}", hex_encoded);
final_tx.to_cbor_bytes()
}
}
#[tokio::main]
async fn main() -> BlockfrostResult<()> {
let address_alice = generating_keys::create_account(MNEMONIC_ALICE);
let address_bob = generating_keys::create_account(MNEMONIC_BOB);
let api = BlockfrostAPI::new(
"preprodwYU86nDDxOQKRAkTvp660AQu2pxLfh9l",
BlockFrostSettings::new(),
);
assert_eq!(
address_alice.to_bech32(None).unwrap(),
"addr_test1qztenh2rujsa47xgz0u53rjm4ape6urd4yua4f8u6h3rz2lg3cfqlr49zru49t7ejlwjxsdhy9rdafs3fs2yc2egzjeqfqgg4z"
);
assert_eq!(
address_bob.to_bech32(None).unwrap(),
"addr_test1qravems9gq7fqnnsx4u2eqpmx6v7d0h65slk0lsfpwhwew83s0t8du45gf8w86q27kadzqjwszck4hvf4avhjqu3l2esuqsd00"
);
/*
let address = "addr_test1qp5tjpeph2su74qrg60se276u6zvd90umxmctufxr0jf8gr7dsy677qxztemp72yqgu3xv35w2fts5c5k2c9szlrn5fqttkd5z";
let addresses = api.addresses(address).await;
let addresses_total = api.addresses_total(address).await;
let addresses_utxos = api.addresses_utxos(address, Pagination::default()).await;
dbg!(&addresses);
dbg!(&addresses_total);
dbg!(&addresses_utxos);
*/
let alice_address_content = api
.addresses(&address_alice.to_bech32(None).unwrap())
.await?;
//print alice and bob address content in mutiple lines
println!("Alice Address Content:");
for amount in alice_address_content.amount {
println!("{:?}", amount);
}
if let Ok(bob_address_content) = api.addresses(&address_bob.to_bech32(None).unwrap()).await {
println!("Bob Address Content:");
for amount in bob_address_content.amount {
println!("{:?}", amount);
}
} else {
println!("Bob address not found");
}
let slot = api.blocks_latest().await;
let slot = slot?.slot.unwrap() as u64;
let alice_utxos = api
.addresses_utxos(&address_alice.to_bech32(None).unwrap(), Pagination::all())
.await?;
let alice_utxo = alice_utxos[0].clone();
println!(
"Alice UTXOs: {}:{}, {:?}",
alice_utxo.tx_hash, alice_utxo.output_index, alice_utxo
);
let params = CardanoTransactionParameters {
send_address: address_alice,
recv_address: address_bob,
sender_private_key: generating_keys::create_signing_key(MNEMONIC_ALICE),
amount: 10_000_000,
ttl: slot,
transaction_input: TransactionInput::new(
TransactionHash::from_hex(&alice_utxo.tx_hash).unwrap(),
alice_utxo.output_index as u64,
),
transaction_output_amount: alice_utxo
.amount
.iter()
.find(|u| u.unit == "lovelace")
.unwrap()
.quantity
.parse()
.unwrap(),
};
// Should contain the correct cbor contents
let transaction_data = tx_builder::build_tx_with_change(¶ms);
let transaction_hash = api.transactions_submit(transaction_data).await?;
dbg!(&transaction_hash);
// println!("{}", transaction_hash);
Ok(())
}
================================================
FILE: crates/anychain-cardano/src/address.rs
================================================
use {
crate::{format::CardanoFormat, public_key::CardanoPublicKey},
anychain_core::{Address, AddressError, PublicKey},
core::{
fmt::{Display, Formatter, Result as FmtResult},
str::FromStr,
},
curve25519_dalek::Scalar,
std::hash::Hash,
};
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct CardanoAddress(pub cml_chain::address::Address);
impl Address for CardanoAddress {
type SecretKey = Scalar;
type Format = CardanoFormat;
type PublicKey = CardanoPublicKey;
fn from_secret_key(
secret_key: &Self::SecretKey,
format: &Self::Format,
) -> Result<Self, AddressError> {
Self::PublicKey::from_secret_key(secret_key).to_address(format)
}
fn from_public_key(
public_key: &Self::PublicKey,
format: &Self::Format,
) -> Result<Self, AddressError> {
public_key.to_address(format)
}
}
impl FromStr for CardanoAddress {
type Err = AddressError;
fn from_str(addr: &str) -> Result<Self, Self::Err> {
let address = cml_chain::address::Address::from_bech32(addr)
.map_err(|error| AddressError::InvalidAddress(format!("{:?}", error)))?;
Ok(Self(address))
}
}
impl Display for CardanoAddress {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
write!(f, "{}", self.0.to_bech32(None).unwrap())
}
}
#[cfg(test)]
mod tests {
use super::CardanoAddress;
use crate::{format::CardanoFormat, network::CardanoNetwork};
use anychain_core::Address;
use curve25519_dalek::Scalar;
#[test]
fn test() {
let sk = [
104u8, 78, 102, 228, 174, 250, 35, 99, 180, 223, 45, 40, 124, 22, 12, 130, 70, 82, 183,
48, 195, 95, 207, 80, 47, 5, 201, 222, 157, 148, 168, 13,
];
let sk = Scalar::from_bytes_mod_order(sk);
let sk_to = [
189, 149, 70, 173, 231, 111, 65, 210, 164, 15, 24, 21, 180, 45, 148, 78, 252, 149, 36,
168, 70, 107, 84, 229, 47, 5, 213, 243, 253, 249, 19, 11u8,
];
let sk_to = Scalar::from_bytes_mod_order(sk_to);
let format = CardanoNetwork::Preprod;
let format = CardanoFormat::Enterprise(format);
let from = CardanoAddress::from_secret_key(&sk, &format).unwrap();
let to = CardanoAddress::from_secret_key(&sk_to, &format).unwrap();
println!("from: {}\nto: {}\n", from, to);
}
}
================================================
FILE: crates/anychain-cardano/src/amount.rs
================================================
//! Definitions for the native Cardano token and its fractional LOVELACE.
use {
anychain_core::{to_basic_unit_u64, Amount, AmountError},
core::fmt,
serde::{Deserialize, Serialize},
std::ops::{Add, Sub},
};
/// Represents the amount of SOL in lamports
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct CardanoAmount(pub u64);
pub enum Denomination {
LOVELACE,
ADA,
}
impl Denomination {
/// The number of decimal places more than one LOVELACE.
/// There are 10^6 LOVELACE in one ADA
fn precision(self) -> u64 {
match self {
Denomination::LOVELACE => 0,
Denomination::ADA => 6,
}
}
}
impl fmt::Display for Denomination {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{}",
match self {
Denomination::LOVELACE => "lovelace",
Denomination::ADA => "ADA",
}
)
}
}
impl Amount for CardanoAmount {}
impl CardanoAmount {
pub fn from_u64(lovelace: u64) -> Self {
Self(lovelace)
}
pub fn from_u64_str(value: &str) -> Result<u64, AmountError> {
match value.parse::<u64>() {
Ok(lovelace) => Ok(lovelace),
Err(error) => Err(AmountError::Crate("uint", format!("{:?}", error))),
}
}
pub fn from_lovelace(lovelace_value: &str) -> Result<Self, AmountError> {
let lovelace = Self::from_u64_str(lovelace_value)?;
Ok(Self::from_u64(lovelace))
}
pub fn from_ada(sol_value: &str) -> Result<Self, AmountError> {
let lovelace_value = to_basic_unit_u64(sol_value, Denomination::ADA.precision());
let lovelace = Self::from_u64_str(&lovelace_value)?;
Ok(Self::from_u64(lovelace))
}
}
impl Add for CardanoAmount {
type Output = Self;
fn add(self, rhs: Self) -> Self {
Self(self.0 + rhs.0)
}
}
impl Sub for CardanoAmount {
type Output = Self;
fn sub(self, rhs: Self) -> Self::Output {
Self(self.0 - rhs.0)
}
}
impl fmt::Display for CardanoAmount {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.0)
}
}
#[cfg(test)]
#[allow(dead_code)]
mod tests {
use super::*;
fn test_from_lovelace(lovelace_value: &str, expected_amount: &str) {
let amount = CardanoAmount::from_lovelace(lovelace_value).unwrap();
assert_eq!(expected_amount, amount.to_string())
}
fn test_from_ada(ada_value: &str, expected_amount: &str) {
let amount = CardanoAmount::from_ada(ada_value).unwrap();
assert_eq!(expected_amount, amount.to_string())
}
pub struct AmountDenominationTestCase {
lovelace: &'static str,
ada: &'static str,
}
const TEST_AMOUNTS: [AmountDenominationTestCase; 2] = [
AmountDenominationTestCase {
lovelace: "0",
ada: "0",
},
AmountDenominationTestCase {
lovelace: "1000000",
ada: "1",
},
];
#[test]
fn test_lovelace_conversion() {
TEST_AMOUNTS
.iter()
.for_each(|amounts| test_from_lovelace(amounts.lovelace, amounts.lovelace));
}
#[test]
fn test_sol_conversion() {
TEST_AMOUNTS
.iter()
.for_each(|amounts| test_from_ada(amounts.ada, amounts.lovelace));
}
fn test_addition(a: &str, b: &str, result: &str) {
let a = CardanoAmount::from_lovelace(a).unwrap();
let b = CardanoAmount::from_lovelace(b).unwrap();
let result = CardanoAmount::from_lovelace(result).unwrap();
assert_eq!(result, a.add(b));
}
fn test_subtraction(a: &str, b: &str, result: &str) {
let a = CardanoAmount::from_lovelace(a).unwrap();
let b = CardanoAmount::from_lovelace(b).unwrap();
let result = CardanoAmount::from_lovelace(result).unwrap();
assert_eq!(result, a.sub(b));
}
mod valid_arithmetic {
use super::*;
const TEST_VALUES: [(&str, &str, &str); 5] = [
("0", "0", "0"),
("1", "2", "3"),
("100000", "0", "100000"),
("123456789", "987654321", "1111111110"),
("1000000000000000", "2000000000000000", "3000000000000000"),
];
#[test]
fn test_valid_addition() {
TEST_VALUES
.iter()
.for_each(|(a, b, c)| test_addition(a, b, c));
}
}
}
================================================
FILE: crates/anychain-cardano/src/format.rs
================================================
use crate::network::CardanoNetwork;
use {
anychain_core::Format,
core::{default::Default, fmt},
};
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum CardanoFormat {
Base(CardanoNetwork),
Enterprise(CardanoNetwork),
Reward(CardanoNetwork),
Byron(CardanoNetwork),
}
impl CardanoFormat {}
impl Default for CardanoFormat {
fn default() -> Self {
Self::Base(CardanoNetwork::default())
}
}
impl Format for CardanoFormat {}
impl fmt::Display for CardanoFormat {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
CardanoFormat::Base(_) => write!(f, "base"),
CardanoFormat::Enterprise(_) => write!(f, "enterprise"),
CardanoFormat::Reward(_) => write!(f, "reward"),
CardanoFormat::Byron(_) => write!(f, "byron"),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_display() {
assert_eq!(
CardanoFormat::Base(CardanoNetwork::Mainnet).to_string(),
"base"
);
assert_eq!(
CardanoFormat::Enterprise(CardanoNetwork::Mainnet).to_string(),
"enterprise"
);
assert_eq!(
CardanoFormat::Reward(CardanoNetwork::Mainnet).to_string(),
"reward"
);
assert_eq!(
CardanoFormat::Byron(CardanoNetwork::Mainnet).to_string(),
"byron"
);
}
}
================================================
FILE: crates/anychain-cardano/src/lib.rs
================================================
pub mod address;
pub mod amount;
pub mod format;
pub mod network;
pub mod public_key;
pub mod transaction;
mod util;
pub use self::address::*;
pub use self::amount::*;
pub use self::format::*;
pub use self::network::*;
pub use self::public_key::*;
pub use self::transaction::*;
================================================
FILE: crates/anychain-cardano/src/network.rs
================================================
/// Mainnet: This is the primary network where actual transactions occur and real ADA is used.
/// It is the live network used by end-users and applications.
///
/// Preview: This is a testing environment that mimics the mainnet but uses test ADA.
/// It is used for testing new features and updates before they are deployed to the mainnet.
///
/// Preprod: This is another testing environment similar to TestnetPreview, but it may be used for pre-production testing.
/// It allows developers to test their applications in an environment that closely resembles the mainnet before final deployment.
#[derive(Default, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum CardanoNetwork {
#[default]
Mainnet,
Preprod,
Preview,
}
impl CardanoNetwork {
pub fn info(&self) -> CardanoNetworkInfo {
match self {
CardanoNetwork::Mainnet => CardanoNetworkInfo::mainnet(),
CardanoNetwork::Preprod => CardanoNetworkInfo::preprod(),
CardanoNetwork::Preview => CardanoNetworkInfo::preview(),
}
}
}
#[derive(Debug, Clone, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct CardanoNetworkInfo {
network_id: u8,
protocol_magic: u32,
}
impl CardanoNetworkInfo {
pub fn new(network_id: u8, protocol_magic: u32) -> Self {
Self {
network_id,
protocol_magic,
}
}
pub fn network_id(&self) -> u8 {
self.network_id
}
pub fn protocol_magic(&self) -> u32 {
self.protocol_magic
}
pub fn mainnet() -> CardanoNetworkInfo {
CardanoNetworkInfo {
network_id: 0b0001,
protocol_magic: 764824073,
}
}
pub fn preprod() -> CardanoNetworkInfo {
CardanoNetworkInfo {
network_id: 0b0000,
protocol_magic: 1,
}
}
pub fn preview() -> CardanoNetworkInfo {
CardanoNetworkInfo {
network_id: 0b0000,
protocol_magic: 2,
}
}
}
================================================
FILE: crates/anychain-cardano/src/public_key.rs
================================================
use {
crate::{address::CardanoAddress, format::CardanoFormat},
anychain_core::{AddressError, PublicKey, PublicKeyError},
cml_chain::{
address::{EnterpriseAddress, RewardAddress},
certs::StakeCredential,
},
cml_crypto::{blake2b224, Ed25519KeyHash},
core::{fmt, str::FromStr},
curve25519_dalek::{constants::ED25519_BASEPOINT_TABLE as G, Scalar},
group::GroupEncoding,
};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CardanoPublicKey(pub ed25519_dalek::VerifyingKey);
impl PublicKey for CardanoPublicKey {
type SecretKey = Scalar;
type Address = CardanoAddress;
type Format = CardanoFormat;
fn from_secret_key(secret_key: &Self::SecretKey) -> Self {
let pk = secret_key * G;
let pk = pk.to_bytes();
let pk = ed25519_dalek::VerifyingKey::from_bytes(&pk).unwrap();
Self(pk)
}
fn to_address(&self, format: &Self::Format) -> Result<Self::Address, AddressError> {
let bytes = self.0.as_bytes();
let hash = blake2b224(bytes);
let hash = Ed25519KeyHash::from(hash);
let cred = StakeCredential::new_pub_key(hash);
match format {
CardanoFormat::Enterprise(network) => {
let address =
EnterpriseAddress::new(network.info().ne
gitextract_yq5pvl5m/ ├── .github/ │ └── workflows/ │ ├── lint-pr.yml │ ├── release.yml │ └── rust.yml ├── .gitignore ├── Cargo.toml ├── LICENSE ├── Makefile ├── README.md ├── crates/ │ ├── anychain-bitcoin/ │ │ ├── Cargo.toml │ │ ├── README.md │ │ └── src/ │ │ ├── address.rs │ │ ├── amount.rs │ │ ├── format.rs │ │ ├── lib.rs │ │ ├── network/ │ │ │ ├── bitcoin.rs │ │ │ ├── bitcoin_testnet.rs │ │ │ ├── bitcoincash.rs │ │ │ ├── bitcoincash_testnet.rs │ │ │ ├── dogecoin.rs │ │ │ ├── dogecoin_testnet.rs │ │ │ ├── litecoin.rs │ │ │ ├── litecoin_testnet.rs │ │ │ └── mod.rs │ │ ├── public_key.rs │ │ ├── transaction.rs │ │ └── witness_program.rs │ ├── anychain-cardano/ │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── examples/ │ │ │ └── transfer-ada.rs │ │ ├── src/ │ │ │ ├── address.rs │ │ │ ├── amount.rs │ │ │ ├── format.rs │ │ │ ├── lib.rs │ │ │ ├── network.rs │ │ │ ├── public_key.rs │ │ │ ├── transaction.rs │ │ │ └── util.rs │ │ └── tests/ │ │ └── test_derive.rs │ ├── anychain-core/ │ │ ├── Cargo.toml │ │ ├── README.md │ │ └── src/ │ │ ├── address.rs │ │ ├── amount.rs │ │ ├── error.rs │ │ ├── format.rs │ │ ├── lib.rs │ │ ├── network.rs │ │ ├── no_std/ │ │ │ ├── io.rs │ │ │ └── mod.rs │ │ ├── public_key.rs │ │ ├── transaction.rs │ │ └── utilities/ │ │ ├── crypto.rs │ │ └── mod.rs │ ├── anychain-ethereum/ │ │ ├── Cargo.toml │ │ ├── README.md │ │ └── src/ │ │ ├── address.rs │ │ ├── format.rs │ │ ├── lib.rs │ │ ├── network/ │ │ │ ├── mainnet.rs │ │ │ ├── mod.rs │ │ │ └── testnet.rs │ │ ├── public_key.rs │ │ ├── transaction/ │ │ │ ├── contract.rs │ │ │ ├── eip1559.rs │ │ │ ├── eip3009.rs │ │ │ ├── eip7702.rs │ │ │ ├── legacy.rs │ │ │ └── mod.rs │ │ └── util.rs │ ├── anychain-filecoin/ │ │ ├── Cargo.toml │ │ ├── README.md │ │ └── src/ │ │ ├── address.rs │ │ ├── amount.rs │ │ ├── format.rs │ │ ├── lib.rs │ │ ├── public_key.rs │ │ ├── transaction.rs │ │ └── utilities/ │ │ ├── crypto.rs │ │ └── mod.rs │ ├── anychain-kms/ │ │ ├── .gitignore │ │ ├── Cargo.toml │ │ ├── README.md │ │ └── src/ │ │ ├── bip32/ │ │ │ ├── child_number.rs │ │ │ ├── derivation_path.rs │ │ │ ├── error.rs │ │ │ ├── extended_key/ │ │ │ │ ├── attrs.rs │ │ │ │ ├── extended_private_key.rs │ │ │ │ ├── extended_public_key.rs │ │ │ │ └── mod.rs │ │ │ ├── mod.rs │ │ │ ├── prefix.rs │ │ │ ├── private_key.rs │ │ │ └── public_key.rs │ │ ├── bip39/ │ │ │ ├── crypto.rs │ │ │ ├── error.rs │ │ │ ├── langs/ │ │ │ │ ├── chinese_simplified.txt │ │ │ │ ├── chinese_traditional.txt │ │ │ │ ├── english.txt │ │ │ │ ├── french.txt │ │ │ │ ├── italian.txt │ │ │ │ ├── japanese.txt │ │ │ │ ├── korean.txt │ │ │ │ └── spanish.txt │ │ │ ├── language.rs │ │ │ ├── mnemonic.rs │ │ │ ├── mnemonic_type.rs │ │ │ ├── mod.rs │ │ │ ├── seed.rs │ │ │ └── util.rs │ │ ├── crypto.rs │ │ ├── error.rs │ │ └── lib.rs │ ├── anychain-neo/ │ │ ├── Cargo.toml │ │ └── src/ │ │ ├── address.rs │ │ ├── format.rs │ │ ├── lib.rs │ │ ├── public_key.rs │ │ └── transaction.rs │ ├── anychain-polkadot/ │ │ ├── Cargo.toml │ │ ├── README.md │ │ └── src/ │ │ ├── address.rs │ │ ├── format.rs │ │ ├── lib.rs │ │ ├── network/ │ │ │ ├── kusama.rs │ │ │ ├── mod.rs │ │ │ ├── polkadot.rs │ │ │ ├── rococo.rs │ │ │ └── westend.rs │ │ ├── public_key.rs │ │ ├── transaction.rs │ │ └── utilities/ │ │ ├── crypto.rs │ │ └── mod.rs │ ├── anychain-ripple/ │ │ ├── Cargo.toml │ │ ├── README.md │ │ └── src/ │ │ ├── address.rs │ │ ├── format.rs │ │ ├── lib.rs │ │ ├── public_key.rs │ │ └── transaction.rs │ └── anychain-tron/ │ ├── Cargo.toml │ ├── README.md │ └── src/ │ ├── abi.rs │ ├── address.rs │ ├── format.rs │ ├── lib.rs │ ├── protocol/ │ │ ├── Discover.rs │ │ ├── Tron.rs │ │ ├── account_contract.rs │ │ ├── asset_issue_contract.rs │ │ ├── balance_contract.rs │ │ ├── common.rs │ │ ├── exchange_contract.rs │ │ ├── market_contract.rs │ │ ├── mod.rs │ │ ├── proposal_contract.rs │ │ ├── shield_contract.rs │ │ ├── smart_contract.rs │ │ ├── storage_contract.rs │ │ ├── vote_asset_contract.rs │ │ └── witness_contract.rs │ ├── public_key.rs │ ├── transaction.rs │ └── trx.rs ├── docs/ │ ├── design-cn.md │ └── design-en.md ├── examples/ │ ├── anychain-bitcoin-cli/ │ │ ├── Cargo.toml │ │ ├── README.md │ │ └── src/ │ │ └── main.rs │ ├── anychain-bitcoin-client/ │ │ ├── Cargo.toml │ │ └── src/ │ │ └── main.rs │ ├── anychain-ethereum-cli/ │ │ ├── Cargo.toml │ │ ├── README.md │ │ └── src/ │ │ └── main.rs │ └── anychain-neo-cli/ │ ├── Cargo.toml │ ├── README.md │ └── src/ │ └── main.rs ├── lib.rs └── rust-toolchain.toml
Showing preview only (408K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (4376 symbols across 117 files)
FILE: crates/anychain-bitcoin/src/address.rs
type BitcoinAddress (line 16) | pub struct BitcoinAddress<N: BitcoinNetwork> {
function checksum_bch (line 39) | fn checksum_bch(feed: Vec<u8>) -> [u8; 5] {
function compute_checksum_bch (line 74) | fn compute_checksum_bch(payload: &str, prefix: &str) -> Result<String, A...
type SecretKey (line 115) | type SecretKey = libsecp256k1::SecretKey;
type Format (line 116) | type Format = BitcoinFormat;
type PublicKey (line 117) | type PublicKey = BitcoinPublicKey<N>;
method from_secret_key (line 120) | fn from_secret_key(
method from_public_key (line 128) | fn from_public_key(
function p2pkh_from_hash (line 147) | pub fn p2pkh_from_hash(hash: &[u8]) -> Result<Self, AddressError> {
function p2sh_p2wpkh_from_hash (line 167) | pub fn p2sh_p2wpkh_from_hash(hash: &[u8]) -> Result<Self, AddressError> {
function p2wsh_from_hash (line 187) | pub fn p2wsh_from_hash(hash: &[u8]) -> Result<Self, AddressError> {
function bech32_from_hash (line 210) | pub fn bech32_from_hash(hash: &[u8]) -> Result<Self, AddressError> {
function cash_addr_from_hash (line 232) | pub fn cash_addr_from_hash(hash: &[u8]) -> Result<Self, AddressError> {
function p2tr_from_hash (line 258) | pub fn p2tr_from_hash(hash: &[u8]) -> Result<Self, AddressError> {
function p2pkh (line 281) | pub fn p2pkh(public_key: &<Self as Address>::PublicKey) -> Result<Self, ...
function p2wsh (line 287) | pub fn p2wsh(original_script: &[u8]) -> Result<Self, AddressError> {
function p2sh_p2wpkh (line 293) | pub fn p2sh_p2wpkh(public_key: &<Self as Address>::PublicKey) -> Result<...
function bech32 (line 299) | pub fn bech32(public_key: &<Self as Address>::PublicKey) -> Result<Self,...
function cash_addr (line 305) | pub fn cash_addr(public_key: &<Self as Address>::PublicKey) -> Result<Se...
function format (line 311) | pub fn format(&self) -> BitcoinFormat {
function create_redeem_script (line 316) | pub fn create_redeem_script(public_key: &<Self as Address>::PublicKey) -...
function from_script_pub_key (line 324) | pub fn from_script_pub_key(script_pub_key: &[u8]) -> Result<Self, Addres...
type Err (line 363) | type Err = AddressError;
method from_str (line 365) | fn from_str(address: &str) -> Result<Self, Self::Err> {
function fmt (line 507) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
function test_from_str (line 519) | fn test_from_str<N: BitcoinNetwork>(expected_address: &str, expected_for...
function test_to_str (line 525) | fn test_to_str<N: BitcoinNetwork>(expected_address: &str, address: &Bitc...
type N (line 532) | type N = Bitcoin;
constant KEYPAIRS (line 534) | const KEYPAIRS: [(&str, &str); 5] = [
function from_str (line 558) | fn from_str() {
function to_str (line 565) | fn to_str() {
type N (line 576) | type N = Bitcoin;
constant KEYPAIRS (line 578) | const KEYPAIRS: [(&str, &str); 5] = [
function from_str (line 602) | fn from_str() {
function to_str (line 609) | fn to_str() {
type N (line 620) | type N = BitcoinTestnet;
constant KEYPAIRS (line 622) | const KEYPAIRS: [(&str, &str); 5] = [
function from_str (line 646) | fn from_str() {
function to_str (line 653) | fn to_str() {
type N (line 664) | type N = BitcoinTestnet;
constant KEYPAIRS (line 666) | const KEYPAIRS: [(&str, &str); 5] = [
function from_str (line 690) | fn from_str() {
function to_str (line 697) | fn to_str() {
type N (line 708) | type N = Bitcoin;
constant KEYPAIRS (line 710) | const KEYPAIRS: [(&str, &str); 5] = [
function from_str (line 734) | fn from_str() {
function to_str (line 741) | fn to_str() {
type N (line 752) | type N = BitcoinTestnet;
constant KEYPAIRS (line 754) | const KEYPAIRS: [(&str, &str); 5] = [
function from_str (line 778) | fn from_str() {
function to_str (line 785) | fn to_str() {
type N (line 796) | type N = Bitcoin;
constant KEYPAIRS (line 798) | const KEYPAIRS: [(&str, &str); 5] = [
constant INVALID (line 821) | const INVALID: [&str; 7] = [
function from_invalid_address (line 832) | fn from_invalid_address() {
function from_str (line 839) | fn from_str() {
function to_str (line 846) | fn to_str() {
type N (line 857) | type N = BitcoinTestnet;
constant KEYPAIRS (line 859) | const KEYPAIRS: [(&str, &str); 5] = [
constant INVALID (line 882) | const INVALID: [&str; 3] = [
function from_invalid_address (line 889) | fn from_invalid_address() {
function from_str (line 896) | fn from_str() {
function to_str (line 903) | fn to_str() {
type N (line 914) | type N = Bitcoin;
function test_addr (line 917) | fn test_addr() {
type N (line 928) | type N = BitcoinTestnet;
constant SCRIPTPAIRS (line 930) | const SCRIPTPAIRS: [(&str, &str); 2] = [
function from_str (line 942) | fn from_str() {
function to_str (line 952) | fn to_str() {
function f (line 961) | fn f() {
function ff (line 1032) | fn ff() {
function test_decode_script (line 1052) | fn test_decode_script() {
FILE: crates/anychain-bitcoin/src/amount.rs
constant COIN (line 8) | const COIN: i64 = 1_0000_0000;
type BitcoinAmount (line 12) | pub struct BitcoinAmount(pub i64);
constant ZERO (line 64) | pub const ZERO: BitcoinAmount = BitcoinAmount(0);
constant ONE_SAT (line 66) | pub const ONE_SAT: BitcoinAmount = BitcoinAmount(1);
constant ONE_BTC (line 68) | pub const ONE_BTC: BitcoinAmount = BitcoinAmount(COIN);
method from_satoshi (line 70) | pub fn from_satoshi(satoshis: i64) -> Result<Self, AmountError> {
method from_ubtc (line 74) | pub fn from_ubtc(ubtc_value: i64) -> Result<Self, AmountError> {
method from_mbtc (line 80) | pub fn from_mbtc(mbtc_value: i64) -> Result<Self, AmountError> {
method from_cbtc (line 86) | pub fn from_cbtc(cbtc_value: i64) -> Result<Self, AmountError> {
method from_dbtc (line 92) | pub fn from_dbtc(dbtc_value: i64) -> Result<Self, AmountError> {
method from_btc (line 98) | pub fn from_btc(btc_value: i64) -> Result<Self, AmountError> {
method fmt (line 120) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
type Denomination (line 14) | pub enum Denomination {
method precision (line 31) | fn precision(self) -> u32 {
method fmt (line 44) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
type Output (line 106) | type Output = Result<Self, AmountError>;
method add (line 107) | fn add(self, rhs: Self) -> Self::Output {
type Output (line 113) | type Output = Result<Self, AmountError>;
method sub (line 114) | fn sub(self, rhs: Self) -> Self::Output {
function test_from_satoshi (line 129) | fn test_from_satoshi(sat_value: i64, expected_amount: BitcoinAmount) {
function test_from_ubtc (line 134) | fn test_from_ubtc(ubtc_value: i64, expected_amount: BitcoinAmount) {
function test_from_mbtc (line 139) | fn test_from_mbtc(mbtc_value: i64, expected_amount: BitcoinAmount) {
function test_from_cbtc (line 144) | fn test_from_cbtc(cbtc_value: i64, expected_amount: BitcoinAmount) {
function test_from_dbtc (line 149) | fn test_from_dbtc(dbtc_value: i64, expected_amount: BitcoinAmount) {
function test_from_btc (line 154) | fn test_from_btc(btc_value: i64, expected_amount: BitcoinAmount) {
function test_addition (line 159) | fn test_addition(a: &i64, b: &i64, result: &i64) {
function test_subtraction (line 167) | fn test_subtraction(a: &i64, b: &i64, result: &i64) {
type AmountDenominationTestCase (line 175) | pub struct AmountDenominationTestCase {
constant TEST_AMOUNTS (line 187) | const TEST_AMOUNTS: [AmountDenominationTestCase; 5] = [
function test_satoshi_conversion (line 231) | fn test_satoshi_conversion() {
function test_ubtc_conversion (line 238) | fn test_ubtc_conversion() {
function test_mbtc_conversion (line 245) | fn test_mbtc_conversion() {
function test_cbtc_conversion (line 252) | fn test_cbtc_conversion() {
function test_dbtc_conversion (line 259) | fn test_dbtc_conversion() {
function test_btc_conversion (line 266) | fn test_btc_conversion() {
constant TEST_VALUES (line 276) | const TEST_VALUES: [(i64, i64, i64); 7] = [
function test_valid_addition (line 287) | fn test_valid_addition() {
function test_valid_subtraction (line 294) | fn test_valid_subtraction() {
constant INVALID_TEST_AMOUNTS (line 307) | const INVALID_TEST_AMOUNTS: [AmountDenominationTestCase; 4] = [
function test_invalid_ubtc_conversion (line 344) | fn test_invalid_ubtc_conversion() {
function test_invalid_mbtc_conversion (line 352) | fn test_invalid_mbtc_conversion() {
function test_invalid_cbtc_conversion (line 360) | fn test_invalid_cbtc_conversion() {
function test_invalid_dbtc_conversion (line 368) | fn test_invalid_dbtc_conversion() {
function test_invalid_btc_conversion (line 376) | fn test_invalid_btc_conversion() {
constant TEST_VALUES (line 386) | const TEST_VALUES: [(i64, i64, i64); 8] = [
function test_invalid_addition (line 399) | fn test_invalid_addition() {
function test_invalid_subtraction (line 407) | fn test_invalid_subtraction() {
FILE: crates/anychain-bitcoin/src/format.rs
type BitcoinFormat (line 12) | pub enum BitcoinFormat {
method from_address_prefix (line 31) | pub fn from_address_prefix(prefix: Prefix) -> Result<Self, AddressErro...
method fmt (line 54) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
type Err (line 66) | type Err = AddressError;
method from_str (line 68) | fn from_str(format: &str) -> Result<Self, AddressError> {
FILE: crates/anychain-bitcoin/src/network/bitcoin.rs
type Bitcoin (line 9) | pub struct Bitcoin;
method fmt (line 65) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
constant NAME (line 12) | const NAME: &'static str = "bitcoin";
method to_address_prefix (line 17) | fn to_address_prefix(format: BitcoinFormat) -> Result<Prefix, AddressErr...
method from_address_prefix (line 32) | fn from_address_prefix(prefix: Prefix) -> Result<Self, AddressError> {
type Err (line 54) | type Err = NetworkError;
method from_str (line 56) | fn from_str(s: &str) -> Result<Self, Self::Err> {
FILE: crates/anychain-bitcoin/src/network/bitcoin_testnet.rs
type BitcoinTestnet (line 9) | pub struct BitcoinTestnet;
method fmt (line 65) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
constant NAME (line 12) | const NAME: &'static str = "bitcoin testnet";
method to_address_prefix (line 17) | fn to_address_prefix(format: BitcoinFormat) -> Result<Prefix, AddressErr...
method from_address_prefix (line 32) | fn from_address_prefix(prefix: Prefix) -> Result<Self, AddressError> {
type Err (line 54) | type Err = NetworkError;
method from_str (line 56) | fn from_str(s: &str) -> Result<Self, Self::Err> {
FILE: crates/anychain-bitcoin/src/network/bitcoincash.rs
type BitcoinCash (line 9) | pub struct BitcoinCash;
method fmt (line 61) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
constant NAME (line 12) | const NAME: &'static str = "bitcoin cash";
method to_address_prefix (line 17) | fn to_address_prefix(format: BitcoinFormat) -> Result<Prefix, AddressErr...
method from_address_prefix (line 28) | fn from_address_prefix(prefix: Prefix) -> Result<Self, AddressError> {
type Err (line 50) | type Err = NetworkError;
method from_str (line 52) | fn from_str(s: &str) -> Result<Self, Self::Err> {
FILE: crates/anychain-bitcoin/src/network/bitcoincash_testnet.rs
type BitcoinCashTestnet (line 9) | pub struct BitcoinCashTestnet;
method fmt (line 61) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
constant NAME (line 12) | const NAME: &'static str = "bitcoin cash testnet";
method to_address_prefix (line 17) | fn to_address_prefix(format: BitcoinFormat) -> Result<Prefix, AddressErr...
method from_address_prefix (line 28) | fn from_address_prefix(prefix: Prefix) -> Result<Self, AddressError> {
type Err (line 50) | type Err = NetworkError;
method from_str (line 52) | fn from_str(s: &str) -> Result<Self, Self::Err> {
FILE: crates/anychain-bitcoin/src/network/dogecoin.rs
type Dogecoin (line 9) | pub struct Dogecoin;
method fmt (line 61) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
constant NAME (line 12) | const NAME: &'static str = "dogecoin";
method to_address_prefix (line 17) | fn to_address_prefix(format: BitcoinFormat) -> Result<Prefix, AddressErr...
method from_address_prefix (line 31) | fn from_address_prefix(prefix: Prefix) -> Result<Self, AddressError> {
type Err (line 50) | type Err = NetworkError;
method from_str (line 52) | fn from_str(s: &str) -> Result<Self, Self::Err> {
FILE: crates/anychain-bitcoin/src/network/dogecoin_testnet.rs
type DogecoinTestnet (line 9) | pub struct DogecoinTestnet;
method fmt (line 63) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
constant NAME (line 12) | const NAME: &'static str = "dogecoin testnet";
method to_address_prefix (line 19) | fn to_address_prefix(format: BitcoinFormat) -> Result<Prefix, AddressErr...
method from_address_prefix (line 33) | fn from_address_prefix(prefix: Prefix) -> Result<Self, AddressError> {
type Err (line 52) | type Err = NetworkError;
method from_str (line 54) | fn from_str(s: &str) -> Result<Self, Self::Err> {
FILE: crates/anychain-bitcoin/src/network/litecoin.rs
type Litecoin (line 9) | pub struct Litecoin;
method fmt (line 65) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
constant NAME (line 12) | const NAME: &'static str = "litecoin";
method to_address_prefix (line 17) | fn to_address_prefix(format: BitcoinFormat) -> Result<Prefix, AddressErr...
method from_address_prefix (line 32) | fn from_address_prefix(prefix: Prefix) -> Result<Self, AddressError> {
type Err (line 54) | type Err = NetworkError;
method from_str (line 56) | fn from_str(s: &str) -> Result<Self, Self::Err> {
FILE: crates/anychain-bitcoin/src/network/litecoin_testnet.rs
type LitecoinTestnet (line 9) | pub struct LitecoinTestnet;
method fmt (line 65) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
constant NAME (line 12) | const NAME: &'static str = "litecoin testnet";
method to_address_prefix (line 17) | fn to_address_prefix(format: BitcoinFormat) -> Result<Prefix, AddressErr...
method from_address_prefix (line 32) | fn from_address_prefix(prefix: Prefix) -> Result<Self, AddressError> {
type Err (line 54) | type Err = NetworkError;
method from_str (line 56) | fn from_str(s: &str) -> Result<Self, Self::Err> {
FILE: crates/anychain-bitcoin/src/network/mod.rs
type BitcoinNetwork (line 30) | pub trait BitcoinNetwork: Network {
method to_address_prefix (line 32) | fn to_address_prefix(format: BitcoinFormat) -> Result<Prefix, AddressE...
method from_address_prefix (line 35) | fn from_address_prefix(prefix: Prefix) -> Result<Self, AddressError>;
type Prefix (line 39) | pub enum Prefix {
method version (line 47) | pub fn version(self) -> u8 {
method prefix (line 55) | pub fn prefix(self) -> String {
method from_version (line 63) | pub fn from_version(version: u8) -> Self {
method from_prefix (line 67) | pub fn from_prefix(prefix: &str) -> Self {
FILE: crates/anychain-bitcoin/src/public_key.rs
type BitcoinPublicKey (line 7) | pub struct BitcoinPublicKey<N: BitcoinNetwork> {
type SecretKey (line 17) | type SecretKey = libsecp256k1::SecretKey;
type Address (line 18) | type Address = BitcoinAddress<N>;
type Format (line 19) | type Format = BitcoinFormat;
method from_secret_key (line 22) | fn from_secret_key(secret_key: &Self::SecretKey) -> Self {
method to_address (line 31) | fn to_address(&self, format: &Self::Format) -> Result<Self::Address, Add...
function from_secp256k1_public_key (line 38) | pub fn from_secp256k1_public_key(
function to_secp256k1_public_key (line 50) | pub fn to_secp256k1_public_key(&self) -> libsecp256k1::PublicKey {
function serialize (line 55) | pub fn serialize(&self) -> Vec<u8> {
function is_compressed (line 63) | pub fn is_compressed(&self) -> bool {
type Err (line 69) | type Err = PublicKeyError;
method from_str (line 71) | fn from_str(public_key: &str) -> Result<Self, Self::Err> {
function fmt (line 86) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
function test_to_address (line 105) | fn test_to_address<N: BitcoinNetwork>(
function test_from_str (line 114) | fn test_from_str<N: BitcoinNetwork>(
function test_to_str (line 128) | fn test_to_str<N: BitcoinNetwork>(expected_public_key: &str, public_key:...
type N (line 135) | type N = Bitcoin;
constant KEYPAIRS (line 136) | const KEYPAIRS: [(&str, &str, &str); 5] = [
function to_address (line 165) | fn to_address() {
function from_str (line 174) | fn from_str() {
function to_str (line 188) | fn to_str() {
type N (line 199) | type N = Bitcoin;
constant KEYPAIRS (line 200) | const KEYPAIRS: [(&str, &str, &str); 5] = [
function to_address (line 229) | fn to_address() {
function from_str (line 238) | fn from_str() {
function to_str (line 252) | fn to_str() {
type N (line 263) | type N = BitcoinTestnet;
constant KEYPAIRS (line 264) | const KEYPAIRS: [(&str, &str, &str); 5] = [
function to_address (line 293) | fn to_address() {
function from_str (line 302) | fn from_str() {
function to_str (line 316) | fn to_str() {
type N (line 327) | type N = BitcoinTestnet;
constant KEYPAIRS (line 328) | const KEYPAIRS: [(&str, &str, &str); 5] = [
function to_address (line 357) | fn to_address() {
function from_str (line 366) | fn from_str() {
function to_str (line 380) | fn to_str() {
type N (line 391) | type N = Bitcoin;
constant KEYPAIRS (line 392) | const KEYPAIRS: [(&str, &str, &str); 5] = [
function to_address (line 421) | fn to_address() {
function from_str (line 430) | fn from_str() {
function to_str (line 444) | fn to_str() {
type N (line 455) | type N = BitcoinTestnet;
constant KEYPAIRS (line 456) | const KEYPAIRS: [(&str, &str, &str); 5] = [
function to_address (line 485) | fn to_address() {
function from_str (line 494) | fn from_str() {
function to_str (line 508) | fn to_str() {
function test_p2pkh_invalid (line 517) | fn test_p2pkh_invalid() {
function test_p2sh_p2wpkh_invalid (line 540) | fn test_p2sh_p2wpkh_invalid() {
FILE: crates/anychain-bitcoin/src/transaction.rs
function variable_length_integer (line 23) | pub fn variable_length_integer(value: u64) -> Result<Vec<u8>, Transactio...
function read_variable_length_integer (line 38) | pub fn read_variable_length_integer<R: Read>(mut reader: R) -> Result<us...
type BitcoinVector (line 73) | pub struct BitcoinVector;
method read (line 77) | pub fn read<R: Read, E, F>(mut reader: R, func: F) -> Result<Vec<E>, T...
method read_witness (line 86) | pub fn read_witness<R: Read, E, F>(
function create_script_pub_key (line 99) | pub fn create_script_pub_key<N: BitcoinNetwork>(
function create_script_op_return (line 182) | pub fn create_script_op_return(property_id: u32, amount: i64) -> Result<...
type SignatureHash (line 206) | pub enum SignatureHash {
method fmt (line 242) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
method from_byte (line 279) | pub fn from_byte(byte: &u8) -> Self {
type Opcode (line 300) | pub enum Opcode {
method fmt (line 311) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
type Outpoint (line 326) | pub struct Outpoint {
method new (line 335) | pub fn new(reverse_transaction_id: Vec<u8>, index: u32) -> Self {
type BitcoinTransactionInput (line 345) | pub struct BitcoinTransactionInput<N: BitcoinNetwork> {
constant DEFAULT_SEQUENCE (line 376) | const DEFAULT_SEQUENCE: [u8; 4] = [0xf2, 0xff, 0xff, 0xff];
function new (line 379) | pub fn new(
function set_public_key (line 448) | pub fn set_public_key(
function set_redeem_script (line 466) | pub fn set_redeem_script(&mut self, redeem_script: Vec<u8>) -> Result<()...
function set_format (line 471) | pub fn set_format(&mut self, format: BitcoinFormat) -> Result<(), Transa...
function set_balance (line 476) | pub fn set_balance(&mut self, balance: i64) -> Result<(), TransactionErr...
function set_sequence (line 481) | pub fn set_sequence(&mut self, sequence: u32) -> Result<(), TransactionE...
function set_sighash (line 486) | pub fn set_sighash(&mut self, sighash: SignatureHash) -> Result<(), Tran...
function get_address (line 491) | pub fn get_address(&self) -> Option<BitcoinAddress<N>> {
function get_format (line 495) | pub fn get_format(&self) -> Option<BitcoinFormat> {
function get_balance (line 499) | pub fn get_balance(&self) -> Option<BitcoinAmount> {
function get_sequence (line 503) | pub fn get_sequence(&self) -> u32 {
function get_sighash (line 508) | pub fn get_sighash(&self) -> SignatureHash {
function read (line 513) | pub fn read<R: Read>(mut reader: &mut R) -> Result<Self, TransactionErro...
function serialize (line 556) | pub fn serialize(&self, raw: bool) -> Result<Vec<u8>, TransactionError> {
function sign (line 592) | pub fn sign(
type BitcoinTransactionOutput (line 647) | pub struct BitcoinTransactionOutput {
method new (line 656) | pub fn new<N: BitcoinNetwork>(
method omni_data_output (line 668) | pub fn omni_data_output(
method read (line 681) | pub fn read<R: Read>(mut reader: &mut R) -> Result<Self, TransactionEr...
method serialize (line 698) | pub fn serialize(&self) -> Result<Vec<u8>, TransactionError> {
type BitcoinTransactionId (line 710) | pub struct BitcoinTransactionId {
method fmt (line 718) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
type BitcoinTransactionParameters (line 725) | pub struct BitcoinTransactionParameters<N: BitcoinNetwork> {
function new (line 740) | pub fn new(
function read (line 754) | pub fn read<R: Read>(mut reader: R) -> Result<Self, TransactionError> {
type BitcoinTransaction (line 813) | pub struct BitcoinTransaction<N: BitcoinNetwork> {
function fmt (line 819) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
type Address (line 825) | type Address = BitcoinAddress<N>;
type Format (line 826) | type Format = BitcoinFormat;
type PublicKey (line 827) | type PublicKey = BitcoinPublicKey<N>;
type TransactionId (line 828) | type TransactionId = BitcoinTransactionId;
type TransactionParameters (line 829) | type TransactionParameters = BitcoinTransactionParameters<N>;
method new (line 832) | fn new(parameters: &Self::TransactionParameters) -> Result<Self, Transac...
method from_bytes (line 840) | fn from_bytes(transaction: &[u8]) -> Result<Self, TransactionError> {
method to_bytes (line 847) | fn to_bytes(&self) -> Result<Vec<u8>, TransactionError> {
method to_transaction_id (line 890) | fn to_transaction_id(&self) -> Result<Self::TransactionId, TransactionEr...
method sign (line 900) | fn sign(&mut self, _signature: Vec<u8>, _recid: u8) -> Result<Vec<u8>, T...
function p2pkh_hash_preimage (line 910) | pub fn p2pkh_hash_preimage(
function segwit_hash_preimage (line 933) | pub fn segwit_hash_preimage(
function to_transaction_bytes_without_witness (line 1018) | pub fn to_transaction_bytes_without_witness(&self) -> Result<Vec<u8>, Tr...
function input (line 1038) | pub fn input(
function digest (line 1051) | pub fn digest(&mut self, index: u32) -> Result<Vec<u8>, TransactionError> {
function set_segwit (line 1066) | pub fn set_segwit(&mut self) -> Result<(), TransactionError> {
type Err (line 1086) | type Err = TransactionError;
method from_str (line 1088) | fn from_str(transaction: &str) -> Result<Self, Self::Err> {
FILE: crates/anychain-bitcoin/src/witness_program.rs
type WitnessProgramError (line 29) | pub enum WitnessProgramError {
method from (line 47) | fn from(error: WitnessProgramError) -> Self {
method from (line 53) | fn from(error: WitnessProgramError) -> Self {
type WitnessProgram (line 59) | pub struct WitnessProgram {
method new (line 68) | pub fn new(program: &[u8]) -> Result<Self, WitnessProgramError> {
method validate (line 93) | pub fn validate(&self) -> Result<(), WitnessProgramError> {
method to_scriptpubkey (line 118) | pub fn to_scriptpubkey(&self) -> Vec<u8> {
type Err (line 133) | type Err = WitnessProgramError;
method from_str (line 136) | fn from_str(s: &str) -> Result<Self, Self::Err> {
function test_from_str (line 148) | fn test_from_str(program_str: &str, expected_version: u8, expected_progr...
function test_to_scriptpubkey (line 154) | fn test_to_scriptpubkey(version: u8, program: &[u8], expected_scriptpubk...
constant VALID_P2SH_P2WPKH_PROGRAMS (line 168) | const VALID_P2SH_P2WPKH_PROGRAMS: [(&str, u8, &[u8], &[u8]); 1] = [(
function from_str (line 182) | fn from_str() {
function to_scriptpubkey (line 191) | fn to_scriptpubkey() {
constant VALID_P2SH_P2WSH_PROGRAMS (line 203) | const VALID_P2SH_P2WSH_PROGRAMS: [(&str, u8, &[u8], &[u8]); 1] = [(
function from_str (line 219) | fn from_str() {
function to_scriptpubkey (line 228) | fn to_scriptpubkey() {
constant VALID_OP_1_PROGRAMS (line 240) | const VALID_OP_1_PROGRAMS: [(&str, u8, &[u8], &[u8]); 1] = [(
function from_str (line 256) | fn from_str() {
function to_scriptpubkey (line 265) | fn to_scriptpubkey() {
constant INVALID_VERSION_PROGRAM (line 280) | const INVALID_VERSION_PROGRAM: &[u8] = &[0x19, 0x03, 0x00, 0x00, 0x00];
constant INVALID_LENGTH_FOR_VERSION (line 281) | const INVALID_LENGTH_FOR_VERSION: &[u8] = &[
constant INVALID_LENGTH_PROGRAM (line 286) | const INVALID_LENGTH_PROGRAM: &[u8] = &[0x19];
constant INVALID_LENGTH_PROGRAM_TOO_LONG (line 287) | const INVALID_LENGTH_PROGRAM_TOO_LONG: &[u8] = &[
function new_invalid_version (line 295) | fn new_invalid_version() {
function new_invalid_length (line 305) | fn new_invalid_length() {
function new_invalid_program_length_for_version (line 315) | fn new_invalid_program_length_for_version() {
function new_invalid_program_length_too_long (line 325) | fn new_invalid_program_length_too_long() {
constant INVALID_P2SH_P2WPKH_PROGRAM_LENGTH (line 338) | const INVALID_P2SH_P2WPKH_PROGRAM_LENGTH: &str =
constant INVALID_P2SH_P2WSH_PROGRAM_LENGTH (line 340) | const INVALID_P2SH_P2WSH_PROGRAM_LENGTH: &str =
constant INVALID_OP_1_PROGRAM_LENGTH (line 342) | const INVALID_OP_1_PROGRAM_LENGTH: &str =
constant INVALID_HEX_STR (line 344) | const INVALID_HEX_STR: &str = "001122zzxxyy";
function from_str_invalid_p2sh_p2wpkh_program_len (line 347) | fn from_str_invalid_p2sh_p2wpkh_program_len() {
function from_str_invalid_p2sh_p2wsh_program_len (line 357) | fn from_str_invalid_p2sh_p2wsh_program_len() {
function from_str_invalid_op_1_program_len (line 367) | fn from_str_invalid_op_1_program_len() {
function from_str_invalid_hex_str (line 377) | fn from_str_invalid_hex_str() {
FILE: crates/anychain-cardano/examples/transfer-ada.rs
constant MNEMONIC_ALICE (line 7) | const MNEMONIC_ALICE: &str = "toe deal rival umbrella oak inch water hov...
constant MNEMONIC_BOB (line 9) | const MNEMONIC_BOB: &str = "rifle suffer defense test system measure dis...
type CardanoTransactionParameters (line 11) | struct CardanoTransactionParameters {
function derive_key (line 28) | fn derive_key(
function create_account (line 43) | pub fn create_account(mnemonic_str: &str) -> Address {
function create_signing_key (line 66) | pub fn create_signing_key(mnemonic_str: &str) -> String {
function harden (line 81) | fn harden(index: u32) -> u32 {
constant MAX_VALUE_SIZE (line 103) | const MAX_VALUE_SIZE: u32 = 4000;
constant MAX_TX_SIZE (line 104) | const MAX_TX_SIZE: u32 = 8000;
function create_linear_fee (line 106) | fn create_linear_fee(coefficient: u64, constant: u64) -> LinearFee {
function create_default_linear_fee (line 109) | fn create_default_linear_fee() -> LinearFee {
function create_tx_builder_full (line 114) | fn create_tx_builder_full(
function create_tx_builder (line 140) | fn create_tx_builder(
function create_tx_builder_with_fee (line 155) | fn create_tx_builder_with_fee(linear_fee: LinearFee) -> TransactionBuild...
function create_default_tx_builder (line 159) | fn create_default_tx_builder() -> TransactionBuilder {
function build_tx_with_change (line 163) | pub fn build_tx_with_change(params: &CardanoTransactionParameters) -> Ve...
function main (line 255) | async fn main() -> BlockfrostResult<()> {
FILE: crates/anychain-cardano/src/address.rs
type CardanoAddress (line 13) | pub struct CardanoAddress(pub cml_chain::address::Address);
type SecretKey (line 16) | type SecretKey = Scalar;
type Format (line 17) | type Format = CardanoFormat;
type PublicKey (line 18) | type PublicKey = CardanoPublicKey;
method from_secret_key (line 20) | fn from_secret_key(
method from_public_key (line 27) | fn from_public_key(
type Err (line 36) | type Err = AddressError;
method from_str (line 38) | fn from_str(addr: &str) -> Result<Self, Self::Err> {
method fmt (line 46) | fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
function test (line 59) | fn test() {
FILE: crates/anychain-cardano/src/amount.rs
type CardanoAmount (line 12) | pub struct CardanoAmount(pub u64);
method from_u64 (line 47) | pub fn from_u64(lovelace: u64) -> Self {
method from_u64_str (line 51) | pub fn from_u64_str(value: &str) -> Result<u64, AmountError> {
method from_lovelace (line 57) | pub fn from_lovelace(lovelace_value: &str) -> Result<Self, AmountError> {
method from_ada (line 62) | pub fn from_ada(sol_value: &str) -> Result<Self, AmountError> {
method fmt (line 84) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
type Denomination (line 14) | pub enum Denomination {
method precision (line 22) | fn precision(self) -> u64 {
method fmt (line 32) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
type Output (line 70) | type Output = Self;
method add (line 71) | fn add(self, rhs: Self) -> Self {
type Output (line 77) | type Output = Self;
method sub (line 78) | fn sub(self, rhs: Self) -> Self::Output {
function test_from_lovelace (line 94) | fn test_from_lovelace(lovelace_value: &str, expected_amount: &str) {
function test_from_ada (line 99) | fn test_from_ada(ada_value: &str, expected_amount: &str) {
type AmountDenominationTestCase (line 104) | pub struct AmountDenominationTestCase {
constant TEST_AMOUNTS (line 109) | const TEST_AMOUNTS: [AmountDenominationTestCase; 2] = [
function test_lovelace_conversion (line 121) | fn test_lovelace_conversion() {
function test_sol_conversion (line 128) | fn test_sol_conversion() {
function test_addition (line 134) | fn test_addition(a: &str, b: &str, result: &str) {
function test_subtraction (line 142) | fn test_subtraction(a: &str, b: &str, result: &str) {
constant TEST_VALUES (line 152) | const TEST_VALUES: [(&str, &str, &str); 5] = [
function test_valid_addition (line 161) | fn test_valid_addition() {
FILE: crates/anychain-cardano/src/format.rs
type CardanoFormat (line 8) | pub enum CardanoFormat {
method fmt (line 25) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
method default (line 17) | fn default() -> Self {
function test_display (line 40) | fn test_display() {
FILE: crates/anychain-cardano/src/network.rs
type CardanoNetwork (line 11) | pub enum CardanoNetwork {
method info (line 19) | pub fn info(&self) -> CardanoNetworkInfo {
type CardanoNetworkInfo (line 29) | pub struct CardanoNetworkInfo {
method new (line 34) | pub fn new(network_id: u8, protocol_magic: u32) -> Self {
method network_id (line 40) | pub fn network_id(&self) -> u8 {
method protocol_magic (line 43) | pub fn protocol_magic(&self) -> u32 {
method mainnet (line 46) | pub fn mainnet() -> CardanoNetworkInfo {
method preprod (line 52) | pub fn preprod() -> CardanoNetworkInfo {
method preview (line 58) | pub fn preview() -> CardanoNetworkInfo {
FILE: crates/anychain-cardano/src/public_key.rs
type CardanoPublicKey (line 15) | pub struct CardanoPublicKey(pub ed25519_dalek::VerifyingKey);
method fmt (line 59) | fn fmt(&self, _: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
type SecretKey (line 18) | type SecretKey = Scalar;
type Address (line 19) | type Address = CardanoAddress;
type Format (line 20) | type Format = CardanoFormat;
method from_secret_key (line 22) | fn from_secret_key(secret_key: &Self::SecretKey) -> Self {
method to_address (line 29) | fn to_address(&self, format: &Self::Format) -> Result<Self::Address, Add...
type Err (line 51) | type Err = PublicKeyError;
method from_str (line 53) | fn from_str(_: &str) -> Result<Self, Self::Err> {
FILE: crates/anychain-cardano/src/transaction.rs
type Input (line 23) | pub struct Input {
type Output (line 31) | pub struct Output {
type CardanoTransactionParameters (line 37) | pub struct CardanoTransactionParameters {
type CardanoSignature (line 45) | pub struct CardanoSignature {
type CardanoTransaction (line 51) | pub struct CardanoTransaction {
method sign (line 75) | pub fn sign(&mut self, sigs: Vec<CardanoSignature>) -> Result<Vec<u8>,...
type Err (line 57) | type Err = TransactionError;
method from_str (line 58) | fn from_str(_: &str) -> Result<Self, Self::Err> {
type CardanoTransactionId (line 64) | pub struct CardanoTransactionId(pub [u8; 32]);
method fmt (line 67) | fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
type Address (line 82) | type Address = CardanoAddress;
type Format (line 83) | type Format = CardanoFormat;
type PublicKey (line 84) | type PublicKey = CardanoPublicKey;
type TransactionId (line 85) | type TransactionId = CardanoTransactionId;
type TransactionParameters (line 86) | type TransactionParameters = CardanoTransactionParameters;
method new (line 88) | fn new(params: &Self::TransactionParameters) -> Result<Self, Transaction...
method sign (line 95) | fn sign(&mut self, _: Vec<u8>, _: u8) -> Result<Vec<u8>, TransactionErro...
method to_bytes (line 99) | fn to_bytes(&self) -> Result<Vec<u8>, TransactionError> {
method from_bytes (line 187) | fn from_bytes(stream: &[u8]) -> Result<Self, TransactionError> {
method to_transaction_id (line 224) | fn to_transaction_id(&self) -> Result<Self::TransactionId, TransactionEr...
FILE: crates/anychain-cardano/src/util.rs
constant MAX_VALUE_SIZE (line 7) | const MAX_VALUE_SIZE: u32 = 4000;
constant MAX_TX_SIZE (line 8) | const MAX_TX_SIZE: u32 = 8000;
function create_linear_fee (line 10) | fn create_linear_fee(coefficient: u64, constant: u64) -> LinearFee {
function create_default_linear_fee (line 14) | fn create_default_linear_fee() -> LinearFee {
function create_tx_builder_full (line 19) | fn create_tx_builder_full(
function create_tx_builder (line 45) | fn create_tx_builder(
function create_tx_builder_with_fee (line 60) | fn create_tx_builder_with_fee(linear_fee: LinearFee) -> TransactionBuild...
function create_default_tx_builder (line 64) | pub fn create_default_tx_builder() -> TransactionBuilder {
FILE: crates/anychain-cardano/tests/test_derive.rs
function harden (line 9) | fn harden(index: u32) -> u32 {
function derive_key (line 17) | fn derive_key(
function test_derive_alice (line 33) | fn test_derive_alice() {
function test_derive_bob (line 67) | fn test_derive_bob() {
function test_from_address (line 92) | fn test_from_address() {
FILE: crates/anychain-core/src/address.rs
type Address (line 12) | pub trait Address:
method from_secret_key (line 20) | fn from_secret_key(
method from_public_key (line 26) | fn from_public_key(
method is_valid (line 31) | fn is_valid(address: &str) -> bool {
type AddressError (line 37) | pub enum AddressError {
method from (line 76) | fn from(error: crate::no_std::io::Error) -> Self {
method from (line 82) | fn from(error: crate::no_std::FromUtf8Error) -> Self {
method from (line 88) | fn from(msg: &'static str) -> Self {
method from (line 94) | fn from(error: PublicKeyError) -> Self {
method from (line 100) | fn from(error: base58::FromBase58Error) -> Self {
method from (line 106) | fn from(error: bech32::Error) -> Self {
method from (line 112) | fn from(error: core::str::Utf8Error) -> Self {
method from (line 118) | fn from(error: hex::FromHexError) -> Self {
method from (line 124) | fn from(error: rand_core::Error) -> Self {
FILE: crates/anychain-core/src/amount.rs
type Amount (line 11) | pub trait Amount:
type AmountError (line 17) | pub enum AmountError {
function to_basic_unit (line 29) | pub fn to_basic_unit(value: &str, mut denomination: u32) -> String {
function to_basic_unit_u64 (line 96) | pub fn to_basic_unit_u64(value: &str, mut denomination: u64) -> String {
function test (line 163) | fn test() {
FILE: crates/anychain-core/src/error.rs
type Error (line 10) | pub enum Error {
FILE: crates/anychain-core/src/format.rs
type Format (line 11) | pub trait Format:
type FormatError (line 17) | pub enum FormatError {
FILE: crates/anychain-core/src/network.rs
type Network (line 11) | pub trait Network:
constant NAME (line 14) | const NAME: &'static str;
type NetworkError (line 18) | pub enum NetworkError {
FILE: crates/anychain-core/src/no_std/io.rs
type Read (line 5) | pub trait Read {
method read (line 6) | fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>;
method read_exact (line 7) | fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>;
method read (line 12) | fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error> {
method read_exact (line 17) | fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error> {
method read (line 24) | fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error> {
method read_exact (line 42) | fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error> {
type Write (line 62) | pub trait Write {
method write (line 63) | fn write(&mut self, buf: &[u8]) -> Result<usize, Error>;
method write_all (line 64) | fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>;
method write (line 69) | fn write(&mut self, buf: &[u8]) -> Result<usize, Error> {
method write_all (line 74) | fn write_all(&mut self, buf: &[u8]) -> Result<(), Error> {
method write (line 81) | fn write(&mut self, buf: &[u8]) -> Result<usize, Error> {
method write_all (line 90) | fn write_all(&mut self, buf: &[u8]) -> Result<(), Error> {
method write (line 106) | fn write(&mut self, buf: &[u8]) -> Result<usize, Error> {
method write_all (line 112) | fn write_all(&mut self, buf: &[u8]) -> Result<(), Error> {
type Error (line 119) | pub struct Error;
method fmt (line 123) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
FILE: crates/anychain-core/src/public_key.rs
type PublicKey (line 14) | pub trait PublicKey: Clone + Debug + Display + FromStr + Send + Sync + '...
method from_secret_key (line 20) | fn from_secret_key(secret_key: &Self::SecretKey) -> Self;
method to_address (line 23) | fn to_address(&self, format: &Self::Format) -> Result<Self::Address, A...
type PublicKeyError (line 27) | pub enum PublicKeyError {
method from (line 48) | fn from(error: crate::no_std::io::Error) -> Self {
method from (line 54) | fn from(error: base58::FromBase58Error) -> Self {
method from (line 60) | fn from(error: bech32::Error) -> Self {
method from (line 66) | fn from(error: hex::FromHexError) -> Self {
FILE: crates/anychain-core/src/transaction.rs
function func_selector (line 20) | pub fn func_selector(func_signature: &str) -> [u8; 4] {
type TransactionId (line 27) | pub trait TransactionId:
type Transaction (line 33) | pub trait Transaction: Clone + Send + Sync + 'static {
method new (line 41) | fn new(parameters: &Self::TransactionParameters) -> Result<Self, Trans...
method sign (line 44) | fn sign(&mut self, signature: Vec<u8>, recid: u8) -> Result<Vec<u8>, T...
method from_bytes (line 47) | fn from_bytes(transaction: &[u8]) -> Result<Self, TransactionError>;
method to_bytes (line 50) | fn to_bytes(&self) -> Result<Vec<u8>, TransactionError>;
method to_transaction_id (line 53) | fn to_transaction_id(&self) -> Result<Self::TransactionId, Transaction...
type TransactionError (line 57) | pub enum TransactionError {
method from (line 158) | fn from(error: crate::no_std::io::Error) -> Self {
method from (line 164) | fn from(msg: &'static str) -> Self {
method from (line 170) | fn from(error: ()) -> Self {
method from (line 176) | fn from(error: base58::FromBase58Error) -> Self {
method from (line 182) | fn from(error: bech32::Error) -> Self {
method from (line 188) | fn from(error: core::num::ParseIntError) -> Self {
method from (line 194) | fn from(error: core::str::ParseBoolError) -> Self {
method from (line 200) | fn from(error: hex::FromHexError) -> Self {
method from (line 218) | fn from(error: serde_json::error::Error) -> Self {
function test_func_selector (line 228) | fn test_func_selector() {
FILE: crates/anychain-core/src/utilities/crypto.rs
function sha256 (line 6) | pub fn sha256(input: &[u8]) -> [u8; 32] {
function sha512 (line 13) | pub fn sha512(input: &[u8]) -> [u8; 64] {
function keccak256 (line 20) | pub fn keccak256(input: &[u8]) -> [u8; 32] {
function checksum (line 26) | pub fn checksum(data: &[u8]) -> Vec<u8> {
function hash160 (line 30) | pub fn hash160(bytes: &[u8]) -> Vec<u8> {
FILE: crates/anychain-core/src/utilities/mod.rs
function to_hex_string (line 6) | pub fn to_hex_string(bytes: &[u8]) -> String {
FILE: crates/anychain-ethereum/src/address.rs
type EthereumAddress (line 14) | pub struct EthereumAddress(String);
method checksum_address (line 42) | pub fn checksum_address(public_key: &EthereumPublicKey) -> Self {
method to_bytes (line 59) | pub fn to_bytes(&self) -> Result<Vec<u8>, Error> {
method len (line 67) | pub fn len(&self) -> usize {
method is_empty (line 71) | pub fn is_empty(&self) -> bool {
type Error (line 77) | type Error = AddressError;
method try_from (line 79) | fn try_from(address: &'a str) -> Result<Self, Self::Error> {
method fmt (line 105) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
type SecretKey (line 17) | type SecretKey = SecretKey;
type Format (line 18) | type Format = EthereumFormat;
type PublicKey (line 19) | type PublicKey = EthereumPublicKey;
method from_secret_key (line 22) | fn from_secret_key(
method from_public_key (line 30) | fn from_public_key(
type Err (line 85) | type Err = AddressError;
method from_str (line 87) | fn from_str(address: &str) -> Result<Self, Self::Err> {
function test_from_str (line 115) | fn test_from_str(expected_address: &str) {
function test_to_str (line 120) | fn test_to_str(expected_address: &str, address: &EthereumAddress) {
function test_public_key_bytes_to_address (line 125) | fn test_public_key_bytes_to_address() {
constant KEYPAIRS (line 146) | const KEYPAIRS: [(&str, &str); 5] = [
function from_str (line 170) | fn from_str() {
function to_str (line 177) | fn to_str() {
function test_address (line 186) | fn test_address() {
FILE: crates/anychain-ethereum/src/format.rs
type EthereumFormat (line 7) | pub enum EthereumFormat {
method fmt (line 14) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
FILE: crates/anychain-ethereum/src/network/mainnet.rs
type Ethereum (line 4) | pub struct Ethereum;
constant CHAIN_ID (line 7) | const CHAIN_ID: u32 = 1;
type EthereumClassic (line 11) | pub struct EthereumClassic;
constant CHAIN_ID (line 14) | const CHAIN_ID: u32 = 61;
type Polygon (line 18) | pub struct Polygon;
constant CHAIN_ID (line 21) | const CHAIN_ID: u32 = 137;
type Arbitrum (line 25) | pub struct Arbitrum;
constant CHAIN_ID (line 28) | const CHAIN_ID: u32 = 42161;
type Avalanche (line 32) | pub struct Avalanche;
constant CHAIN_ID (line 35) | const CHAIN_ID: u32 = 43114;
type Base (line 39) | pub struct Base;
constant CHAIN_ID (line 42) | const CHAIN_ID: u32 = 8453;
type BinanceSmartChain (line 46) | pub struct BinanceSmartChain;
constant CHAIN_ID (line 49) | const CHAIN_ID: u32 = 56;
type HuobiEco (line 53) | pub struct HuobiEco;
constant CHAIN_ID (line 56) | const CHAIN_ID: u32 = 128;
type Okex (line 60) | pub struct Okex;
constant CHAIN_ID (line 63) | const CHAIN_ID: u32 = 66;
type OpBnb (line 67) | pub struct OpBnb;
constant CHAIN_ID (line 70) | const CHAIN_ID: u32 = 204;
type Optimism (line 74) | pub struct Optimism;
constant CHAIN_ID (line 77) | const CHAIN_ID: u32 = 10;
type Linea (line 81) | pub struct Linea;
constant CHAIN_ID (line 84) | const CHAIN_ID: u32 = 59144;
type Xlayer (line 88) | pub struct Xlayer;
constant CHAIN_ID (line 91) | const CHAIN_ID: u32 = 196;
type Sei (line 95) | pub struct Sei;
constant CHAIN_ID (line 98) | const CHAIN_ID: u32 = 1329;
type Cro (line 102) | pub struct Cro;
constant CHAIN_ID (line 105) | const CHAIN_ID: u32 = 25;
type Mova (line 109) | pub struct Mova;
constant CHAIN_ID (line 112) | const CHAIN_ID: u32 = 61900;
type Ink (line 116) | pub struct Ink;
constant CHAIN_ID (line 119) | const CHAIN_ID: u32 = 57073;
type Morph (line 123) | pub struct Morph;
constant CHAIN_ID (line 126) | const CHAIN_ID: u32 = 2818;
type Maca (line 130) | pub struct Maca;
constant CHAIN_ID (line 133) | const CHAIN_ID: u32 = 777178;
type Uni (line 137) | pub struct Uni;
constant CHAIN_ID (line 140) | const CHAIN_ID: u32 = 130;
FILE: crates/anychain-ethereum/src/network/mod.rs
type EthereumNetwork (line 1) | pub trait EthereumNetwork: Copy + Clone + Send + Sync + 'static {
constant CHAIN_ID (line 2) | const CHAIN_ID: u32;
FILE: crates/anychain-ethereum/src/network/testnet.rs
type Sepolia (line 4) | pub struct Sepolia;
constant CHAIN_ID (line 8) | const CHAIN_ID: u32 = 11155111;
type Goerli (line 12) | pub struct Goerli;
constant CHAIN_ID (line 16) | const CHAIN_ID: u32 = 5;
type Kotti (line 20) | pub struct Kotti;
constant CHAIN_ID (line 24) | const CHAIN_ID: u32 = 6;
type Mumbai (line 28) | pub struct Mumbai;
constant CHAIN_ID (line 32) | const CHAIN_ID: u32 = 80001;
type Amoy (line 36) | pub struct Amoy;
constant CHAIN_ID (line 40) | const CHAIN_ID: u32 = 80002;
type ArbitrumGoerli (line 44) | pub struct ArbitrumGoerli;
constant CHAIN_ID (line 48) | const CHAIN_ID: u32 = 421613;
type AvalancheTestnet (line 52) | pub struct AvalancheTestnet;
constant CHAIN_ID (line 56) | const CHAIN_ID: u32 = 43113;
type BaseGoerli (line 60) | pub struct BaseGoerli;
constant CHAIN_ID (line 64) | const CHAIN_ID: u32 = 84531;
type BinanceSmartChainTestnet (line 68) | pub struct BinanceSmartChainTestnet;
constant CHAIN_ID (line 72) | const CHAIN_ID: u32 = 97;
type HuobiEcoTestnet (line 76) | pub struct HuobiEcoTestnet;
constant CHAIN_ID (line 80) | const CHAIN_ID: u32 = 256;
type OkexTestnet (line 84) | pub struct OkexTestnet;
constant CHAIN_ID (line 88) | const CHAIN_ID: u32 = 65;
type OpBnbTestnet (line 92) | pub struct OpBnbTestnet;
constant CHAIN_ID (line 96) | const CHAIN_ID: u32 = 5611;
type OptimismGoerli (line 100) | pub struct OptimismGoerli;
constant CHAIN_ID (line 104) | const CHAIN_ID: u32 = 420;
type LineaSepolia (line 108) | pub struct LineaSepolia;
constant CHAIN_ID (line 112) | const CHAIN_ID: u32 = 59141;
type XlayerTestnet (line 116) | pub struct XlayerTestnet;
constant CHAIN_ID (line 120) | const CHAIN_ID: u32 = 195;
type SeiTestnet (line 124) | pub struct SeiTestnet;
constant CHAIN_ID (line 128) | const CHAIN_ID: u32 = 1328;
type CroTestnet (line 132) | pub struct CroTestnet;
constant CHAIN_ID (line 136) | const CHAIN_ID: u32 = 338;
type MovaTestnet (line 140) | pub struct MovaTestnet;
constant CHAIN_ID (line 144) | const CHAIN_ID: u32 = 10323;
type InkTestnet (line 148) | pub struct InkTestnet;
constant CHAIN_ID (line 152) | const CHAIN_ID: u32 = 763373;
type MorphTestnet (line 156) | pub struct MorphTestnet;
constant CHAIN_ID (line 160) | const CHAIN_ID: u32 = 2710;
type MacaTestnet (line 164) | pub struct MacaTestnet;
constant CHAIN_ID (line 167) | const CHAIN_ID: u32 = 777177;
type UniSepolia (line 171) | pub struct UniSepolia;
constant CHAIN_ID (line 174) | const CHAIN_ID: u32 = 1301;
FILE: crates/anychain-ethereum/src/public_key.rs
type EthereumPublicKey (line 8) | pub struct EthereumPublicKey(libsecp256k1::PublicKey);
method from_secp256k1_public_key (line 28) | pub fn from_secp256k1_public_key(public_key: libsecp256k1::PublicKey) ...
method from_slice (line 32) | pub fn from_slice(sl: &[u8]) -> Result<Self, PublicKeyError> {
method to_secp256k1_public_key (line 39) | pub fn to_secp256k1_public_key(&self) -> libsecp256k1::PublicKey {
type SecretKey (line 11) | type SecretKey = libsecp256k1::SecretKey;
type Address (line 12) | type Address = EthereumAddress;
type Format (line 13) | type Format = EthereumFormat;
method from_secret_key (line 16) | fn from_secret_key(secret_key: &Self::SecretKey) -> Self {
method to_address (line 21) | fn to_address(&self, _format: &Self::Format) -> Result<Self::Address, Ad...
type Err (line 45) | type Err = PublicKeyError;
method from_str (line 47) | fn from_str(public_key: &str) -> Result<Self, Self::Err> {
method fmt (line 58) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
function test_from_secret_key (line 71) | fn test_from_secret_key(expected_public_key: &EthereumPublicKey, secret_...
function test_to_address (line 76) | fn test_to_address(expected_address: &EthereumAddress, public_key: &Ethe...
function test_from_str (line 81) | fn test_from_str(expected_public_key: &str, expected_address: &str) {
function test_to_str (line 88) | fn test_to_str(expected_public_key: &str, public_key: &EthereumPublicKey) {
constant KEYPAIRS (line 95) | const KEYPAIRS: [(&str, &str, &str); 5] = [
function from_private_key (line 124) | fn from_private_key() {
function to_address (line 134) | fn to_address() {
function from_str (line 143) | fn from_str() {
function to_str (line 152) | fn to_str() {
function test_pubkey (line 160) | fn test_pubkey() {
function test_checksum_address_invalid (line 172) | fn test_checksum_address_invalid() {
function address_gen (line 192) | fn address_gen() {
function test_public_key_from_invalid_slice (line 225) | fn test_public_key_from_invalid_slice() {
FILE: crates/anychain-ethereum/src/transaction/contract.rs
function erc20_transfer_func (line 9) | pub fn erc20_transfer_func() -> Function {
function eip3009_transfer_func (line 31) | pub fn eip3009_transfer_func() -> Function {
function schedule_func (line 98) | pub fn schedule_func() -> Function {
function execute_batch_transfer_func (line 119) | pub fn execute_batch_transfer_func() -> Function {
function erc20_transfer (line 155) | pub fn erc20_transfer(address: &EthereumAddress, amount: U256) -> Vec<u8> {
function decode (line 165) | pub fn decode(data: Vec<u8>) -> Result<Value, TransactionError> {
FILE: crates/anychain-ethereum/src/transaction/eip1559.rs
type Eip1559TransactionParameters (line 11) | pub struct Eip1559TransactionParameters {
method to_rlp (line 24) | pub fn to_rlp(&self, array_len: usize) -> Result<RlpStream, Transactio...
method get_data (line 46) | pub fn get_data(&self) -> Vec<u8> {
type Eip1559TransactionSignature (line 52) | pub struct Eip1559TransactionSignature {
type AccessItem (line 59) | pub struct AccessItem {
method rlp_append (line 65) | fn rlp_append(&self, s: &mut RlpStream) {
method decode (line 73) | fn decode(rlp: &rlp::Rlp) -> Result<Self, DecoderError> {
type Eip1559Transaction (line 85) | pub struct Eip1559Transaction<N: EthereumNetwork> {
function restore_sender (line 93) | pub fn restore_sender(&mut self) -> Result<(), TransactionError> {
type Address (line 121) | type Address = EthereumAddress;
type Format (line 122) | type Format = EthereumFormat;
type PublicKey (line 123) | type PublicKey = EthereumPublicKey;
type TransactionId (line 124) | type TransactionId = EthereumTransactionId;
type TransactionParameters (line 125) | type TransactionParameters = Eip1559TransactionParameters;
method new (line 127) | fn new(params: &Self::TransactionParameters) -> Result<Self, Transaction...
method sign (line 136) | fn sign(&mut self, rs: Vec<u8>, recid: u8) -> Result<Vec<u8>, Transactio...
method to_bytes (line 150) | fn to_bytes(&self) -> Result<Vec<u8>, TransactionError> {
method from_bytes (line 166) | fn from_bytes(tx: &[u8]) -> Result<Self, TransactionError> {
method to_transaction_id (line 211) | fn to_transaction_id(&self) -> Result<Self::TransactionId, TransactionEr...
type Err (line 219) | type Err = TransactionError;
method from_str (line 221) | fn from_str(tx: &str) -> Result<Self, Self::Err> {
function fmt (line 231) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
function test_eip1559_tx (line 256) | fn test_eip1559_tx() {
function test_eip3009_tx (line 286) | fn test_eip3009_tx() {
FILE: crates/anychain-ethereum/src/transaction/eip3009.rs
type EIP712TypedData (line 10) | trait EIP712TypedData {
method type_hash (line 11) | fn type_hash(&self) -> Result<Vec<u8>, TransactionError>;
method encode (line 12) | fn encode(&self) -> Result<Vec<u8>, TransactionError>;
method hash_struct (line 13) | fn hash_struct(&self) -> Result<Vec<u8>, TransactionError> {
method type_hash (line 26) | fn type_hash(&self) -> Result<Vec<u8>, TransactionError> {
method encode (line 33) | fn encode(&self) -> Result<Vec<u8>, TransactionError> {
method type_hash (line 81) | fn type_hash(&self) -> Result<Vec<u8>, TransactionError> {
method encode (line 86) | fn encode(&self) -> Result<Vec<u8>, TransactionError> {
type EIP712Domain (line 18) | struct EIP712Domain<N: EthereumNetwork> {
function new (line 55) | fn new(name: String, version: String, contract: String) -> Result<Self, ...
type TransferWithAuthorizationParameters (line 67) | pub struct TransferWithAuthorizationParameters<N: EthereumNetwork> {
function new (line 125) | pub fn new(
function sign (line 169) | pub fn sign(&mut self, recid: u8, r: Vec<u8>, s: Vec<u8>) -> Result<Vec<...
function digest (line 176) | pub fn digest(&self) -> Result<Vec<u8>, TransactionError> {
function to_data (line 193) | fn to_data(&self) -> Result<Vec<u8>, TransactionError> {
function test_eip3009_tx (line 240) | fn test_eip3009_tx() {
FILE: crates/anychain-ethereum/src/transaction/eip7702.rs
type Authorization (line 14) | pub struct Authorization {
method digest (line 24) | pub fn digest(&self) -> Vec<u8> {
method sign (line 35) | pub fn sign(&mut self, rs: Vec<u8>, recid: u8) {
method restore_sender (line 41) | pub fn restore_sender(&self) -> Result<EthereumAddress, TransactionErr...
method rlp_append (line 55) | fn rlp_append(&self, s: &mut RlpStream) {
method decode (line 67) | fn decode(rlp: &rlp::Rlp) -> Result<Self, DecoderError> {
type Eip7702TransactionParameters (line 90) | pub struct Eip7702TransactionParameters {
method to_rlp (line 104) | pub fn to_rlp(&self, array_len: usize) -> Result<RlpStream, Transactio...
method get_data (line 127) | pub fn get_data(&self) -> Vec<u8> {
type Eip7702TransactionSignature (line 133) | pub struct Eip7702TransactionSignature {
type Eip7702Transaction (line 140) | pub struct Eip7702Transaction<N: EthereumNetwork> {
function restore_sender (line 148) | pub fn restore_sender(&mut self) -> Result<(), TransactionError> {
type Address (line 176) | type Address = EthereumAddress;
type Format (line 177) | type Format = EthereumFormat;
type PublicKey (line 178) | type PublicKey = EthereumPublicKey;
type TransactionId (line 179) | type TransactionId = EthereumTransactionId;
type TransactionParameters (line 180) | type TransactionParameters = Eip7702TransactionParameters;
method new (line 182) | fn new(params: &Self::TransactionParameters) -> Result<Self, Transaction...
method sign (line 191) | fn sign(&mut self, rs: Vec<u8>, recid: u8) -> Result<Vec<u8>, Transactio...
method to_bytes (line 205) | fn to_bytes(&self) -> Result<Vec<u8>, TransactionError> {
method from_bytes (line 221) | fn from_bytes(tx: &[u8]) -> Result<Self, TransactionError> {
method to_transaction_id (line 281) | fn to_transaction_id(&self) -> Result<Self::TransactionId, TransactionEr...
type Err (line 289) | type Err = TransactionError;
method from_str (line 291) | fn from_str(tx: &str) -> Result<Self, Self::Err> {
function fmt (line 301) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
type Many2ManyTransfer (line 313) | pub struct Many2ManyTransfer<N: EthereumNetwork> {
function new (line 318) | pub fn new(transfers: Vec<One2ManyTransfer<N>>) -> Self {
function authorizations (line 322) | pub fn authorizations(&self) -> Result<Vec<Authorization>, TransactionEr...
function data (line 330) | pub fn data(&self) -> Result<Vec<u8>, TransactionError> {
type One2ManyTransfer (line 346) | pub struct One2ManyTransfer<N: EthereumNetwork> {
function new (line 372) | pub fn new(
function digest (line 391) | pub fn digest(&self, typ: u8) -> Result<Vec<u8>, TransactionError> {
function sign (line 417) | pub fn sign(&mut self, rs: Vec<u8>, recid: u8, typ: u8) -> Result<(), Tr...
function authorization (line 436) | pub fn authorization(&self) -> Result<Authorization, TransactionError> {
function data (line 459) | pub fn data(&self) -> Result<Vec<u8>, TransactionError> {
function to_token (line 491) | pub fn to_token(&self) -> Token {
type Transfer (line 500) | pub struct Transfer {
method new (line 507) | pub fn new(token: Option<String>, to: String, amount: String) -> Self {
method to_token (line 515) | pub fn to_token(&self) -> Token {
method from_token (line 532) | pub fn from_token(token: Token) -> Result<Self, TransactionError> {
method to_json (line 564) | pub fn to_json(&self) -> Value {
function _parse_mnemonic (line 603) | pub fn _parse_mnemonic(phrase: String) -> Value {
function create_sk (line 622) | pub fn create_sk(xprv: String, path: String) -> libsecp256k1::SecretKey {
function _create_address (line 630) | pub fn _create_address(xprv: String, path: String) -> EthereumAddress {
function test_tx (line 643) | fn test_tx() {
function test_decouple (line 680) | fn test_decouple() {
FILE: crates/anychain-ethereum/src/transaction/legacy.rs
type EthereumTransactionParameters (line 10) | pub struct EthereumTransactionParameters {
method to_rlp (line 20) | pub fn to_rlp(&self) -> Result<RlpStream, TransactionError> {
method get_data (line 39) | pub fn get_data(&self) -> Vec<u8> {
type EthereumTransactionSignature (line 45) | pub struct EthereumTransactionSignature {
type EthereumTransaction (line 52) | pub struct EthereumTransaction<N: EthereumNetwork> {
function restore_sender (line 63) | pub fn restore_sender(&mut self) -> Result<(), TransactionError> {
type Address (line 91) | type Address = EthereumAddress;
type Format (line 92) | type Format = EthereumFormat;
type PublicKey (line 93) | type PublicKey = EthereumPublicKey;
type TransactionId (line 94) | type TransactionId = EthereumTransactionId;
type TransactionParameters (line 95) | type TransactionParameters = EthereumTransactionParameters;
method new (line 97) | fn new(params: &Self::TransactionParameters) -> Result<Self, Transaction...
method sign (line 106) | fn sign(&mut self, rs: Vec<u8>, recid: u8) -> Result<Vec<u8>, Transactio...
method to_bytes (line 120) | fn to_bytes(&self) -> Result<Vec<u8>, TransactionError> {
method from_bytes (line 141) | fn from_bytes(tx: &[u8]) -> Result<Self, TransactionError> {
method to_transaction_id (line 180) | fn to_transaction_id(&self) -> Result<Self::TransactionId, TransactionEr...
type Err (line 188) | type Err = TransactionError;
method from_str (line 190) | fn from_str(tx: &str) -> Result<Self, Self::Err> {
function fmt (line 200) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
function test_legacy_tx (line 220) | fn test_legacy_tx() {
FILE: crates/anychain-ethereum/src/transaction/mod.rs
type EthereumTransactionId (line 17) | pub struct EthereumTransactionId {
method fmt (line 24) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
FILE: crates/anychain-ethereum/src/util.rs
function trim_leading_zeros (line 6) | pub(crate) fn trim_leading_zeros(v: &Vec<u8>) -> &[u8] {
function pad_zeros (line 19) | pub(crate) fn pad_zeros(v: &mut Vec<u8>, to_len: usize) {
function adapt1 (line 29) | pub(crate) fn adapt1<T>(v: Result<T, Error>) -> Result<T, TransactionErr...
function adapt2 (line 39) | pub(crate) fn adapt2<T>(v: Result<T, rlp::DecoderError>) -> Result<T, Tr...
function restore_sender (line 46) | pub(crate) fn restore_sender(
FILE: crates/anychain-filecoin/src/address.rs
type FilecoinAddress (line 28) | pub struct FilecoinAddress {
method new (line 64) | fn new(network: Network, protocol: Protocol, bz: &[u8]) -> Result<Self...
method from_bytes (line 72) | pub fn from_bytes(bz: &[u8]) -> Result<Self, Error> {
method new_id (line 82) | pub const fn new_id(id: u64) -> Self {
method new_secp256k1 (line 90) | pub fn new_secp256k1(pubkey: &[u8]) -> Result<Self, Error> {
method new_secp256k1_v2 (line 100) | pub fn new_secp256k1_v2(
method new_actor (line 111) | pub fn new_actor(data: &[u8]) -> Self {
method new_bls (line 119) | pub fn new_bls(pubkey: &[u8]) -> Result<Self, Error> {
method is_bls_zero_address (line 131) | pub fn is_bls_zero_address(&self) -> bool {
method protocol (line 139) | pub fn protocol(&self) -> Protocol {
method payload (line 145) | pub fn payload(&self) -> &Payload {
method into_payload (line 151) | pub fn into_payload(self) -> Payload {
method payload_bytes (line 156) | pub fn payload_bytes(&self) -> Vec<u8> {
method network (line 161) | pub fn network(&self) -> Network {
method set_network (line 166) | pub fn set_network(&mut self, network: Network) -> &mut Self {
method to_bytes (line 172) | pub fn to_bytes(self) -> Vec<u8> {
method id (line 177) | pub fn id(&self) -> Result<u64, Error> {
method fmt (line 186) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
method deserialize (line 270) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
type SecretKey (line 34) | type SecretKey = super::public_key::FilecoinSecretKey;
type Format (line 35) | type Format = FilecoinFormat;
type PublicKey (line 36) | type PublicKey = FilecoinPublicKey;
method from_secret_key (line 39) | fn from_secret_key(
method from_public_key (line 47) | fn from_public_key(
type Err (line 192) | type Err = Error;
method from_str (line 193) | fn from_str(addr: &str) -> Result<Self, Error> {
method serialize (line 260) | fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
function encode (line 282) | fn encode(addr: &FilecoinAddress) -> String {
function to_leb_bytes (line 306) | pub(crate) fn to_leb_bytes(id: u64) -> Result<Vec<u8>, Error> {
function from_leb_bytes (line 311) | pub(crate) fn from_leb_bytes(bz: &[u8]) -> Result<u64, Error> {
function validate_checksum (line 321) | pub fn validate_checksum(ingest: &[u8], expect: Vec<u8>) -> bool {
type Protocol (line 329) | pub enum Protocol {
method from_byte (line 342) | pub(super) fn from_byte(b: u8) -> Option<Protocol> {
method fmt (line 349) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
method from (line 426) | fn from(pl: Payload) -> Self {
method from (line 437) | fn from(pl: &Payload) -> Self {
type Payload (line 358) | pub enum Payload {
method to_raw_bytes (line 377) | pub fn to_raw_bytes(self) -> Vec<u8> {
method to_bytes (line 388) | pub fn to_bytes(self) -> Vec<u8> {
method new (line 402) | pub fn new(protocol: Protocol, payload: &[u8]) -> Result<Self, Error> {
method default (line 370) | fn default() -> Self {
type Error (line 449) | pub enum Error {
type Network (line 475) | pub enum Network {
method to_prefix (line 484) | pub(super) fn to_prefix(self) -> &'static str {
constant ADDRESS_ENCODER (line 493) | pub const ADDRESS_ENCODER: Encoding = new_encoding! {
constant PAYLOAD_HASH_LEN (line 499) | pub const PAYLOAD_HASH_LEN: usize = 20;
constant SECP_PUB_LEN (line 502) | pub const SECP_PUB_LEN: usize = 65;
constant BLS_PUB_LEN (line 505) | pub const BLS_PUB_LEN: usize = 48;
constant CHECKSUM_HASH_LEN (line 519) | pub const CHECKSUM_HASH_LEN: usize = 4;
constant MAX_ADDRESS_LEN (line 521) | const MAX_ADDRESS_LEN: usize = 84 + 2;
constant MAINNET_PREFIX (line 522) | const MAINNET_PREFIX: &str = "f";
constant TESTNET_PREFIX (line 523) | const TESTNET_PREFIX: &str = "t";
constant NETWORK_DEFAULT (line 527) | pub const NETWORK_DEFAULT: Network = Network::Testnet;
function base32_to_internal_address (line 533) | fn base32_to_internal_address() {
function test_mainnet_address (line 542) | fn test_mainnet_address() {
FILE: crates/anychain-filecoin/src/amount.rs
type FilecoinAmount (line 7) | pub type FilecoinAmount = BigInt;
type Denomination (line 9) | pub enum Denomination {
method precision (line 20) | fn precision(self) -> u32 {
method fmt (line 34) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
type FilecoinAmountConverter (line 51) | pub trait FilecoinAmountConverter {
method from_decimal_str (line 52) | fn from_decimal_str(val: &str) -> Self;
method from_atto_fil (line 54) | fn from_atto_fil(atto_fil_value: &str) -> Self;
method from_femto_fil (line 56) | fn from_femto_fil(femto_fil_value: &str) -> Self;
method from_pico_fil (line 58) | fn from_pico_fil(pico_fil_value: &str) -> Self;
method from_nano_fil (line 60) | fn from_nano_fil(nano_fil_value: &str) -> Self;
method from_micro_fil (line 62) | fn from_micro_fil(micro_fil_value: &str) -> Self;
method from_milli_fil (line 64) | fn from_milli_fil(milli_fil_value: &str) -> Self;
method from_fil (line 66) | fn from_fil(fil_value: &str) -> Self;
method add (line 68) | fn add(self, b: Self) -> Self;
method sub (line 70) | fn sub(self, b: Self) -> Self;
method from_decimal_str (line 74) | fn from_decimal_str(val: &str) -> Self {
method from_atto_fil (line 78) | fn from_atto_fil(atto_fil_value: &str) -> Self {
method from_femto_fil (line 82) | fn from_femto_fil(femto_fil_value: &str) -> Self {
method from_pico_fil (line 87) | fn from_pico_fil(pico_fil_value: &str) -> Self {
method from_nano_fil (line 92) | fn from_nano_fil(nano_fil_value: &str) -> Self {
method from_micro_fil (line 97) | fn from_micro_fil(micro_fil_value: &str) -> Self {
method from_milli_fil (line 102) | fn from_milli_fil(milli_fil_value: &str) -> Self {
method from_fil (line 107) | fn from_fil(fil_value: &str) -> Self {
method add (line 112) | fn add(self, b: Self) -> Self {
method sub (line 116) | fn sub(self, b: Self) -> Self {
function f (line 125) | fn f() {
FILE: crates/anychain-filecoin/src/format.rs
type FilecoinFormat (line 8) | pub enum FilecoinFormat {
method fmt (line 15) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
FILE: crates/anychain-filecoin/src/public_key.rs
type FilecoinSecretKey (line 10) | pub enum FilecoinSecretKey {
type FilecoinPublicKey (line 17) | pub enum FilecoinPublicKey {
method from_secp256k1_public_key (line 45) | pub fn from_secp256k1_public_key(public_key: libsecp256k1::PublicKey) ...
method to_secp256k1_public_key (line 50) | pub fn to_secp256k1_public_key(&self) -> libsecp256k1::PublicKey {
method from_bls_public_key (line 58) | pub fn from_bls_public_key(public_key: bls_signatures::PublicKey) -> S...
method to_bls_public_key (line 63) | pub fn to_bls_public_key(&self) -> bls_signatures::PublicKey {
type SecretKey (line 23) | type SecretKey = FilecoinSecretKey;
type Address (line 24) | type Address = FilecoinAddress;
type Format (line 25) | type Format = FilecoinFormat;
method from_secret_key (line 28) | fn from_secret_key(secret_key: &Self::SecretKey) -> Self {
method to_address (line 38) | fn to_address(&self, _format: &Self::Format) -> Result<Self::Address, Ad...
type Err (line 72) | type Err = PublicKeyError;
method from_str (line 74) | fn from_str(public_key: &str) -> Result<Self, Self::Err> {
method fmt (line 104) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
function test_public_key_from_str (line 124) | fn test_public_key_from_str() {
function test_public_key_secp256k1 (line 132) | fn test_public_key_secp256k1() {
function test_public_key_bls (line 156) | fn test_public_key_bls() {
FILE: crates/anychain-filecoin/src/transaction.rs
constant DAG_CBOR_CODEC (line 30) | const DAG_CBOR_CODEC: u64 = 0x71;
constant BLAKE2B_256_MULTIHASH_CODE (line 31) | const BLAKE2B_256_MULTIHASH_CODE: u64 = 0xb220;
function cid_from_cbor (line 33) | fn cid_from_cbor<T: ser::Serialize>(value: &T) -> anyhow::Result<Cid> {
type FilecoinTransactionParameters (line 43) | pub struct FilecoinTransactionParameters {
method cid (line 59) | pub fn cid(&self) -> anyhow::Result<Cid> {
method to_bytes (line 65) | pub fn to_bytes(&self) -> Vec<u8> {
method check (line 71) | pub fn check(self: &FilecoinTransactionParameters) -> anyhow::Result<(...
method deserialize (line 104) | fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
method from (line 402) | fn from(wrapper: ParameterJson) -> Self {
method serialize (line 83) | fn serialize<S>(&self, s: S) -> std::result::Result<S::Ok, S::Error>
type FilecoinSignatureType (line 150) | pub enum FilecoinSignatureType {
type FilecoinSignature (line 158) | pub struct FilecoinSignature {
method serialize (line 166) | fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
method deserialize (line 180) | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
type FilecoinTransactionId (line 208) | pub struct FilecoinTransactionId {
method fmt (line 215) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
type FilecoinTransaction (line 222) | pub struct FilecoinTransaction {
method cid (line 284) | pub fn cid(&self) -> anyhow::Result<Cid> {
method digest (line 288) | pub fn digest(&self) -> Result<Vec<u8>, TransactionError> {
method from (line 326) | fn from(wrapper: FilecoinTransactionJson) -> Self {
type Address (line 230) | type Address = FilecoinAddress;
type Format (line 231) | type Format = FilecoinFormat;
type PublicKey (line 232) | type PublicKey = FilecoinPublicKey;
type TransactionId (line 233) | type TransactionId = FilecoinTransactionId;
type TransactionParameters (line 234) | type TransactionParameters = FilecoinTransactionParameters;
method new (line 237) | fn new(parameters: &Self::TransactionParameters) -> Result<Self, Transac...
method from_bytes (line 245) | fn from_bytes(transaction: &[u8]) -> Result<Self, TransactionError> {
method sign (line 251) | fn sign(&mut self, mut signature: Vec<u8>, recid: u8) -> Result<Vec<u8>,...
method to_bytes (line 266) | fn to_bytes(&self) -> Result<Vec<u8>, TransactionError> {
method to_transaction_id (line 275) | fn to_transaction_id(&self) -> Result<Self::TransactionId, TransactionEr...
type Err (line 294) | type Err = TransactionError;
method from_str (line 295) | fn from_str(s: &str) -> Result<Self, Self::Err> {
method fmt (line 301) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
type FilecoinTransactionJson (line 318) | pub struct FilecoinTransactionJson(#[serde(with = "self")] pub FilecoinT...
method from (line 332) | fn from(tx: FilecoinTransaction) -> Self {
type FilecoinTransactionJsonRef (line 323) | pub struct FilecoinTransactionJsonRef<'a>(#[serde(with = "self")] pub &'...
function serialize (line 337) | pub fn serialize<S>(tx: &FilecoinTransaction, serializer: S) -> Result<S...
function deserialize (line 359) | pub fn deserialize<'de, D>(deserializer: D) -> Result<FilecoinTransactio...
type ParameterJson (line 394) | pub struct ParameterJson(#[serde(with = "self")] pub FilecoinTransaction...
method from (line 408) | fn from(wrapper: FilecoinTransactionParameters) -> Self {
type ParameterJsonRef (line 399) | pub struct ParameterJsonRef<'a>(#[serde(with = "self")] pub &'a Filecoin...
type JsonHelper (line 415) | struct JsonHelper {
function serialize (line 435) | pub fn serialize<S>(
function deserialize (line 458) | pub fn deserialize<'de, D>(deserializer: D) -> Result<FilecoinTransactio...
type SignatureJson (line 490) | pub struct SignatureJson(#[serde(with = "self")] pub FilecoinSignature);
type SignatureJsonRef (line 495) | pub struct SignatureJsonRef<'a>(#[serde(with = "self")] pub &'a Filecoin...
type JsonHelper (line 498) | struct JsonHelper {
function serialize (line 505) | pub fn serialize<S>(sig: &FilecoinSignature, serializer: S) -> Result<S:...
function deserialize (line 516) | pub fn deserialize<'de, D>(deserializer: D) -> Result<FilecoinSignature,...
type JsonHelperEnum (line 535) | enum JsonHelperEnum {
type SignatureTypeJson (line 542) | pub struct SignatureTypeJson(#[serde(with = "self")] pub FilecoinSignatu...
function serialize (line 544) | pub fn serialize<S>(
function deserialize (line 558) | pub fn deserialize<'de, D>(deserializer: D) -> Result<FilecoinSignatureT...
type CidJson (line 580) | pub struct CidJson(#[serde(with = "self")] pub Cid);
type CidJsonRef (line 585) | pub struct CidJsonRef<'a>(#[serde(with = "self")] pub &'a Cid);
method from (line 588) | fn from(wrapper: CidJson) -> Self {
function serialize (line 593) | pub fn serialize<S>(c: &Cid, serializer: S) -> Result<S::Ok, S::Error>
function deserialize (line 600) | pub fn deserialize<'de, D>(deserializer: D) -> Result<Cid, D::Error>
type CidMap (line 610) | struct CidMap {
function serialize (line 619) | pub fn serialize<S>(v: &Option<Cid>, serializer: S) -> Result<S::Ok, S::...
function deserialize (line 626) | pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<Cid>, D::Er...
type AddressJson (line 645) | pub struct AddressJson(#[serde(with = "self")] pub FilecoinAddress);
method from (line 653) | fn from(addr: FilecoinAddress) -> Self {
type AddressJsonRef (line 650) | pub struct AddressJsonRef<'a>(#[serde(with = "self")] pub &'a FilecoinAd...
method from (line 659) | fn from(addr: AddressJson) -> Self {
function serialize (line 664) | pub fn serialize<S>(addr: &FilecoinAddress, serializer: S) -> Result<S::...
function deserialize (line 671) | pub fn deserialize<'de, D>(deserializer: D) -> Result<FilecoinAddress, D...
function serialize (line 686) | pub fn serialize<S>(amount: &FilecoinAmount, serializer: S) -> Result<S:...
function deserialize (line 694) | pub fn deserialize<'de, D>(deserializer: D) -> Result<FilecoinAmount, D:...
function filecoin_transaction_serialization_test (line 716) | fn filecoin_transaction_serialization_test() {
function filecoin_transaction_deserialization_test (line 751) | fn filecoin_transaction_deserialization_test() {
FILE: crates/anychain-filecoin/src/utilities/crypto.rs
constant PAYLOAD_HASH_LEN (line 2) | pub const PAYLOAD_HASH_LEN: usize = 20;
function blake2b_160 (line 6) | pub fn blake2b_160(input: &[u8]) -> [u8; 20] {
function blake2b_256 (line 20) | pub fn blake2b_256(ingest: &[u8]) -> [u8; 32] {
constant CHECKSUM_HASH_LEN (line 33) | pub const CHECKSUM_HASH_LEN: usize = 4;
function blake2b_checksum (line 36) | pub fn blake2b_checksum(ingest: &[u8]) -> Vec<u8> {
FILE: crates/anychain-kms/src/bip32/child_number.rs
type ChildNumber (line 11) | pub struct ChildNumber(pub u32);
constant BYTE_SIZE (line 15) | pub const BYTE_SIZE: usize = 4;
constant HARDENED_FLAG (line 18) | pub const HARDENED_FLAG: u32 = 1 << 31;
method new (line 23) | pub fn new(index: u32, hardened: bool) -> Result<Self> {
method from_bytes (line 34) | pub fn from_bytes(bytes: [u8; Self::BYTE_SIZE]) -> Self {
method to_bytes (line 39) | pub fn to_bytes(self) -> [u8; Self::BYTE_SIZE] {
method index (line 45) | pub fn index(self) -> u32 {
method is_hardened (line 50) | pub fn is_hardened(&self) -> bool {
method from (line 68) | fn from(n: u32) -> ChildNumber {
method fmt (line 56) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
function from (line 74) | fn from(n: ChildNumber) -> u32 {
type Err (line 80) | type Err = Error;
method from_str (line 82) | fn from_str(child: &str) -> Result<ChildNumber> {
function parse_non_hardened (line 99) | fn parse_non_hardened() {
function parse_hardened (line 107) | fn parse_hardened() {
function parse_rejects_invalid (line 115) | fn parse_rejects_invalid() {
function index_overflow (line 120) | fn index_overflow() {
FILE: crates/anychain-kms/src/bip32/derivation_path.rs
constant PREFIX (line 11) | const PREFIX: &str = "m";
type DerivationPath (line 15) | pub struct DerivationPath {
method iter (line 21) | pub fn iter(&self) -> impl Iterator<Item = ChildNumber> + '_ {
method is_empty (line 26) | pub fn is_empty(&self) -> bool {
method len (line 31) | pub fn len(&self) -> usize {
method parent (line 38) | pub fn parent(&self) -> Option<Self> {
method push (line 47) | pub fn push(&mut self, child_number: ChildNumber) {
method as_ref (line 53) | fn as_ref(&self) -> &[ChildNumber] {
method extend (line 71) | fn extend<T>(&mut self, iter: T)
method fmt (line 59) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
type Err (line 80) | type Err = Error;
method from_str (line 82) | fn from_str(path: &str) -> Result<DerivationPath> {
type Item (line 96) | type Item = ChildNumber;
type IntoIter (line 97) | type IntoIter = vec::IntoIter<ChildNumber>;
method into_iter (line 99) | fn into_iter(self) -> vec::IntoIter<ChildNumber> {
function round_trip (line 112) | fn round_trip() {
function parent (line 163) | fn parent() {
FILE: crates/anychain-kms/src/bip32/error.rs
type Result (line 8) | pub type Result<T> = core::result::Result<T, Error>;
type Error (line 13) | pub enum Error {
method from (line 53) | fn from(_: bs58::decode::Error) -> Error {
method from (line 59) | fn from(_: bs58::encode::Error) -> Error {
method from (line 65) | fn from(_: core::array::TryFromSliceError) -> Error {
method from (line 80) | fn from(_: InvalidLength) -> Error {
method from (line 100) | fn from(_: libsecp256k1::Error) -> Error {
method fmt (line 37) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
FILE: crates/anychain-kms/src/bip32/extended_key/attrs.rs
type ExtendedKeyAttrs (line 8) | pub struct ExtendedKeyAttrs {
FILE: crates/anychain-kms/src/bip32/extended_key/extended_private_key.rs
constant BIP39_DOMAIN_SEPARATOR (line 23) | const BIP39_DOMAIN_SEPARATOR: [u8; 12] = [
type XprvSecp256k1 (line 28) | pub type XprvSecp256k1 = ExtendedPrivateKey<libsecp256k1::SecretKey>;
type XprvEd25519 (line 31) | pub type XprvEd25519 = ExtendedPrivateKey<Scalar>;
type ExtendedPrivateKey (line 39) | pub struct ExtendedPrivateKey<K: PrivateKey> {
constant MAX_DEPTH (line 52) | pub const MAX_DEPTH: Depth = u8::MAX;
function new_from_path (line 55) | pub fn new_from_path<S>(seed: S, path: &DerivationPath) -> Result<Self>
function new (line 65) | pub fn new<S>(seed: S) -> Result<Self>
function derive_from_path (line 89) | pub fn derive_from_path(self, path: &DerivationPath) -> Result<Self> {
function derive_child (line 95) | pub fn derive_child(&self, child_number: ChildNumber) -> Result<Self> {
function private_key (line 135) | pub fn private_key(&self) -> &K {
function public_key (line 140) | pub fn public_key(&self) -> ExtendedPublicKey<K::PublicKey> {
function attrs (line 146) | pub fn attrs(&self) -> &ExtendedKeyAttrs {
function to_bytes (line 151) | pub fn to_bytes(&self) -> Vec<u8> {
function to_extended_key (line 156) | pub fn to_extended_key(&self, prefix: Prefix) -> ExtendedKey {
function to_string (line 170) | pub fn to_string(&self, prefix: Prefix) -> Zeroizing<String> {
method ct_eq (line 179) | fn ct_eq(&self, other: &Self) -> Choice {
method fmt (line 203) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
method eq (line 220) | fn eq(&self, other: &Self) -> bool {
type Err (line 229) | type Err = Error;
method from_str (line 231) | fn from_str(xprv: &str) -> Result<Self> {
type Error (line 240) | type Error = Error;
function try_from (line 242) | fn try_from(extended_key: ExtendedKey) -> Result<ExtendedPrivateKey<K>> {
function test_constant_time_eq_same (line 260) | fn test_constant_time_eq_same() {
function test_constant_time_eq_diff (line 274) | fn test_constant_time_eq_diff() {
FILE: crates/anychain-kms/src/bip32/extended_key/extended_public_key.rs
type XpubSecp256k1 (line 14) | pub type XpubSecp256k1 = ExtendedPublicKey<libsecp256k1::PublicKey>;
type XpubEd25519 (line 17) | pub type XpubEd25519 = ExtendedPublicKey<ed25519_dalek::VerifyingKey>;
type ExtendedPublicKey (line 25) | pub struct ExtendedPublicKey<K: PublicKey> {
function public_key (line 38) | pub fn public_key(&self) -> &K {
function attrs (line 44) | pub fn attrs(&self) -> &ExtendedKeyAttrs {
function fingerprint (line 49) | pub fn fingerprint(&self) -> KeyFingerprint {
function derive_from_path (line 53) | pub fn derive_from_path(self, path: &DerivationPath) -> Result<Self> {
function derive_child (line 59) | pub fn derive_child(&self, child_number: ChildNumber) -> Result<Self> {
function to_bytes (line 88) | pub fn to_bytes(&self) -> Vec<u8> {
function to_extended_key (line 93) | pub fn to_extended_key(&self, prefix: Prefix) -> ExtendedKey {
function to_string (line 112) | pub fn to_string(&self, prefix: Prefix) -> String {
function from (line 121) | fn from(xprv: &ExtendedPrivateKey<K>) -> ExtendedPublicKey<K::PublicKey> {
type Err (line 133) | type Err = Error;
method from_str (line 135) | fn from_str(xpub: &str) -> Result<Self> {
type Error (line 144) | type Error = Error;
function try_from (line 146) | fn try_from(extended_key: ExtendedKey) -> Result<ExtendedPublicKey<K>> {
FILE: crates/anychain-kms/src/bip32/extended_key/mod.rs
type ExtendedKey (line 16) | pub struct ExtendedKey {
constant BYTE_SIZE (line 31) | pub const BYTE_SIZE: usize = 78;
constant MAX_BASE58_SIZE (line 36) | pub const MAX_BASE58_SIZE: usize = 112;
method write_base58 (line 43) | pub fn write_base58<'a>(&self, buffer: &'a mut [u8; Self::MAX_BASE58_S...
method fmt (line 60) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
type Err (line 69) | type Err = Error;
method from_str (line 71) | fn from_str(base58: &str) -> Result<Self> {
method drop (line 108) | fn drop(&mut self) {
function bip32_test_vector_1_xprv (line 123) | fn bip32_test_vector_1_xprv() {
function bip32_test_vector_1_xpub (line 144) | fn bip32_test_vector_1_xpub() {
function debug_extend_key (line 164) | fn debug_extend_key(ek: &ExtendedKey) {
function test_master_xprv (line 177) | fn test_master_xprv() {
function test_xprv (line 189) | fn test_xprv() {
function test_hex (line 204) | fn test_hex() {
FILE: crates/anychain-kms/src/bip32/mod.rs
type ChainCode (line 27) | pub type ChainCode = [u8; KEY_SIZE];
type Depth (line 30) | pub type Depth = u8;
type KeyFingerprint (line 33) | pub type KeyFingerprint = [u8; 4];
type Version (line 36) | pub type Version = u32;
type HmacSha512 (line 39) | pub type HmacSha512 = hmac::Hmac<sha2::Sha512>;
constant KEY_SIZE (line 41) | pub const KEY_SIZE: usize = 32;
type TestVector (line 47) | pub(crate) struct TestVector {
constant VECTORS (line 53) | const VECTORS :[TestVector;1] = [
function test_vectors (line 92) | pub fn test_vectors() {
FILE: crates/anychain-kms/src/bip32/prefix.rs
type Prefix (line 25) | pub struct Prefix {
constant LENGTH (line 35) | pub const LENGTH: usize = 4;
constant TPRV (line 38) | pub const TPRV: Self = Self::from_parts_unchecked("tprv", 0x04358394);
constant TPUB (line 41) | pub const TPUB: Self = Self::from_parts_unchecked("tpub", 0x043587cf);
constant XPRV (line 44) | pub const XPRV: Self = Self::from_parts_unchecked("xprv", 0x0488ade4);
constant XPUB (line 47) | pub const XPUB: Self = Self::from_parts_unchecked("xpub", 0x0488b21e);
constant YPRV (line 50) | pub const YPRV: Self = Self::from_parts_unchecked("yprv", 0x049d7878);
constant YPUB (line 53) | pub const YPUB: Self = Self::from_parts_unchecked("ypub", 0x049d7cb2);
constant ZPRV (line 56) | pub const ZPRV: Self = Self::from_parts_unchecked("zprv", 0x04b2430c);
constant ZPUB (line 59) | pub const ZPUB: Self = Self::from_parts_unchecked("zpub", 0x04b24746);
method from_parts_unchecked (line 71) | pub const fn from_parts_unchecked(s: &str, version: Version) -> Self {
method from_bytes (line 82) | pub fn from_bytes(bytes: [u8; Self::LENGTH]) -> Result<Self> {
method from_version (line 90) | fn from_version(version: Version) -> Result<Self> {
method as_str (line 103) | pub fn as_str(&self) -> &str {
method is_public (line 108) | pub fn is_public(self) -> bool {
method is_private (line 113) | pub fn is_private(self) -> bool {
method version (line 118) | pub fn version(self) -> Version {
method to_bytes (line 123) | pub fn to_bytes(self) -> [u8; Self::LENGTH] {
method validate_str (line 129) | pub(crate) const fn validate_str(s: &str) -> Result<&str> {
method as_ref (line 149) | fn as_ref(&self) -> &str {
type Error (line 182) | type Error = Error;
method try_from (line 184) | fn try_from(version: Version) -> Result<Self> {
type Error (line 190) | type Error = Error;
method try_from (line 192) | fn try_from(bytes: &[u8]) -> Result<Prefix> {
method fmt (line 155) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
method fmt (line 164) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
method from (line 170) | fn from(prefix: Prefix) -> Version {
method from (line 176) | fn from(prefix: &Prefix) -> Version {
type DebugVersion (line 199) | struct DebugVersion(Version);
method fmt (line 202) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
function constants (line 212) | fn constants() {
FILE: crates/anychain-kms/src/bip32/private_key.rs
type PrivateKey (line 9) | pub trait PrivateKey: Sized {
method from_bytes (line 14) | fn from_bytes(bytes: Vec<u8>) -> Result<Self>;
method to_bytes (line 17) | fn to_bytes(&self) -> Vec<u8>;
method derive_child (line 22) | fn derive_child(&self, tweak: Vec<u8>) -> Result<Self>;
method public_key (line 25) | fn public_key(&self) -> Self::PublicKey;
type PublicKey (line 29) | type PublicKey = libsecp256k1::PublicKey;
method from_bytes (line 31) | fn from_bytes(bytes: Vec<u8>) -> Result<Self> {
method to_bytes (line 38) | fn to_bytes(&self) -> Vec<u8> {
method derive_child (line 42) | fn derive_child(&self, tweak: Vec<u8>) -> Result<Self> {
method public_key (line 50) | fn public_key(&self) -> Self::PublicKey {
type PublicKey (line 68) | type PublicKey = ed25519_dalek::VerifyingKey;
method from_bytes (line 70) | fn from_bytes(bytes: Vec<u8>) -> Result<Self> {
method to_bytes (line 76) | fn to_bytes(&self) -> Vec<u8> {
method derive_child (line 80) | fn derive_child(&self, tweak: Vec<u8>) -> Result<Self> {
method public_key (line 87) | fn public_key(&self) -> Self::PublicKey {
function from (line 56) | fn from(xprv: XprvSecp256k1) -> libsecp256k1::SecretKey {
function from (line 62) | fn from(xprv: &XprvSecp256k1) -> libsecp256k1::SecretKey {
method from (line 94) | fn from(xprv: XprvEd25519) -> Scalar {
method from (line 100) | fn from(xprv: &XprvEd25519) -> Scalar {
function test_secp256k1_derivation (line 111) | fn test_secp256k1_derivation() {
function test_ed25519_derivation (line 127) | fn test_ed25519_derivation() {
FILE: crates/anychain-kms/src/bip32/public_key.rs
type PublicKey (line 14) | pub trait PublicKey: Sized {
method from_bytes (line 16) | fn from_bytes(bytes: Vec<u8>) -> Result<Self>;
method to_bytes (line 19) | fn to_bytes(&self) -> Vec<u8>;
method derive_child (line 22) | fn derive_child(&self, tweak: Vec<u8>) -> Result<Self>;
method fingerprint (line 27) | fn fingerprint(&self) -> KeyFingerprint {
method from_bytes (line 34) | fn from_bytes(bytes: Vec<u8>) -> Result<Self> {
method to_bytes (line 41) | fn to_bytes(&self) -> Vec<u8> {
method derive_child (line 45) | fn derive_child(&self, tweak: Vec<u8>) -> Result<Self> {
method from_bytes (line 55) | fn from_bytes(bytes: Vec<u8>) -> Result<Self> {
method to_bytes (line 69) | fn to_bytes(&self) -> Vec<u8> {
method derive_child (line 73) | fn derive_child(&self, tweak: Vec<u8>) -> Result<Self> {
constant SEED (line 93) | const SEED: [u8; 64] = hex!(
type XprvSecp256k1 (line 98) | type XprvSecp256k1 = crate::bip32::ExtendedPrivateKey<libsecp256k1::Secr...
function secp256k1_xprv_derivation (line 101) | fn secp256k1_xprv_derivation() {
function secp256k1_ffi_xpub_derivation (line 112) | fn secp256k1_ffi_xpub_derivation() {
function test_ed25519 (line 124) | fn test_ed25519() {
FILE: crates/anychain-kms/src/bip39/crypto.rs
constant PBKDF2_ROUNDS (line 13) | const PBKDF2_ROUNDS: u32 = 2048;
constant PBKDF2_BYTES (line 14) | const PBKDF2_BYTES: usize = 64;
function sha256_first_byte (line 18) | pub(crate) fn sha256_first_byte(input: &[u8]) -> u8 {
function gen_random_bytes (line 24) | pub(crate) fn gen_random_bytes(byte_length: usize) -> Vec<u8> {
function pbkdf2 (line 37) | pub(crate) fn pbkdf2(input: &[u8], salt: &str) -> Vec<u8> {
FILE: crates/anychain-kms/src/bip39/error.rs
type ErrorKind (line 5) | pub enum ErrorKind {
function prints_correctly (line 26) | fn prints_correctly() {
FILE: crates/anychain-kms/src/bip39/language.rs
type WordMap (line 5) | pub struct WordMap {
method get_bits (line 14) | pub fn get_bits(&self, word: &str) -> Result<Bits11, ErrorKind> {
type WordList (line 9) | pub struct WordList {
method get_word (line 23) | pub fn get_word(&self, bits: Bits11) -> &'static str {
method get_words_by_prefix (line 27) | pub fn get_words_by_prefix(&self, prefix: &str) -> &[&'static str] {
function gen_wordlist (line 43) | fn gen_wordlist(lang_words: &'static str) -> WordList {
function gen_wordmap (line 52) | fn gen_wordmap(wordlist: &WordList) -> WordMap {
type Language (line 113) | pub enum Language {
method from_language_code (line 134) | pub fn from_language_code(language_code: &str) -> Option<Self> {
method from_phrase (line 159) | pub fn from_phrase(phrase: &str) -> Option<Self> {
method wordlist (line 177) | pub fn wordlist(&self) -> &'static WordList {
method wordmap (line 200) | pub fn wordmap(&self) -> &'static WordMap {
function words_by_prefix (line 230) | fn words_by_prefix() {
function all_words_by_prefix (line 238) | fn all_words_by_prefix() {
function words_by_invalid_prefix (line 246) | fn words_by_invalid_prefix() {
function is_wordlist_nfkd (line 252) | fn is_wordlist_nfkd(wl: &WordList) -> bool {
function chinese_simplified_wordlist_is_nfkd (line 265) | fn chinese_simplified_wordlist_is_nfkd() {
function chinese_traditional_wordlist_is_nfkd (line 272) | fn chinese_traditional_wordlist_is_nfkd() {
function french_wordlist_is_nfkd (line 279) | fn french_wordlist_is_nfkd() {
function italian_wordlist_is_nfkd (line 286) | fn italian_wordlist_is_nfkd() {
function japanese_wordlist_is_nfkd (line 293) | fn japanese_wordlist_is_nfkd() {
function korean_wordlist_is_nfkd (line 300) | fn korean_wordlist_is_nfkd() {
function spanish_wordlist_is_nfkd (line 307) | fn spanish_wordlist_is_nfkd() {
function from_language_code_en (line 313) | fn from_language_code_en() {
function from_language_code_cn_hans (line 323) | fn from_language_code_cn_hans() {
function from_language_code_cn_hant (line 333) | fn from_language_code_cn_hant() {
function from_language_code_fr (line 343) | fn from_language_code_fr() {
function from_language_code_it (line 353) | fn from_language_code_it() {
function from_language_code_ja (line 363) | fn from_language_code_ja() {
function from_language_code_ko (line 373) | fn from_language_code_ko() {
function from_language_code_es (line 383) | fn from_language_code_es() {
function from_invalid_language_code (line 392) | fn from_invalid_language_code() {
function test_ffrom_phrase (line 397) | fn test_ffrom_phrase() {
FILE: crates/anychain-kms/src/bip39/mnemonic.rs
type Mnemonic (line 39) | pub struct Mnemonic {
method new (line 65) | pub fn new(mtype: MnemonicType, lang: Language) -> Mnemonic {
method from_entropy (line 86) | pub fn from_entropy(entropy: &[u8], lang: Language) -> Result<Mnemonic...
method from_entropy_unchecked (line 93) | fn from_entropy_unchecked<E>(entropy: E, lang: Language) -> Mnemonic
method from_phrase (line 144) | pub fn from_phrase(phrase: &str, lang: Language) -> Result<Mnemonic, E...
method validate (line 180) | pub fn validate(phrase: &str, lang: Language) -> Result<(), Error> {
method phrase_to_entropy (line 191) | fn phrase_to_entropy(phrase: &str, lang: Language) -> Result<Vec<u8>, ...
method phrase (line 227) | pub fn phrase(&self) -> &str {
method into_phrase (line 232) | pub fn into_phrase(mut self) -> String {
method entropy (line 254) | pub fn entropy(&self) -> &[u8] {
method language (line 261) | pub fn language(&self) -> Language {
method as_bytes (line 265) | pub fn as_bytes(&self) -> Vec<u8> {
method as_ref (line 276) | fn as_ref(&self) -> &str {
method fmt (line 282) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
method fmt (line 288) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
method fmt (line 294) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
method fmt (line 308) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
method from (line 322) | fn from(val: Mnemonic) -> String {
function back_to_back (line 335) | fn back_to_back() {
function mnemonic_from_entropy (line 348) | fn mnemonic_from_entropy() {
function mnemonic_from_phrase (line 362) | fn mnemonic_from_phrase() {
function mnemonic_format (line 376) | fn mnemonic_format() {
function mnemonic_hex_format (line 384) | fn mnemonic_hex_format() {
FILE: crates/anychain-kms/src/bip39/mnemonic_type.rs
constant ENTROPY_OFFSET (line 5) | const ENTROPY_OFFSET: usize = 8;
type MnemonicType (line 33) | pub enum MnemonicType {
method for_word_count (line 55) | pub fn for_word_count(size: usize) -> Result<MnemonicType, Error> {
method for_key_size (line 79) | pub fn for_key_size(size: usize) -> Result<MnemonicType, Error> {
method for_phrase (line 113) | pub fn for_phrase(phrase: &str) -> Result<MnemonicType, Error> {
method total_bits (line 132) | pub fn total_bits(&self) -> usize {
method entropy_bits (line 149) | pub fn entropy_bits(&self) -> usize {
method checksum_bits (line 166) | pub fn checksum_bits(&self) -> u8 {
method word_count (line 181) | pub fn word_count(&self) -> usize {
method fmt (line 187) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
function word_count (line 205) | fn word_count() {
function entropy_bits (line 215) | fn entropy_bits() {
function checksum_bits (line 225) | fn checksum_bits() {
FILE: crates/anychain-kms/src/bip39/mod.rs
constant VECTORS (line 23) | const VECTORS: [[&str;4];24] = [
function test_vectors (line 172) | fn test_vectors() {
FILE: crates/anychain-kms/src/bip39/seed.rs
type Seed (line 24) | pub struct Seed {
method new (line 32) | pub fn new(mnemonic: &Mnemonic, password: &str) -> Self {
method as_bytes (line 41) | pub fn as_bytes(&self) -> &[u8] {
method as_ref (line 47) | fn as_ref(&self) -> &[u8] {
method fmt (line 53) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
method fmt (line 59) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
method fmt (line 73) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
method drop (line 87) | fn drop(&mut self) {
function seed_hex_format (line 100) | fn seed_hex_format() {
function test_unicode_normalization (line 115) | fn test_unicode_normalization(
function issue_26 (line 130) | fn issue_26() {
function password_is_unicode_normalized (line 142) | fn password_is_unicode_normalized() {
function japanese_normalization_1 (line 155) | fn japanese_normalization_1() {
function japanese_normalization_2 (line 167) | fn japanese_normalization_2() {
function french_normalization (line 179) | fn french_normalization() {
FILE: crates/anychain-kms/src/bip39/util.rs
type IterExt (line 3) | pub(crate) trait IterExt: Iterator {
method join (line 4) | fn join<R>(&mut self, glue: &str) -> R
method bits (line 28) | fn bits<Out>(self) -> BitIter<Self::Item, Out, Self>
type Joinable (line 38) | pub(crate) trait Joinable {
method write_into (line 39) | fn write_into(self, buf: &mut String);
method write_into (line 44) | fn write_into(self, buf: &mut String) {
method write_into (line 51) | fn write_into(self, buf: &mut String) {
type Bits (line 58) | pub(crate) trait Bits {
constant SIZE (line 59) | const SIZE: usize;
method bits (line 61) | fn bits(self) -> u32;
constant SIZE (line 65) | const SIZE: usize = 8;
method bits (line 67) | fn bits(self) -> u32 {
constant SIZE (line 73) | const SIZE: usize = 8;
method bits (line 75) | fn bits(self) -> u32 {
constant SIZE (line 84) | const SIZE: usize = 11;
method bits (line 86) | fn bits(self) -> u32 {
type Bits11 (line 81) | pub struct Bits11(u16);
method from (line 92) | fn from(val: u16) -> Self {
function from (line 98) | fn from(val: Bits11) -> Self {
type BitWriter (line 103) | pub(crate) struct BitWriter {
method with_capacity (line 110) | pub fn with_capacity(capacity: usize) -> Self {
method push (line 125) | pub fn push<B: Bits>(&mut self, source: B) {
method len (line 138) | pub fn len(&self) -> usize {
method into_bytes (line 142) | pub fn into_bytes(mut self) -> Vec<u8> {
type BitIter (line 151) | pub(crate) struct BitIter<In: Bits, Out: Bits, I: Iterator<Item = In> + ...
function new (line 164) | fn new(source: I) -> Self {
type Item (line 182) | type Item = Out;
method next (line 184) | fn next(&mut self) -> Option<Out> {
method size_hint (line 200) | fn size_hint(&self) -> (usize, Option<usize>) {
function checksum (line 211) | pub(crate) fn checksum(source: u8, bits: u8) -> u8 {
FILE: crates/anychain-kms/src/crypto.rs
function ripemd (line 4) | pub fn ripemd(msg: &[u8]) -> String {
FILE: crates/anychain-kms/src/error.rs
type Error (line 2) | pub enum Error {
FILE: crates/anychain-kms/src/lib.rs
function secp256k1_sign (line 19) | pub fn secp256k1_sign(sk: &[u8], msg: &[u8]) -> Result<(Vec<u8>, u8)> {
function ed25519_sign (line 26) | pub fn ed25519_sign(sk: &[u8], msg: &[u8]) -> Result<Vec<u8>> {
function ed25519_sign_inner (line 33) | fn ed25519_sign_inner(sk: &[u8], msg: &[u8], nonce_bytes: &[u8]) -> Resu...
function test_mnemonic (line 80) | fn test_mnemonic() {
function test_master_xprv (line 104) | fn test_master_xprv() {
function test_xpub (line 118) | fn test_xpub() {
function test_stand_ed25519_sign (line 132) | fn test_stand_ed25519_sign() {
function test_ed25519_sign (line 163) | fn test_ed25519_sign() {
function test_ed25519_exception (line 180) | fn test_ed25519_exception() {
FILE: crates/anychain-neo/src/address.rs
type NeoAddress (line 10) | pub struct NeoAddress(pub String);
method to_script_hash (line 53) | pub fn to_script_hash(&self) -> Vec<u8> {
type Format (line 13) | type Format = NeoFormat;
type SecretKey (line 14) | type SecretKey = p256::SecretKey;
type PublicKey (line 15) | type PublicKey = NeoPublicKey;
method from_secret_key (line 17) | fn from_secret_key(
method from_public_key (line 24) | fn from_public_key(
type Err (line 61) | type Err = AddressError;
method from_str (line 63) | fn from_str(s: &str) -> Result<Self, Self::Err> {
method fmt (line 77) | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
function test_address_from_secret_key (line 91) | fn test_address_from_secret_key() {
function test_address_from_public_key (line 107) | fn test_address_from_public_key() {
function test_address_from_str (line 124) | fn test_address_from_str() {
function tesa_addresses_from_sk (line 135) | fn tesa_addresses_from_sk() {
FILE: crates/anychain-neo/src/format.rs
type NeoFormat (line 7) | pub enum NeoFormat {
method fmt (line 14) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
FILE: crates/anychain-neo/src/public_key.rs
type NeoPublicKey (line 6) | pub struct NeoPublicKey(pub p256::PublicKey);
method serialize_compressed (line 25) | pub fn serialize_compressed(&self) -> Vec<u8> {
type SecretKey (line 9) | type SecretKey = p256::SecretKey;
type Address (line 10) | type Address = NeoAddress;
type Format (line 11) | type Format = NeoFormat;
method from_secret_key (line 13) | fn from_secret_key(secret_key: &Self::SecretKey) -> Self {
method to_address (line 18) | fn to_address(&self, format: &Self::Format) -> Result<Self::Address, Add...
type Err (line 31) | type Err = PublicKeyError;
method from_str (line 33) | fn from_str(s: &str) -> Result<Self, Self::Err> {
method fmt (line 41) | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
function test_public_key_from_str (line 56) | fn test_public_key_from_str() {
FILE: crates/anychain-neo/src/transaction.rs
type TxIn (line 6) | pub struct TxIn {
method serialize (line 19) | fn serialize(&self) -> Vec<u8> {
type TxOut (line 12) | pub struct TxOut {
method serialize (line 30) | fn serialize(&self) -> Vec<u8> {
type NeoTransactionParameters (line 45) | pub struct NeoTransactionParameters {
method serialize (line 51) | fn serialize(&self) -> Vec<u8> {
type NeoSignature (line 75) | pub struct NeoSignature {
method serialize (line 81) | fn serialize(&self) -> Vec<u8> {
type NeoTransaction (line 98) | pub struct NeoTransaction {
type NeoTransactionId (line 104) | pub struct NeoTransactionId {
method fmt (line 109) | fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
type TransactionId (line 117) | type TransactionId = NeoTransactionId;
type Format (line 118) | type Format = NeoFormat;
type TransactionParameters (line 119) | type TransactionParameters = NeoTransactionParameters;
type Address (line 120) | type Address = NeoAddress;
type PublicKey (line 121) | type PublicKey = NeoPublicKey;
method new (line 123) | fn new(params: &Self::TransactionParameters) -> Result<Self, Transaction...
method sign (line 130) | fn sign(&mut self, rs_pk_s: Vec<u8>, _recid: u8) -> Result<Vec<u8>, Tran...
method to_bytes (line 164) | fn to_bytes(&self) -> Result<Vec<u8>, TransactionError> {
method from_bytes (line 175) | fn from_bytes(_tx: &[u8]) -> Result<Self, TransactionError> {
method to_transaction_id (line 179) | fn to_transaction_id(&self) -> Result<Self::TransactionId, TransactionEr...
method fmt (line 188) | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
function test_tx_gen (line 213) | fn test_tx_gen() {
FILE: crates/anychain-polkadot/src/address.rs
type PolkadotAddress (line 10) | pub struct PolkadotAddress<N: PolkadotNetwork> {
type SecretKey (line 16) | type SecretKey = PolkadotSecretKey;
type PublicKey (line 17) | type PublicKey = PolkadotPublicKey<N>;
type Format (line 18) | type Format = PolkadotFormat;
method from_secret_key (line 20) | fn from_secret_key(
method from_public_key (line 27) | fn from_public_key(
function from_payload (line 36) | pub fn from_payload(payload: &str) -> Result<Self, AddressError> {
function to_payload (line 51) | pub fn to_payload(&self) -> Result<Vec<u8>, AddressError> {
type Err (line 58) | type Err = TransactionError;
method from_str (line 59) | fn from_str(s: &str) -> Result<Self, Self::Err> {
method fmt (line 86) | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
function test_address (line 98) | fn test_address() {
function test_address_2 (line 120) | fn test_address_2() {
function test_address_3 (line 130) | fn test_address_3() {
FILE: crates/anychain-polkadot/src/format.rs
type PolkadotFormat (line 5) | pub enum PolkadotFormat {
method fmt (line 12) | fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
FILE: crates/anychain-polkadot/src/network/kusama.rs
type Kusama (line 7) | pub struct Kusama;
constant NAME (line 10) | const NAME: &'static str = "kusama";
constant VERSION (line 14) | const VERSION: u8 = 0x02;
constant PALLET_ASSET (line 15) | const PALLET_ASSET: u8 = 4;
constant TRANSFER_ALLOW_DEATH (line 16) | const TRANSFER_ALLOW_DEATH: u8 = 0;
constant TRANSFER_KEEP_ALIVE (line 17) | const TRANSFER_KEEP_ALIVE: u8 = 3;
type Err (line 21) | type Err = NetworkError;
method from_str (line 22) | fn from_str(_s: &str) -> Result<Self, Self::Err> {
method fmt (line 28) | fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
FILE: crates/anychain-polkadot/src/network/mod.rs
type PolkadotNetwork (line 15) | pub trait PolkadotNetwork: Network {
constant VERSION (line 16) | const VERSION: u8;
constant PALLET_ASSET (line 17) | const PALLET_ASSET: u8;
constant TRANSFER_ALLOW_DEATH (line 18) | const TRANSFER_ALLOW_DEATH: u8;
constant TRANSFER_KEEP_ALIVE (line 19) | const TRANSFER_KEEP_ALIVE: u8;
FILE: crates/anychain-polkadot/src/network/polkadot.rs
type Polkadot (line 7) | pub struct Polkadot;
constant NAME (line 10) | const NAME: &'static str = "polkadot";
constant VERSION (line 14) | const VERSION: u8 = 0x00;
constant PALLET_ASSET (line 15) | const PALLET_ASSET: u8 = 5;
constant TRANSFER_ALLOW_DEATH (line 16) | const TRANSFER_ALLOW_DEATH: u8 = 0;
constant TRANSFER_KEEP_ALIVE (line 17) | const TRANSFER_KEEP_ALIVE: u8 = 3;
type Err (line 21) | type Err = NetworkError;
method from_str (line 22) | fn from_str(_s: &str) -> Result<Self, Self::Err> {
method fmt (line 28) | fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
FILE: crates/anychain-polkadot/src/network/rococo.rs
type Rococo (line 7) | pub struct Rococo;
constant NAME (line 10) | const NAME: &'static str = "rococo";
constant VERSION (line 14) | const VERSION: u8 = 0x2a;
constant PALLET_ASSET (line 15) | const PALLET_ASSET: u8 = 4;
constant TRANSFER_ALLOW_DEATH (line 16) | const TRANSFER_ALLOW_DEATH: u8 = 0;
constant TRANSFER_KEEP_ALIVE (line 17) | const TRANSFER_KEEP_ALIVE: u8 = 3;
type Err (line 21) | type Err = NetworkError;
method from_str (line 22) | fn from_str(_s: &str) -> Result<Self, Self::Err> {
method fmt (line 28) | fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
FILE: crates/anychain-polkadot/src/network/westend.rs
type Westend (line 7) | pub struct Westend;
constant NAME (line 10) | const NAME: &'static str = "westend";
constant VERSION (line 14) | const VERSION: u8 = 0x2a;
constant PALLET_ASSET (line 15) | const PALLET_ASSET: u8 = 4;
constant TRANSFER_ALLOW_DEATH (line 16) | const TRANSFER_ALLOW_DEATH: u8 = 0;
constant TRANSFER_KEEP_ALIVE (line 17) | const TRANSFER_KEEP_ALIVE: u8 = 3;
type Err (line 21) | type Err = NetworkError;
method from_str (line 22) | fn from_str(_s: &str) -> Result<Self, Self::Err> {
method fmt (line 28) | fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
FILE: crates/anychain-polkadot/src/public_key.rs
type PolkadotSecretKey (line 6) | pub enum PolkadotSecretKey {
type PublicKeyContent (line 12) | pub enum PublicKeyContent {
type PolkadotPublicKey (line 18) | pub struct PolkadotPublicKey<N: PolkadotNetwork> {
type SecretKey (line 24) | type SecretKey = PolkadotSecretKey;
type Address (line 25) | type Address = PolkadotAddress<N>;
type Format (line 26) | type Format = PolkadotFormat;
method from_secret_key (line 28) | fn from_secret_key(secret_key: &Self::SecretKey) -> Self {
method to_address (line 51) | fn to_address(
function serialize (line 60) | pub fn serialize(&self) -> Vec<u8> {
function address_payload (line 67) | pub fn address_payload(&self) -> Vec<u8> {
type Err (line 76) | type Err = PublicKeyError;
method from_str (line 77) | fn from_str(_s: &str) -> Result<Self, Self::Err> {
method fmt (line 83) | fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
FILE: crates/anychain-polkadot/src/transaction.rs
type PolkadotTransactionParameters (line 8) | pub struct PolkadotTransactionParameters<N: PolkadotNetwork> {
type TxInterim (line 20) | struct TxInterim {
type PolkadotTransaction (line 32) | pub struct PolkadotTransaction<N: PolkadotNetwork> {
type PolkadotTransactionId (line 38) | pub struct PolkadotTransactionId {
method fmt (line 45) | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
type CompactWrapper (line 51) | struct CompactWrapper<T: HasCompact> {
function encode (line 56) | fn encode(val: u64) -> Vec<u8> {
type Address (line 65) | type Address = PolkadotAddress<N>;
type Format (line 66) | type Format = PolkadotFormat;
type PublicKey (line 67) | type PublicKey = PolkadotPublicKey<N>;
type TransactionId (line 68) | type TransactionId = PolkadotTransactionId;
type TransactionParameters (line 69) | type TransactionParameters = PolkadotTransactionParameters<N>;
method new (line 71) | fn new(params: &Self::TransactionParameters) -> Result<Self, Transaction...
method sign (line 79) | fn sign(&mut self, rs: Vec<u8>, recid: u8) -> Result<Vec<u8>, Transactio...
method from_bytes (line 90) | fn from_bytes(_tx: &[u8]) -> Result<Self, TransactionError> {
method to_bytes (line 95) | fn to_bytes(&self) -> Result<Vec<u8>, TransactionError> {
method to_transaction_id (line 136) | fn to_transaction_id(&self) -> Result<Self::TransactionId, TransactionEr...
function to_interim (line 144) | fn to_interim(&self) -> Result<TxInterim, TransactionError> {
function to_bytes_ed25519 (line 181) | fn to_bytes_ed25519(&self) -> Result<Vec<u8>, TransactionError> {
function sign_ed25519 (line 223) | pub fn sign_ed25519(&mut self, rs: Vec<u8>) -> Result<Vec<u8>, Transacti...
method fmt (line 236) | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
function tx_from_str (line 257) | fn tx_from_str<N: PolkadotNetwork>(json: &str) -> PolkadotTransaction<N> {
function test_address_gen (line 288) | fn test_address_gen() {
function test_address_gen_2 (line 321) | fn test_address_gen_2() {
function test_tx_gen (line 356) | fn test_tx_gen() {
function test_tx_gen_2 (line 393) | fn test_tx_gen_2() {
FILE: crates/anychain-polkadot/src/utilities/crypto.rs
function blake2b_256 (line 3) | pub fn blake2b_256(ingest: &[u8]) -> [u8; 32] {
FILE: crates/anychain-ripple/src/address.rs
constant RIPPLE_ALPHABET (line 33) | const RIPPLE_ALPHABET: &str = "rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg6...
function to_xrp_bs58 (line 56) | fn to_xrp_bs58(s: &str) -> Result<String, AddressError> {
function to_btc_bs58 (line 67) | fn to_btc_bs58(s: &str) -> Result<String, AddressError> {
type RippleAddress (line 79) | pub struct RippleAddress(String);
method to_hash160 (line 150) | pub fn to_hash160(&self) -> Result<[u8; 20], AddressError> {
method from_hash160 (line 163) | pub fn from_hash160(hash: &[u8]) -> Result<Self, AddressError> {
type SecretKey (line 82) | type SecretKey = libsecp256k1::SecretKey;
type PublicKey (line 83) | type PublicKey = RipplePublicKey;
type Format (line 84) | type Format = RippleFormat;
method from_secret_key (line 86) | fn from_secret_key(
method from_public_key (line 93) | fn from_public_key(
type Err (line 103) | type Err = AddressError;
method from_str (line 104) | fn from_str(addr: &str) -> Result<Self, Self::Err> {
method fmt (line 144) | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
function test_from_secret_key (line 183) | fn test_from_secret_key() {
function test_from_str (line 197) | fn test_from_str() {
function test_from_str_invalid_address (line 211) | fn test_from_str_invalid_address() {
FILE: crates/anychain-ripple/src/format.rs
type RippleFormat (line 7) | pub enum RippleFormat {
method fmt (line 14) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
FILE: crates/anychain-ripple/src/public_key.rs
type RipplePublicKey (line 7) | pub struct RipplePublicKey {
method from_secp256k1_public_key (line 35) | pub fn from_secp256k1_public_key(
method to_secp256k1_public_key (line 46) | pub fn to_secp256k1_public_key(&self) -> libsecp256k1::PublicKey {
method serialize (line 51) | pub fn serialize(&self) -> Vec<u8> {
method is_compressed (line 59) | pub fn is_compressed(&self) -> bool {
method fmt (line 82) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
type SecretKey (line 15) | type SecretKey = libsecp256k1::SecretKey;
type Address (line 16) | type Address = RippleAddress;
type Format (line 17) | type Format = RippleFormat;
method from_secret_key (line 20) | fn from_secret_key(secret_key: &Self::SecretKey) -> Self {
method to_address (line 28) | fn to_address(&self, format: &Self::Format) -> Result<Self::Address, Add...
type Err (line 65) | type Err = PublicKeyError;
method from_str (line 67) | fn from_str(public_key: &str) -> Result<Self, Self::Err> {
FILE: crates/anychain-ripple/src/transaction.rs
type RippleTransactionParameters (line 14) | pub struct RippleTransactionParameters {
type RippleTransaction (line 25) | pub struct RippleTransaction {
method fmt (line 107) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
method to_st (line 113) | fn to_st(&self) -> Result<SerializedType, TransactionError> {
method from_st (line 212) | fn from_st(st: &SerializedType) -> Result<Self, TransactionError> {
method set_public_key (line 398) | pub fn set_public_key(&mut self, pk: Vec<u8>) -> Result<(), Transactio...
type Address (line 31) | type Address = RippleAddress;
type Format (line 32) | type Format = RippleFormat;
type PublicKey (line 33) | type PublicKey = RipplePublicKey;
type TransactionParameters (line 34) | type TransactionParameters = RippleTransactionParameters;
type TransactionId (line 35) | type TransactionId = RippleTransactionId;
method new (line 37) | fn new(parameters: &Self::TransactionParameters) -> Result<Self, Transac...
method sign (line 44) | fn sign(&mut self, rs: Vec<u8>, _recid: u8) -> Result<Vec<u8>, Transacti...
method from_bytes (line 55) | fn from_bytes(stream: &[u8]) -> Result<Self, TransactionError> {
method to_bytes (line 70) | fn to_bytes(&self) -> Result<Vec<u8>, TransactionError> {
method to_transaction_id (line 74) | fn to_transaction_id(&self) -> Result<Self::TransactionId, TransactionEr...
type Err (line 99) | type Err = TransactionError;
method from_str (line 101) | fn from_str(tx: &str) -> Result<Self, Self::Err> {
type RippleTransactionId (line 405) | pub struct RippleTransactionId {
method fmt (line 412) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
type SerializedTypeID (line 418) | enum SerializedTypeID {
method from_u8 (line 430) | fn from_u8(b: u8) -> Result<Self, TransactionError> {
method fmt (line 448) | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
type SerializedType (line 462) | enum SerializedType {
method typ (line 644) | fn typ(&self) -> SerializedTypeID {
method val (line 656) | fn val(&self) -> u32 {
method serialize_type (line 668) | fn serialize_type(&self) -> Result<Vec<u8>, TransactionError> {
method serialize (line 672) | fn serialize(&self) -> Result<Vec<u8>, TransactionError> {
method deserialize (line 713) | fn deserialize(
method add (line 818) | fn add(&mut self, st: SerializedType) -> Result<(), TransactionError> {
method sort (line 834) | fn sort(&mut self) -> Result<(), TransactionError> {
method eq (line 500) | fn eq(&self, other: &Self) -> bool {
method cmp (line 511) | fn cmp(&self, other: &Self) -> Ordering {
method partial_cmp (line 532) | fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
function serialize_len (line 537) | fn serialize_len(mut len: u32) -> Result<Vec<u8>, TransactionError> {
function deserialize_len (line 558) | fn deserialize_len(stream: &mut &[u8]) -> Result<u32, TransactionError> {
function serialize_type (line 584) | fn serialize_type(typ: SerializedTypeID, val: u32) -> Result<Vec<u8>, Tr...
function deserialize_type (line 615) | fn deserialize_type(stream: &mut &[u8]) -> Result<(u8, u8), TransactionE...
function test_tx_gen (line 857) | fn test_tx_gen() {
function test_tx_from_str (line 907) | fn test_tx_from_str() {
function test_tx_from_str_rejects_tampered_source_account (line 941) | fn test_tx_from_str_rejects_tampered_source_account() {
FILE: crates/anychain-tron/src/abi.rs
type Param (line 9) | pub struct Param {
method from (line 15) | fn from(address: &TronAddress) -> Self {
method from (line 24) | fn from(amount: U256) -> Self {
function contract_function_call (line 32) | pub fn contract_function_call(function_name: &str, params: &[Param]) -> ...
function trc20_transfer (line 55) | pub fn trc20_transfer(address: &str, amount: &str) -> Vec<u8> {
function trc20_approve (line 62) | pub fn trc20_approve(address: &str, amount: &str) -> Vec<u8> {
function test_contract_function_call (line 78) | fn test_contract_function_call() {
FILE: crates/anychain-tron/src/address.rs
constant ADDRESS_TYPE_PREFIX (line 12) | const ADDRESS_TYPE_PREFIX: u8 = 0x41;
type TronAddress (line 15) | pub struct TronAddress([u8; 21]);
method to_hex (line 45) | pub fn to_hex(&self) -> String {
method as_bytes (line 49) | pub fn as_bytes(&self) -> &[u8] {
method from_bytes (line 53) | pub fn from_bytes(raw: &[u8]) -> Result<Self, AddressError> {
method to_base58 (line 66) | pub fn to_base58(&self) -> String {
method to_token (line 70) | pub fn to_token(&self) -> Token {
method fmt (line 86) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
method fmt (line 92) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type Error (line 98) | type Error = AddressError;
method try_from (line 100) | fn try_from(value: &[u8]) -> Result<Self, AddressError> {
type Error (line 117) | type Error = AddressError;
method try_from (line 119) | fn try_from(value: Vec<u8>) -> Result<Self, Self::Error> {
type Error (line 125) | type Error = AddressError;
method try_from (line 127) | fn try_from(value: &Vec<u8>) -> Result<Self, Self::Error> {
type Error (line 133) | type Error = AddressError;
method try_from (line 135) | fn try_from(value: &str) -> Result<Self, Self::Error> {
method as_ref (line 176) | fn as_ref(&self) -> &[u8] {
type SecretKey (line 18) | type SecretKey = libsecp256k1::SecretKey;
type Format (line 19) | type Format = TronFormat;
type PublicKey (line 20) | type PublicKey = TronPublicKey;
method from_secret_key (line 22) | fn from_secret_key(
method from_public_key (line 29) | fn from_public_key(
method default (line 78) | fn default() -> Self {
type Error (line 141) | type Error = AddressError;
method from_hex (line 143) | fn from_hex<T: AsRef<[u8]>>(hex: T) -> Result<Self, Self::Error> {
type Err (line 149) | type Err = AddressError;
method from_str (line 151) | fn from_str(s: &str) -> Result<Self, AddressError>
function b58encode_check (line 182) | pub fn b58encode_check<T: AsRef<[u8]>>(raw: T) -> String {
function b58decode_check (line 197) | pub fn b58decode_check(s: &str) -> Result<Vec<u8>, AddressError> {
function test_address (line 225) | fn test_address() {
function test_address_from_public (line 252) | fn test_address_from_public() {
function test_address_from_bytes (line 260) | fn test_address_from_bytes() {
FILE: crates/anychain-tron/src/format.rs
type TronFormat (line 8) | pub enum TronFormat {
method fmt (line 15) | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
FILE: crates/anychain-tron/src/protocol/Discover.rs
constant _PROTOBUF_VERSION_CHECK (line 25) | const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_3_7_2;
type Endpoint (line 29) | pub struct Endpoint {
method new (line 51) | pub fn new() -> Endpoint {
method generated_message_descriptor_data (line 55) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 87) | const NAME: &'static str = "Endpoint";
method is_initialized (line 89) | fn is_initialized(&self) -> bool {
method merge_from (line 93) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 118) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 137) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 154) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 158) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 162) | fn new() -> Endpoint {
method clear (line 166) | fn clear(&mut self) {
method default_instance (line 174) | fn default_instance() -> &'static Endpoint {
method descriptor (line 187) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 194) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 200) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 45) | fn default() -> &'a Endpoint {
type PingMessage (line 205) | pub struct PingMessage {
method new (line 227) | pub fn new() -> PingMessage {
method generated_message_descriptor_data (line 231) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 263) | const NAME: &'static str = "PingMessage";
method is_initialized (line 265) | fn is_initialized(&self) -> bool {
method merge_from (line 269) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 294) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 315) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 332) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 336) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 340) | fn new() -> PingMessage {
method clear (line 344) | fn clear(&mut self) {
method default_instance (line 352) | fn default_instance() -> &'static PingMessage {
method descriptor (line 365) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 372) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 378) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 221) | fn default() -> &'a PingMessage {
type PongMessage (line 383) | pub struct PongMessage {
method new (line 403) | pub fn new() -> PongMessage {
method generated_message_descriptor_data (line 407) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 434) | const NAME: &'static str = "PongMessage";
method is_initialized (line 436) | fn is_initialized(&self) -> bool {
method merge_from (line 440) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 462) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 479) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 493) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 497) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 501) | fn new() -> PongMessage {
method clear (line 505) | fn clear(&mut self) {
method default_instance (line 512) | fn default_instance() -> &'static PongMessage {
method descriptor (line 524) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 531) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 537) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 397) | fn default() -> &'a PongMessage {
type FindNeighbours (line 542) | pub struct FindNeighbours {
method new (line 562) | pub fn new() -> FindNeighbours {
method generated_message_descriptor_data (line 566) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 593) | const NAME: &'static str = "FindNeighbours";
method is_initialized (line 595) | fn is_initialized(&self) -> bool {
method merge_from (line 599) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 621) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 638) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 652) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 656) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 660) | fn new() -> FindNeighbours {
method clear (line 664) | fn clear(&mut self) {
method default_instance (line 671) | fn default_instance() -> &'static FindNeighbours {
method descriptor (line 683) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 690) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 696) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 556) | fn default() -> &'a FindNeighbours {
type Neighbours (line 701) | pub struct Neighbours {
method new (line 721) | pub fn new() -> Neighbours {
method generated_message_descriptor_data (line 725) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 752) | const NAME: &'static str = "Neighbours";
method is_initialized (line 754) | fn is_initialized(&self) -> bool {
method merge_from (line 758) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 780) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 798) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 812) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 816) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 820) | fn new() -> Neighbours {
method clear (line 824) | fn clear(&mut self) {
method default_instance (line 831) | fn default_instance() -> &'static Neighbours {
method descriptor (line 843) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 850) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 856) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 715) | fn default() -> &'a Neighbours {
type BackupMessage (line 861) | pub struct BackupMessage {
method new (line 879) | pub fn new() -> BackupMessage {
method generated_message_descriptor_data (line 883) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 905) | const NAME: &'static str = "BackupMessage";
method is_initialized (line 907) | fn is_initialized(&self) -> bool {
method merge_from (line 911) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 930) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 943) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 954) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 958) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 962) | fn new() -> BackupMessage {
method clear (line 966) | fn clear(&mut self) {
method default_instance (line 972) | fn default_instance() -> &'static BackupMessage {
method descriptor (line 983) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 990) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 996) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 873) | fn default() -> &'a BackupMessage {
function file_descriptor_proto (line 1088) | fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescr...
function file_descriptor (line 1096) | pub fn file_descriptor() -> &'static ::protobuf::reflect::FileDescriptor {
FILE: crates/anychain-tron/src/protocol/Tron.rs
constant _PROTOBUF_VERSION_CHECK (line 25) | const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_3_7_2;
type AccountId (line 30) | pub struct AccountId {
method new (line 48) | pub fn new() -> AccountId {
method generated_message_descriptor_data (line 52) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 74) | const NAME: &'static str = "AccountId";
method is_initialized (line 76) | fn is_initialized(&self) -> bool {
method merge_from (line 80) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 99) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 112) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 123) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 127) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 131) | fn new() -> AccountId {
method clear (line 135) | fn clear(&mut self) {
method default_instance (line 141) | fn default_instance() -> &'static AccountId {
method descriptor (line 152) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 159) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 165) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 42) | fn default() -> &'a AccountId {
type Vote (line 171) | pub struct Vote {
method new (line 191) | pub fn new() -> Vote {
method generated_message_descriptor_data (line 195) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 217) | const NAME: &'static str = "Vote";
method is_initialized (line 219) | fn is_initialized(&self) -> bool {
method merge_from (line 223) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 242) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 255) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 266) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 270) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 274) | fn new() -> Vote {
method clear (line 278) | fn clear(&mut self) {
method default_instance (line 284) | fn default_instance() -> &'static Vote {
method descriptor (line 295) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 302) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 308) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 185) | fn default() -> &'a Vote {
type Proposal (line 314) | pub struct Proposal {
method new (line 342) | pub fn new() -> Proposal {
method generated_message_descriptor_data (line 346) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 393) | const NAME: &'static str = "Proposal";
method is_initialized (line 395) | fn is_initialized(&self) -> bool {
method merge_from (line 399) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 445) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 476) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 508) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 512) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 516) | fn new() -> Proposal {
method clear (line 520) | fn clear(&mut self) {
method default_instance (line 531) | fn default_instance() -> &'static Proposal {
method descriptor (line 538) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 545) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 551) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 336) | fn default() -> &'a Proposal {
type State (line 558) | pub enum State {
constant NAME (line 570) | const NAME: &'static str = "State";
method value (line 572) | fn value(&self) -> i32 {
method from_i32 (line 576) | fn from_i32(value: i32) -> ::std::option::Option<State> {
method from_str (line 586) | fn from_str(str: &str) -> ::std::option::Option<State> {
constant VALUES (line 596) | const VALUES: &'static [State] = &[
method enum_descriptor (line 605) | fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor {
method descriptor (line 610) | fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor {
method default (line 617) | fn default() -> Self {
method generated_enum_descriptor_data (line 623) | pub(in super) fn generated_enum_descriptor_data() -> ::protobuf::refle...
constant NAME (line 1197) | const NAME: &'static str = "State";
method value (line 1199) | fn value(&self) -> i32 {
method from_i32 (line 1203) | fn from_i32(value: i32) -> ::std::option::Option<State> {
method from_str (line 1212) | fn from_str(str: &str) -> ::std::option::Option<State> {
constant VALUES (line 1221) | const VALUES: &'static [State] = &[
method enum_descriptor (line 1229) | fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor {
method descriptor (line 1234) | fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor {
method default (line 1241) | fn default() -> Self {
method generated_enum_descriptor_data (line 1247) | pub(in super) fn generated_enum_descriptor_data() -> ::protobuf::refle...
type Exchange (line 632) | pub struct Exchange {
method new (line 660) | pub fn new() -> Exchange {
method generated_message_descriptor_data (line 664) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 711) | const NAME: &'static str = "Exchange";
method is_initialized (line 713) | fn is_initialized(&self) -> bool {
method merge_from (line 717) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 751) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 779) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 805) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 809) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 813) | fn new() -> Exchange {
method clear (line 817) | fn clear(&mut self) {
method default_instance (line 828) | fn default_instance() -> &'static Exchange {
method descriptor (line 844) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 851) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 857) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 654) | fn default() -> &'a Exchange {
type MarketOrder (line 863) | pub struct MarketOrder {
method new (line 903) | pub fn new() -> MarketOrder {
method generated_message_descriptor_data (line 907) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 979) | const NAME: &'static str = "MarketOrder";
method is_initialized (line 981) | fn is_initialized(&self) -> bool {
method merge_from (line 985) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 1034) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 1077) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 1118) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 1122) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 1126) | fn new() -> MarketOrder {
method clear (line 1130) | fn clear(&mut self) {
method default_instance (line 1146) | fn default_instance() -> &'static MarketOrder {
method descriptor (line 1167) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 1174) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 1180) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 897) | fn default() -> &'a MarketOrder {
type State (line 1187) | pub enum State {
constant NAME (line 570) | const NAME: &'static str = "State";
method value (line 572) | fn value(&self) -> i32 {
method from_i32 (line 576) | fn from_i32(value: i32) -> ::std::option::Option<State> {
method from_str (line 586) | fn from_str(str: &str) -> ::std::option::Option<State> {
constant VALUES (line 596) | const VALUES: &'static [State] = &[
method enum_descriptor (line 605) | fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor {
method descriptor (line 610) | fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor {
method default (line 617) | fn default() -> Self {
method generated_enum_descriptor_data (line 623) | pub(in super) fn generated_enum_descriptor_data() -> ::protobuf::refle...
constant NAME (line 1197) | const NAME: &'static str = "State";
method value (line 1199) | fn value(&self) -> i32 {
method from_i32 (line 1203) | fn from_i32(value: i32) -> ::std::option::Option<State> {
method from_str (line 1212) | fn from_str(str: &str) -> ::std::option::Option<State> {
constant VALUES (line 1221) | const VALUES: &'static [State] = &[
method enum_descriptor (line 1229) | fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor {
method descriptor (line 1234) | fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor {
method default (line 1241) | fn default() -> Self {
method generated_enum_descriptor_data (line 1247) | pub(in super) fn generated_enum_descriptor_data() -> ::protobuf::refle...
type MarketOrderList (line 1255) | pub struct MarketOrderList {
method new (line 1271) | pub fn new() -> MarketOrderList {
method generated_message_descriptor_data (line 1275) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 1292) | const NAME: &'static str = "MarketOrderList";
method is_initialized (line 1294) | fn is_initialized(&self) -> bool {
method merge_from (line 1298) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 1314) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 1325) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 1333) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 1337) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 1341) | fn new() -> MarketOrderList {
method clear (line 1345) | fn clear(&mut self) {
method default_instance (line 1350) | fn default_instance() -> &'static MarketOrderList {
method descriptor (line 1360) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 1367) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 1373) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 1265) | fn default() -> &'a MarketOrderList {
type MarketOrderPairList (line 1378) | pub struct MarketOrderPairList {
method new (line 1394) | pub fn new() -> MarketOrderPairList {
method generated_message_descriptor_data (line 1398) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 1415) | const NAME: &'static str = "MarketOrderPairList";
method is_initialized (line 1417) | fn is_initialized(&self) -> bool {
method merge_from (line 1421) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 1437) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 1448) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 1456) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 1460) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 1464) | fn new() -> MarketOrderPairList {
method clear (line 1468) | fn clear(&mut self) {
method default_instance (line 1473) | fn default_instance() -> &'static MarketOrderPairList {
method descriptor (line 1483) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 1490) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 1496) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 1388) | fn default() -> &'a MarketOrderPairList {
type MarketOrderPair (line 1501) | pub struct MarketOrderPair {
method new (line 1519) | pub fn new() -> MarketOrderPair {
method generated_message_descriptor_data (line 1523) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 1545) | const NAME: &'static str = "MarketOrderPair";
method is_initialized (line 1547) | fn is_initialized(&self) -> bool {
method merge_from (line 1551) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 1570) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 1583) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 1594) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 1598) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 1602) | fn new() -> MarketOrderPair {
method clear (line 1606) | fn clear(&mut self) {
method default_instance (line 1612) | fn default_instance() -> &'static MarketOrderPair {
method descriptor (line 1623) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 1630) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 1636) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 1513) | fn default() -> &'a MarketOrderPair {
type MarketAccountOrder (line 1641) | pub struct MarketAccountOrder {
method new (line 1663) | pub fn new() -> MarketAccountOrder {
method generated_message_descriptor_data (line 1667) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 1699) | const NAME: &'static str = "MarketAccountOrder";
method is_initialized (line 1701) | fn is_initialized(&self) -> bool {
method merge_from (line 1705) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 1730) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 1749) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 1766) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 1770) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 1774) | fn new() -> MarketAccountOrder {
method clear (line 1778) | fn clear(&mut self) {
method default_instance (line 1786) | fn default_instance() -> &'static MarketAccountOrder {
method descriptor (line 1799) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 1806) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 1812) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 1657) | fn default() -> &'a MarketAccountOrder {
type MarketPrice (line 1817) | pub struct MarketPrice {
method new (line 1835) | pub fn new() -> MarketPrice {
method generated_message_descriptor_data (line 1839) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 1861) | const NAME: &'static str = "MarketPrice";
method is_initialized (line 1863) | fn is_initialized(&self) -> bool {
method merge_from (line 1867) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 1886) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 1899) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 1910) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 1914) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 1918) | fn new() -> MarketPrice {
method clear (line 1922) | fn clear(&mut self) {
method default_instance (line 1928) | fn default_instance() -> &'static MarketPrice {
method descriptor (line 1939) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 1946) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 1952) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 1829) | fn default() -> &'a MarketPrice {
type MarketPriceList (line 1957) | pub struct MarketPriceList {
method new (line 1977) | pub fn new() -> MarketPriceList {
method generated_message_descriptor_data (line 1981) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 2008) | const NAME: &'static str = "MarketPriceList";
method is_initialized (line 2010) | fn is_initialized(&self) -> bool {
method merge_from (line 2014) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 2036) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 2053) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 2067) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 2071) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 2075) | fn new() -> MarketPriceList {
method clear (line 2079) | fn clear(&mut self) {
method default_instance (line 2086) | fn default_instance() -> &'static MarketPriceList {
method descriptor (line 2098) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 2105) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 2111) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 1971) | fn default() -> &'a MarketPriceList {
type MarketOrderIdList (line 2116) | pub struct MarketOrderIdList {
method new (line 2134) | pub fn new() -> MarketOrderIdList {
method generated_message_descriptor_data (line 2138) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 2160) | const NAME: &'static str = "MarketOrderIdList";
method is_initialized (line 2162) | fn is_initialized(&self) -> bool {
method merge_from (line 2166) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 2185) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 2198) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 2209) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 2213) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 2217) | fn new() -> MarketOrderIdList {
method clear (line 2221) | fn clear(&mut self) {
method default_instance (line 2227) | fn default_instance() -> &'static MarketOrderIdList {
method descriptor (line 2238) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 2245) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 2251) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 2128) | fn default() -> &'a MarketOrderIdList {
type ChainParameters (line 2256) | pub struct ChainParameters {
method new (line 2272) | pub fn new() -> ChainParameters {
method generated_message_descriptor_data (line 2276) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 2293) | const NAME: &'static str = "ChainParameters";
method is_initialized (line 2295) | fn is_initialized(&self) -> bool {
method merge_from (line 2299) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 2315) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 2326) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 2334) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 2338) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 2342) | fn new() -> ChainParameters {
method clear (line 2346) | fn clear(&mut self) {
method default_instance (line 2351) | fn default_instance() -> &'static ChainParameters {
method descriptor (line 2361) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 2368) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 2374) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 2266) | fn default() -> &'a ChainParameters {
type ChainParameter (line 2381) | pub struct ChainParameter {
method new (line 2399) | pub fn new() -> ChainParameter {
method generated_message_descriptor_data (line 2403) | pub(in super) fn generated_message_descriptor_data() -> ::protobuf::re...
constant NAME (line 2425) | const NAME: &'static str = "ChainParameter";
method is_initialized (line 2427) | fn is_initialized(&self) -> bool {
method merge_from (line 2431) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 2450) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 2463) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 2474) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 2478) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 2482) | fn new() -> ChainParameter {
method clear (line 2486) | fn clear(&mut self) {
method default_instance (line 2492) | fn default_instance() -> &'static ChainParameter {
method descriptor (line 2503) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 2510) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 2516) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 2393) | fn default() -> &'a ChainParameter {
type Account (line 2523) | pub struct Account {
method new (line 2641) | pub fn new() -> Account {
method generated_message_descriptor_data (line 2645) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 2872) | const NAME: &'static str = "Account";
method is_initialized (line 2874) | fn is_initialized(&self) -> bool {
method merge_from (line 2878) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 3092) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 3256) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 3426) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 3430) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 3434) | fn new() -> Account {
method clear (line 3438) | fn clear(&mut self) {
method default_instance (line 3485) | fn default_instance() -> &'static Account {
method descriptor (line 3492) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 3499) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 3505) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 2635) | fn default() -> &'a Account {
type Frozen (line 3513) | pub struct Frozen {
method new (line 3531) | pub fn new() -> Frozen {
method generated_message_descriptor_data (line 3535) | pub(in super) fn generated_message_descriptor_data() -> ::protobuf::re...
constant NAME (line 3557) | const NAME: &'static str = "Frozen";
method is_initialized (line 3559) | fn is_initialized(&self) -> bool {
method merge_from (line 3563) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 3582) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 3595) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 3606) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 3610) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 3614) | fn new() -> Frozen {
method clear (line 3618) | fn clear(&mut self) {
method default_instance (line 3624) | fn default_instance() -> &'static Frozen {
method descriptor (line 3635) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 3642) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 3648) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 3525) | fn default() -> &'a Frozen {
type AccountResource (line 3653) | pub struct AccountResource {
method new (line 3691) | pub fn new() -> AccountResource {
method generated_message_descriptor_data (line 3695) | pub(in super) fn generated_message_descriptor_data() -> ::protobuf::re...
constant NAME (line 3767) | const NAME: &'static str = "AccountResource";
method is_initialized (line 3769) | fn is_initialized(&self) -> bool {
method merge_from (line 3773) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 3822) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 3866) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 3907) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 3911) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 3915) | fn new() -> AccountResource {
method clear (line 3919) | fn clear(&mut self) {
method default_instance (line 3935) | fn default_instance() -> &'static AccountResource {
method descriptor (line 3956) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 3963) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 3969) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 3685) | fn default() -> &'a AccountResource {
type FreezeV2 (line 3974) | pub struct FreezeV2 {
method new (line 3992) | pub fn new() -> FreezeV2 {
method generated_message_descriptor_data (line 3996) | pub(in super) fn generated_message_descriptor_data() -> ::protobuf::re...
constant NAME (line 4018) | const NAME: &'static str = "FreezeV2";
method is_initialized (line 4020) | fn is_initialized(&self) -> bool {
method merge_from (line 4024) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 4043) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 4056) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 4067) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 4071) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 4075) | fn new() -> FreezeV2 {
method clear (line 4079) | fn clear(&mut self) {
method default_instance (line 4085) | fn default_instance() -> &'static FreezeV2 {
method descriptor (line 4096) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 4103) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 4109) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 3986) | fn default() -> &'a FreezeV2 {
type UnFreezeV2 (line 4114) | pub struct UnFreezeV2 {
method new (line 4134) | pub fn new() -> UnFreezeV2 {
method generated_message_descriptor_data (line 4138) | pub(in super) fn generated_message_descriptor_data() -> ::protobuf::re...
constant NAME (line 4165) | const NAME: &'static str = "UnFreezeV2";
method is_initialized (line 4167) | fn is_initialized(&self) -> bool {
method merge_from (line 4171) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 4193) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 4209) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 4223) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 4227) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 4231) | fn new() -> UnFreezeV2 {
method clear (line 4235) | fn clear(&mut self) {
method default_instance (line 4242) | fn default_instance() -> &'static UnFreezeV2 {
method descriptor (line 4254) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 4261) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 4267) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 4128) | fn default() -> &'a UnFreezeV2 {
type Key (line 4273) | pub struct Key {
method new (line 4291) | pub fn new() -> Key {
method generated_message_descriptor_data (line 4295) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 4317) | const NAME: &'static str = "Key";
method is_initialized (line 4319) | fn is_initialized(&self) -> bool {
method merge_from (line 4323) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 4342) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 4355) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 4366) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 4370) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 4374) | fn new() -> Key {
method clear (line 4378) | fn clear(&mut self) {
method default_instance (line 4384) | fn default_instance() -> &'static Key {
method descriptor (line 4395) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 4402) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 4408) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 4285) | fn default() -> &'a Key {
type DelegatedResource (line 4413) | pub struct DelegatedResource {
method new (line 4439) | pub fn new() -> DelegatedResource {
method generated_message_descriptor_data (line 4443) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 4485) | const NAME: &'static str = "DelegatedResource";
method is_initialized (line 4487) | fn is_initialized(&self) -> bool {
method merge_from (line 4491) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 4522) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 4547) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 4570) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 4574) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 4578) | fn new() -> DelegatedResource {
method clear (line 4582) | fn clear(&mut self) {
method default_instance (line 4592) | fn default_instance() -> &'static DelegatedResource {
method descriptor (line 4607) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 4614) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 4620) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 4433) | fn default() -> &'a DelegatedResource {
type Authority (line 4625) | pub struct Authority {
method new (line 4643) | pub fn new() -> Authority {
method generated_message_descriptor_data (line 4647) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 4669) | const NAME: &'static str = "authority";
method is_initialized (line 4671) | fn is_initialized(&self) -> bool {
method merge_from (line 4675) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 4694) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 4708) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 4719) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 4723) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 4727) | fn new() -> Authority {
method clear (line 4731) | fn clear(&mut self) {
method default_instance (line 4737) | fn default_instance() -> &'static Authority {
method descriptor (line 4748) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 4755) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 4761) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 4637) | fn default() -> &'a Authority {
type Permission (line 4766) | pub struct Permission {
method new (line 4794) | pub fn new() -> Permission {
method generated_message_descriptor_data (line 4798) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 4845) | const NAME: &'static str = "Permission";
method is_initialized (line 4847) | fn is_initialized(&self) -> bool {
method merge_from (line 4851) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 4885) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 4914) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 4940) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 4944) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 4948) | fn new() -> Permission {
method clear (line 4952) | fn clear(&mut self) {
method default_instance (line 4963) | fn default_instance() -> &'static Permission {
method descriptor (line 4979) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 4986) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 4992) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 4788) | fn default() -> &'a Permission {
type PermissionType (line 4999) | pub enum PermissionType {
constant NAME (line 5009) | const NAME: &'static str = "PermissionType";
method value (line 5011) | fn value(&self) -> i32 {
method from_i32 (line 5015) | fn from_i32(value: i32) -> ::std::option::Option<PermissionType> {
method from_str (line 5024) | fn from_str(str: &str) -> ::std::option::Option<PermissionType> {
constant VALUES (line 5033) | const VALUES: &'static [PermissionType] = &[
method enum_descriptor (line 5041) | fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor {
method descriptor (line 5046) | fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor {
method default (line 5053) | fn default() -> Self {
method generated_enum_descriptor_data (line 5059) | pub(in super) fn generated_enum_descriptor_data() -> ::protobuf::refle...
type Witness (line 5068) | pub struct Witness {
method new (line 5100) | pub fn new() -> Witness {
method generated_message_descriptor_data (line 5104) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 5161) | const NAME: &'static str = "Witness";
method is_initialized (line 5163) | fn is_initialized(&self) -> bool {
method merge_from (line 5167) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 5207) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 5241) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 5273) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 5277) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 5281) | fn new() -> Witness {
method clear (line 5285) | fn clear(&mut self) {
method default_instance (line 5298) | fn default_instance() -> &'static Witness {
method descriptor (line 5316) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 5323) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 5329) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
method new (line 14718) | pub fn new() -> Witness {
method generated_message_descriptor_data (line 14722) | pub(in super::super) fn generated_message_descriptor_data() -> ::proto...
constant NAME (line 14744) | const NAME: &'static str = "Witness";
method is_initialized (line 14746) | fn is_initialized(&self) -> bool {
method merge_from (line 14750) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 14769) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 14782) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 14793) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 14797) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 14801) | fn new() -> Witness {
method clear (line 14805) | fn clear(&mut self) {
method default_instance (line 14811) | fn default_instance() -> &'static Witness {
method descriptor (line 14822) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 14829) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 14835) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 5094) | fn default() -> &'a Witness {
type Votes (line 5335) | pub struct Votes {
method new (line 5355) | pub fn new() -> Votes {
method generated_message_descriptor_data (line 5359) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 5386) | const NAME: &'static str = "Votes";
method is_initialized (line 5388) | fn is_initialized(&self) -> bool {
method merge_from (line 5392) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 5414) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 5432) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 5446) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 5450) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 5454) | fn new() -> Votes {
method clear (line 5458) | fn clear(&mut self) {
method default_instance (line 5465) | fn default_instance() -> &'static Votes {
method descriptor (line 5477) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 5484) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 5490) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 5349) | fn default() -> &'a Votes {
type TXOutput (line 5495) | pub struct TXOutput {
method new (line 5513) | pub fn new() -> TXOutput {
method generated_message_descriptor_data (line 5517) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 5539) | const NAME: &'static str = "TXOutput";
method is_initialized (line 5541) | fn is_initialized(&self) -> bool {
method merge_from (line 5545) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 5564) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 5577) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 5588) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 5592) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 5596) | fn new() -> TXOutput {
method clear (line 5600) | fn clear(&mut self) {
method default_instance (line 5606) | fn default_instance() -> &'static TXOutput {
method descriptor (line 5617) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 5624) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 5630) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 5507) | fn default() -> &'a TXOutput {
type TXInput (line 5635) | pub struct TXInput {
method new (line 5653) | pub fn new() -> TXInput {
method generated_message_descriptor_data (line 5657) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 5679) | const NAME: &'static str = "TXInput";
method is_initialized (line 5681) | fn is_initialized(&self) -> bool {
method merge_from (line 5685) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 5704) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 5718) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 5729) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 5733) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 5737) | fn new() -> TXInput {
method clear (line 5741) | fn clear(&mut self) {
method default_instance (line 5747) | fn default_instance() -> &'static TXInput {
method descriptor (line 5758) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 5765) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 5771) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 5647) | fn default() -> &'a TXInput {
type Raw (line 5778) | pub struct Raw {
method new (line 5798) | pub fn new() -> Raw {
method generated_message_descriptor_data (line 5802) | pub(in super) fn generated_message_descriptor_data() -> ::protobuf::re...
constant NAME (line 5829) | const NAME: &'static str = "raw";
method is_initialized (line 5831) | fn is_initialized(&self) -> bool {
method merge_from (line 5835) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 5857) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 5873) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 5887) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 5891) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 5895) | fn new() -> Raw {
method clear (line 5899) | fn clear(&mut self) {
method default_instance (line 5906) | fn default_instance() -> &'static Raw {
method descriptor (line 5918) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 5925) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 5931) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
method new (line 7757) | pub fn new() -> Raw {
method generated_message_descriptor_data (line 7761) | pub(in super) fn generated_message_descriptor_data() -> ::protobuf::re...
constant NAME (line 7823) | const NAME: &'static str = "raw";
method is_initialized (line 7825) | fn is_initialized(&self) -> bool {
method merge_from (line 7829) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 7872) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 7911) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 7946) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 7950) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 7954) | fn new() -> Raw {
method clear (line 7958) | fn clear(&mut self) {
method default_instance (line 7972) | fn default_instance() -> &'static Raw {
method descriptor (line 7991) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 7998) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 8004) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
method new (line 9225) | pub fn new() -> Raw {
method generated_message_descriptor_data (line 9229) | pub(in super) fn generated_message_descriptor_data() -> ::protobuf::re...
constant NAME (line 9281) | const NAME: &'static str = "raw";
method is_initialized (line 9283) | fn is_initialized(&self) -> bool {
method merge_from (line 9287) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 9324) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 9355) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 9384) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 9388) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 9392) | fn new() -> Raw {
method clear (line 9396) | fn clear(&mut self) {
method default_instance (line 9408) | fn default_instance() -> &'static Raw {
method descriptor (line 9425) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 9432) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 9438) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
method new (line 16675) | pub fn new() -> Raw {
method generated_message_descriptor_data (line 16679) | pub(in super) fn generated_message_descriptor_data() -> ::protobuf::re...
constant NAME (line 16716) | const NAME: &'static str = "Raw";
method is_initialized (line 16718) | fn is_initialized(&self) -> bool {
method merge_from (line 16722) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 16750) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 16772) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 16792) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 16796) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 16800) | fn new() -> Raw {
method clear (line 16804) | fn clear(&mut self) {
method default_instance (line 16813) | fn default_instance() -> &'static Raw {
method descriptor (line 16827) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 16834) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 16840) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 5792) | fn default() -> &'a Raw {
type TXOutputs (line 5937) | pub struct TXOutputs {
method new (line 5953) | pub fn new() -> TXOutputs {
method generated_message_descriptor_data (line 5957) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 5974) | const NAME: &'static str = "TXOutputs";
method is_initialized (line 5976) | fn is_initialized(&self) -> bool {
method merge_from (line 5980) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 5996) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 6007) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 6015) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 6019) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 6023) | fn new() -> TXOutputs {
method clear (line 6027) | fn clear(&mut self) {
method default_instance (line 6032) | fn default_instance() -> &'static TXOutputs {
method descriptor (line 6042) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 6049) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 6055) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 5947) | fn default() -> &'a TXOutputs {
type ResourceReceipt (line 6060) | pub struct ResourceReceipt {
method new (line 6090) | pub fn new() -> ResourceReceipt {
method generated_message_descriptor_data (line 6094) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 6146) | const NAME: &'static str = "ResourceReceipt";
method is_initialized (line 6148) | fn is_initialized(&self) -> bool {
method merge_from (line 6152) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 6189) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 6220) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 6249) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 6253) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 6257) | fn new() -> ResourceReceipt {
method clear (line 6261) | fn clear(&mut self) {
method default_instance (line 6273) | fn default_instance() -> &'static ResourceReceipt {
method descriptor (line 6290) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 6297) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 6303) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 6084) | fn default() -> &'a ResourceReceipt {
type MarketOrderDetail (line 6308) | pub struct MarketOrderDetail {
method new (line 6330) | pub fn new() -> MarketOrderDetail {
method generated_message_descriptor_data (line 6334) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 6366) | const NAME: &'static str = "MarketOrderDetail";
method is_initialized (line 6368) | fn is_initialized(&self) -> bool {
method merge_from (line 6372) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 6397) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 6416) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 6433) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 6437) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 6441) | fn new() -> MarketOrderDetail {
method clear (line 6445) | fn clear(&mut self) {
method default_instance (line 6453) | fn default_instance() -> &'static MarketOrderDetail {
method descriptor (line 6466) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 6473) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 6479) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 6324) | fn default() -> &'a MarketOrderDetail {
type Transaction (line 6484) | pub struct Transaction {
method new (line 6505) | pub fn new() -> Transaction {
method generated_message_descriptor_data (line 6509) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 6536) | const NAME: &'static str = "Transaction";
method is_initialized (line 6538) | fn is_initialized(&self) -> bool {
method merge_from (line 6542) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 6564) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 6582) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 6596) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 6600) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 6604) | fn new() -> Transaction {
method clear (line 6608) | fn clear(&mut self) {
method default_instance (line 6615) | fn default_instance() -> &'static Transaction {
method descriptor (line 6627) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 6634) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 6640) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 6499) | fn default() -> &'a Transaction {
type Contract (line 6647) | pub struct Contract {
method new (line 6671) | pub fn new() -> Contract {
method generated_message_descriptor_data (line 6675) | pub(in super) fn generated_message_descriptor_data() -> ::protobuf::re...
constant NAME (line 6712) | const NAME: &'static str = "Contract";
method is_initialized (line 6714) | fn is_initialized(&self) -> bool {
method merge_from (line 6718) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 6746) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 6769) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 6789) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 6793) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 6797) | fn new() -> Contract {
method clear (line 6801) | fn clear(&mut self) {
method default_instance (line 6810) | fn default_instance() -> &'static Contract {
method descriptor (line 6824) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 6831) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 6837) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 6665) | fn default() -> &'a Contract {
type ContractType (line 6844) | pub enum ContractType {
constant NAME (line 6930) | const NAME: &'static str = "ContractType";
method value (line 6932) | fn value(&self) -> i32 {
method from_i32 (line 6936) | fn from_i32(value: i32) -> ::std::option::Option<ContractType> {
method from_str (line 6983) | fn from_str(str: &str) -> ::std::option::Option<ContractType> {
constant VALUES (line 7030) | const VALUES: &'static [ContractType] = &[
method enum_descriptor (line 7076) | fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor {
method descriptor (line 7081) | fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor {
method default (line 7130) | fn default() -> Self {
method generated_enum_descriptor_data (line 7136) | pub(in super::super) fn generated_enum_descriptor_data() -> ::protobuf...
type Result (line 7144) | pub struct Result {
method new (line 7188) | pub fn new() -> Result {
method generated_message_descriptor_data (line 7192) | pub(in super) fn generated_message_descriptor_data() -> ::protobuf::re...
constant NAME (line 7279) | const NAME: &'static str = "Result";
method is_initialized (line 7281) | fn is_initialized(&self) -> bool {
method merge_from (line 7285) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 7355) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 7411) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 7467) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 7471) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 7475) | fn new() -> Result {
method clear (line 7479) | fn clear(&mut self) {
method default_instance (line 7498) | fn default_instance() -> &'static Result {
method descriptor (line 7505) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 7512) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 7518) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 7182) | fn default() -> &'a Result {
type Code (line 7525) | pub enum Code {
constant NAME (line 7533) | const NAME: &'static str = "code";
method value (line 7535) | fn value(&self) -> i32 {
method from_i32 (line 7539) | fn from_i32(value: i32) -> ::std::option::Option<Code> {
method from_str (line 7547) | fn from_str(str: &str) -> ::std::option::Option<Code> {
constant VALUES (line 7555) | const VALUES: &'static [Code] = &[
method enum_descriptor (line 7562) | fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor {
method descriptor (line 7567) | fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor {
method default (line 7574) | fn default() -> Self {
method generated_enum_descriptor_data (line 7580) | pub(in super::super) fn generated_enum_descriptor_data() -> ::protobuf...
constant NAME (line 8713) | const NAME: &'static str = "code";
method value (line 8715) | fn value(&self) -> i32 {
method from_i32 (line 8719) | fn from_i32(value: i32) -> ::std::option::Option<Code> {
method from_str (line 8727) | fn from_str(str: &str) -> ::std::option::Option<Code> {
constant VALUES (line 8735) | const VALUES: &'static [Code] = &[
method enum_descriptor (line 8742) | fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor {
method descriptor (line 8747) | fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor {
method default (line 8754) | fn default() -> Self {
method generated_enum_descriptor_data (line 8760) | pub(in super) fn generated_enum_descriptor_data() -> ::protobuf::refle...
type ContractResult (line 7587) | pub enum ContractResult {
constant NAME (line 7623) | const NAME: &'static str = "contractResult";
method value (line 7625) | fn value(&self) -> i32 {
method from_i32 (line 7629) | fn from_i32(value: i32) -> ::std::option::Option<ContractResult> {
method from_str (line 7651) | fn from_str(str: &str) -> ::std::option::Option<ContractResult> {
constant VALUES (line 7673) | const VALUES: &'static [ContractResult] = &[
method enum_descriptor (line 7694) | fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor {
method descriptor (line 7699) | fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor {
method default (line 7706) | fn default() -> Self {
method generated_enum_descriptor_data (line 7712) | pub(in super::super) fn generated_enum_descriptor_data() -> ::protobuf...
type Raw (line 7720) | pub struct Raw {
method new (line 5798) | pub fn new() -> Raw {
method generated_message_descriptor_data (line 5802) | pub(in super) fn generated_message_descriptor_data() -> ::protobuf::re...
constant NAME (line 5829) | const NAME: &'static str = "raw";
method is_initialized (line 5831) | fn is_initialized(&self) -> bool {
method merge_from (line 5835) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 5857) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 5873) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 5887) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 5891) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 5895) | fn new() -> Raw {
method clear (line 5899) | fn clear(&mut self) {
method default_instance (line 5906) | fn default_instance() -> &'static Raw {
method descriptor (line 5918) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 5925) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 5931) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
method new (line 7757) | pub fn new() -> Raw {
method generated_message_descriptor_data (line 7761) | pub(in super) fn generated_message_descriptor_data() -> ::protobuf::re...
constant NAME (line 7823) | const NAME: &'static str = "raw";
method is_initialized (line 7825) | fn is_initialized(&self) -> bool {
method merge_from (line 7829) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 7872) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 7911) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 7946) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 7950) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 7954) | fn new() -> Raw {
method clear (line 7958) | fn clear(&mut self) {
method default_instance (line 7972) | fn default_instance() -> &'static Raw {
method descriptor (line 7991) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 7998) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 8004) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
method new (line 9225) | pub fn new() -> Raw {
method generated_message_descriptor_data (line 9229) | pub(in super) fn generated_message_descriptor_data() -> ::protobuf::re...
constant NAME (line 9281) | const NAME: &'static str = "raw";
method is_initialized (line 9283) | fn is_initialized(&self) -> bool {
method merge_from (line 9287) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 9324) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 9355) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 9384) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 9388) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 9392) | fn new() -> Raw {
method clear (line 9396) | fn clear(&mut self) {
method default_instance (line 9408) | fn default_instance() -> &'static Raw {
method descriptor (line 9425) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 9432) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 9438) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
method new (line 16675) | pub fn new() -> Raw {
method generated_message_descriptor_data (line 16679) | pub(in super) fn generated_message_descriptor_data() -> ::protobuf::re...
constant NAME (line 16716) | const NAME: &'static str = "Raw";
method is_initialized (line 16718) | fn is_initialized(&self) -> bool {
method merge_from (line 16722) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 16750) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 16772) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 16792) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 16796) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 16800) | fn new() -> Raw {
method clear (line 16804) | fn clear(&mut self) {
method default_instance (line 16813) | fn default_instance() -> &'static Raw {
method descriptor (line 16827) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 16834) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 16840) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 7751) | fn default() -> &'a Raw {
type TransactionInfo (line 8010) | pub struct TransactionInfo {
method new (line 8072) | pub fn new() -> TransactionInfo {
method generated_message_descriptor_data (line 8076) | fn generated_message_descriptor_data() -> ::protobuf::reflect::Generat...
constant NAME (line 8208) | const NAME: &'static str = "TransactionInfo";
method is_initialized (line 8210) | fn is_initialized(&self) -> bool {
method merge_from (line 8214) | fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) ->...
method compute_size (line 8311) | fn compute_size(&self) -> u64 {
method write_to_with_cached_sizes (line 8397) | fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputS...
method special_fields (line 8480) | fn special_fields(&self) -> &::protobuf::SpecialFields {
method mut_special_fields (line 8484) | fn mut_special_fields(&mut self) -> &mut ::protobuf::SpecialFields {
method new (line 8488) | fn new() -> TransactionInfo {
method clear (line 8492) | fn clear(&mut self) {
method default_instance (line 8520) | fn default_instance() -> &'static TransactionInfo {
method descriptor (line 8527) | fn descriptor() -> ::protobuf::reflect::MessageDescriptor {
method fmt (line 8534) | fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
type RuntimeType (line 8540) | type RuntimeType = ::protobuf::reflect::rt::RuntimeTypeMessage<Self>;
function default (line 8066) | fn default() ->
Condensed preview — 177 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (2,502K chars).
[
{
"path": ".github/workflows/lint-pr.yml",
"chars": 515,
"preview": "name: PR\n\non:\n pull_request_target:\n types:\n - opened\n - edited\n - synchronize\n\npermissions:\n conten"
},
{
"path": ".github/workflows/release.yml",
"chars": 2116,
"preview": "name: Build Binary\n\non:\n push:\n tags:\n # Regex for a version number such as 0.2.1\n - \"[0-9]+.[0-9]+.[0-9]+"
},
{
"path": ".github/workflows/rust.yml",
"chars": 1126,
"preview": "name: Rust CI\n\non:\n push:\n branches: [ \"main\" ]\n pull_request:\n branches: [ \"main\" ]\n\nenv:\n CARGO_TERM_COLOR: a"
},
{
"path": ".gitignore",
"chars": 488,
"preview": "# Generated by Cargo\n# will have compiled files and executables\ndebug/\ntarget/\n\n# Remove Cargo.lock from gitignore if cr"
},
{
"path": "Cargo.toml",
"chars": 2681,
"preview": "[workspace]\nresolver = \"2\"\nmembers = [\n \"crates/anychain-core\",\n \"crates/anychain-bitcoin\",\n \"crates/anychain-e"
},
{
"path": "LICENSE",
"chars": 1084,
"preview": "MIT License\n\nCopyright (c) [2013] [taiyi-research-institute]\n\nPermission is hereby granted, free of charge, to any perso"
},
{
"path": "Makefile",
"chars": 670,
"preview": ".PHONY: all check clean\n\nall: build\n\ncheck: fmt test clippy\n\ntest:\n\t(command -v cargo-nextest && cargo nextest run --all"
},
{
"path": "README.md",
"chars": 8154,
"preview": "## Anychain\n\n[](https://github.com"
},
{
"path": "crates/anychain-bitcoin/Cargo.toml",
"chars": 890,
"preview": "[package]\nname = \"anychain-bitcoin\"\ndescription = \"A Rust library for Bitcoin-focused cryptocurrency wallets, enabling s"
},
{
"path": "crates/anychain-bitcoin/README.md",
"chars": 1816,
"preview": "# anychain-bitcoin\n\nanychain-bitcoin is a Rust crate that provides a simple and efficient way to interact with the Bitco"
},
{
"path": "crates/anychain-bitcoin/src/address.rs",
"chars": 38756,
"preview": "use crate::{BitcoinFormat, BitcoinNetwork, BitcoinPublicKey, Opcode, Prefix, WitnessProgram};\nuse anychain_core::{\n c"
},
{
"path": "crates/anychain-bitcoin/src/amount.rs",
"chars": 12570,
"preview": "use anychain_core::{Amount, AmountError};\n\nuse core::fmt;\nuse serde::Serialize;\nuse std::ops::{Add, Sub};\n\n// Number of "
},
{
"path": "crates/anychain-bitcoin/src/format.rs",
"chars": 2912,
"preview": "use crate::Prefix;\nuse anychain_core::no_std::*;\nuse anychain_core::{AddressError, Format};\n\nuse core::fmt;\nuse core::st"
},
{
"path": "crates/anychain-bitcoin/src/lib.rs",
"chars": 473,
"preview": "#![cfg_attr(not(feature = \"std\"), no_std)]\n#![warn(unused_extern_crates)]\n// #![forbid(unsafe_code)]\n\n#[macro_use]\nexter"
},
{
"path": "crates/anychain-bitcoin/src/network/bitcoin.rs",
"chars": 2188,
"preview": "use crate::{BitcoinFormat, BitcoinNetwork, Prefix};\nuse anychain_core::no_std::*;\nuse anychain_core::{AddressError, Netw"
},
{
"path": "crates/anychain-bitcoin/src/network/bitcoin_testnet.rs",
"chars": 2231,
"preview": "use crate::{BitcoinFormat, BitcoinNetwork, Prefix};\nuse anychain_core::no_std::*;\nuse anychain_core::{AddressError, Netw"
},
{
"path": "crates/anychain-bitcoin/src/network/bitcoincash.rs",
"chars": 2161,
"preview": "use crate::{BitcoinFormat, BitcoinNetwork, Prefix};\nuse anychain_core::no_std::*;\nuse anychain_core::{AddressError, Netw"
},
{
"path": "crates/anychain-bitcoin/src/network/bitcoincash_testnet.rs",
"chars": 2196,
"preview": "use crate::{BitcoinFormat, BitcoinNetwork, Prefix};\nuse anychain_core::no_std::*;\nuse anychain_core::{AddressError, Netw"
},
{
"path": "crates/anychain-bitcoin/src/network/dogecoin.rs",
"chars": 1995,
"preview": "use crate::{BitcoinFormat, BitcoinNetwork, Prefix};\nuse anychain_core::no_std::*;\nuse anychain_core::{AddressError, Netw"
},
{
"path": "crates/anychain-bitcoin/src/network/dogecoin_testnet.rs",
"chars": 2068,
"preview": "use crate::{BitcoinFormat, BitcoinNetwork, Prefix};\nuse anychain_core::no_std::*;\nuse anychain_core::{AddressError, Netw"
},
{
"path": "crates/anychain-bitcoin/src/network/litecoin.rs",
"chars": 2196,
"preview": "use crate::{BitcoinFormat, BitcoinNetwork, Prefix};\nuse anychain_core::no_std::*;\nuse anychain_core::{AddressError, Netw"
},
{
"path": "crates/anychain-bitcoin/src/network/litecoin_testnet.rs",
"chars": 2241,
"preview": "use crate::{BitcoinFormat, BitcoinNetwork, Prefix};\nuse anychain_core::no_std::*;\nuse anychain_core::{AddressError, Netw"
},
{
"path": "crates/anychain-bitcoin/src/network/mod.rs",
"chars": 1689,
"preview": "use crate::format::BitcoinFormat;\nuse anychain_core::no_std::*;\nuse anychain_core::{AddressError, Network};\n\npub mod bit"
},
{
"path": "crates/anychain-bitcoin/src/public_key.rs",
"chars": 21627,
"preview": "use crate::{BitcoinAddress, BitcoinFormat, BitcoinNetwork};\nuse anychain_core::{hex, Address, AddressError, PublicKey, P"
},
{
"path": "crates/anychain-bitcoin/src/transaction.rs",
"chars": 40125,
"preview": "use crate::{\n BitcoinAddress, BitcoinAmount, BitcoinFormat, BitcoinNetwork, BitcoinPublicKey, WitnessProgram,\n BAS"
},
{
"path": "crates/anychain-bitcoin/src/witness_program.rs",
"chars": 14375,
"preview": "//!\n//! WitnessProgram\n//!\n//! This module contains the representation of a Bitcoin witness program and utility function"
},
{
"path": "crates/anychain-cardano/Cargo.toml",
"chars": 1185,
"preview": "[package]\nname = \"anychain-cardano\"\ndescription = \"A Rust library for Cardano-focused cryptocurrency wallets, enabling s"
},
{
"path": "crates/anychain-cardano/README.md",
"chars": 263,
"preview": "# anychain-cardano\n\nanychain-cardano is a Rust library that provides a simple and unified interface for interacting with"
},
{
"path": "crates/anychain-cardano/examples/transfer-ada.rs",
"chars": 12184,
"preview": "use blockfrost::{BlockFrostSettings, BlockfrostAPI, BlockfrostResult, Pagination};\n// use cml_chain::builders::tx_builde"
},
{
"path": "crates/anychain-cardano/src/address.rs",
"chars": 2435,
"preview": "use {\n crate::{format::CardanoFormat, public_key::CardanoPublicKey},\n anychain_core::{Address, AddressError, Publi"
},
{
"path": "crates/anychain-cardano/src/amount.rs",
"chars": 4543,
"preview": "//! Definitions for the native Cardano token and its fractional LOVELACE.\n\nuse {\n anychain_core::{to_basic_unit_u64, "
},
{
"path": "crates/anychain-cardano/src/format.rs",
"chars": 1451,
"preview": "use crate::network::CardanoNetwork;\nuse {\n anychain_core::Format,\n core::{default::Default, fmt},\n};\n\n#[derive(Deb"
},
{
"path": "crates/anychain-cardano/src/lib.rs",
"chars": 279,
"preview": "pub mod address;\npub mod amount;\npub mod format;\npub mod network;\npub mod public_key;\npub mod transaction;\nmod util;\n\npu"
},
{
"path": "crates/anychain-cardano/src/network.rs",
"chars": 1996,
"preview": "/// Mainnet: This is the primary network where actual transactions occur and real ADA is used.\n/// It is the live networ"
},
{
"path": "crates/anychain-cardano/src/public_key.rs",
"chars": 1991,
"preview": "use {\n crate::{address::CardanoAddress, format::CardanoFormat},\n anychain_core::{AddressError, PublicKey, PublicKe"
},
{
"path": "crates/anychain-cardano/src/transaction.rs",
"chars": 12195,
"preview": "use crate::util::create_default_tx_builder;\nuse crate::{CardanoAddress, CardanoFormat, CardanoPublicKey};\nuse anychain_c"
},
{
"path": "crates/anychain-cardano/src/util.rs",
"chars": 1876,
"preview": "use cml_chain::builders::tx_builder::{TransactionBuilder, TransactionBuilderConfigBuilder};\nuse cml_chain::fees::LinearF"
},
{
"path": "crates/anychain-cardano/tests/test_derive.rs",
"chars": 3802,
"preview": "use bip39::Mnemonic;\nuse cml_chain::{\n address::{Address, AddressKind, BaseAddress},\n certs::StakeCredential,\n "
},
{
"path": "crates/anychain-core/Cargo.toml",
"chars": 804,
"preview": "[package]\nname = \"anychain-core\"\nversion = \"0.1.8\"\ndescription = \"A core support for cryptocurrency wallets\"\ncategories "
},
{
"path": "crates/anychain-core/README.md",
"chars": 1860,
"preview": "# anychain-core\n\nanychain-core is a Rust crate that provides core functionality for working with various blockchain impl"
},
{
"path": "crates/anychain-core/src/address.rs",
"chars": 3388,
"preview": "use crate::{\n format::Format,\n no_std::{\n fmt::{Debug, Display},\n hash::Hash,\n FromStr, Strin"
},
{
"path": "crates/anychain-core/src/amount.rs",
"chars": 4424,
"preview": "use {\n crate::no_std::{\n fmt::{Debug, Display},\n hash::Hash,\n String,\n },\n thiserror::Erro"
},
{
"path": "crates/anychain-core/src/error.rs",
"chars": 1020,
"preview": "use crate::{\n no_std::{\n fmt::Error as FmtError, io::Error as IoError, num::ParseIntError as NumParseIntError,"
},
{
"path": "crates/anychain-core/src/format.rs",
"chars": 639,
"preview": "use {\n crate::no_std::{\n fmt::{Debug, Display},\n hash::Hash,\n String, Vec,\n },\n thiserror:"
},
{
"path": "crates/anychain-core/src/lib.rs",
"chars": 772,
"preview": "//! # Model\n//!\n//! A model for cryptocurrency wallets.\n\n#![cfg_attr(not(feature = \"std\"), no_std)]\n#![warn(unused_exter"
},
{
"path": "crates/anychain-core/src/network.rs",
"chars": 645,
"preview": "use {\n crate::no_std::{\n fmt::{Debug, Display},\n hash::Hash,\n FromStr, String,\n },\n thiser"
},
{
"path": "crates/anychain-core/src/no_std/io.rs",
"chars": 3237,
"preview": "//! no-std io replacement\nuse crate::no_std::Vec;\nuse core::{cmp, fmt, mem};\n\npub trait Read {\n fn read(&mut self, bu"
},
{
"path": "crates/anychain-core/src/no_std/mod.rs",
"chars": 561,
"preview": "#[cfg(not(feature = \"std\"))]\n#[doc(hidden)]\npub use alloc::{\n borrow::ToOwned, format, string::FromUtf8Error, string:"
},
{
"path": "crates/anychain-core/src/public_key.rs",
"chars": 2037,
"preview": "use {\n crate::{\n address::{Address, AddressError},\n format::Format,\n no_std::{\n fmt::"
},
{
"path": "crates/anychain-core/src/transaction.rs",
"chars": 6438,
"preview": "use {\n crate::{\n address::{Address, AddressError},\n amount::AmountError,\n format::Format,\n "
},
{
"path": "crates/anychain-core/src/utilities/crypto.rs",
"chars": 718,
"preview": "use ripemd::Ripemd160;\nuse sha2::{Digest, Sha256, Sha512};\nuse sha3::Keccak256;\n\n#[inline]\npub fn sha256(input: &[u8]) -"
},
{
"path": "crates/anychain-core/src/utilities/mod.rs",
"chars": 235,
"preview": "use crate::no_std::*;\n\n//#[cfg_attr(test, macro_use)]\npub mod crypto;\n\npub fn to_hex_string(bytes: &[u8]) -> String {\n "
},
{
"path": "crates/anychain-ethereum/Cargo.toml",
"chars": 957,
"preview": "[package]\nname = \"anychain-ethereum\"\ndescription = \"A Rust library for Ethereum-focused cryptocurrency wallets, enabling"
},
{
"path": "crates/anychain-ethereum/README.md",
"chars": 2079,
"preview": "# AnyChain Ethereum Crate\n\n`anychain-ethereum` is a Rust crate that provides a simple and efficient way to interact with"
},
{
"path": "crates/anychain-ethereum/src/address.rs",
"chars": 6625,
"preview": "use crate::format::EthereumFormat;\nuse crate::public_key::EthereumPublicKey;\nuse anychain_core::{to_hex_string, Address,"
},
{
"path": "crates/anychain-ethereum/src/format.rs",
"chars": 368,
"preview": "use anychain_core::Format;\n\nuse core::fmt;\n\n/// Represents the format of a Ethereum address\n#[derive(Debug, Clone, Parti"
},
{
"path": "crates/anychain-ethereum/src/lib.rs",
"chars": 282,
"preview": "#![cfg_attr(not(feature = \"std\"), no_std)]\n\npub mod address;\npub mod format;\npub mod network;\npub mod public_key;\npub mo"
},
{
"path": "crates/anychain-ethereum/src/network/mainnet.rs",
"chars": 2415,
"preview": "use super::EthereumNetwork;\n\n#[derive(Copy, Clone, Debug)]\npub struct Ethereum;\n\nimpl EthereumNetwork for Ethereum {\n "
},
{
"path": "crates/anychain-ethereum/src/network/mod.rs",
"chars": 169,
"preview": "pub trait EthereumNetwork: Copy + Clone + Send + Sync + 'static {\n const CHAIN_ID: u32;\n}\n\npub mod mainnet;\npub mod t"
},
{
"path": "crates/anychain-ethereum/src/network/testnet.rs",
"chars": 3580,
"preview": "use super::EthereumNetwork;\n\n#[derive(Copy, Clone, Debug)]\npub struct Sepolia; // ETH testnet\n\n// ETH testnet\nimpl Ether"
},
{
"path": "crates/anychain-ethereum/src/public_key.rs",
"chars": 9828,
"preview": "use crate::address::EthereumAddress;\nuse crate::format::EthereumFormat;\nuse anychain_core::{hex, Address, AddressError, "
},
{
"path": "crates/anychain-ethereum/src/transaction/contract.rs",
"chars": 9462,
"preview": "use core::str::FromStr;\n\nuse crate::{EthereumAddress, Transfer};\nuse anychain_core::{hex, TransactionError};\nuse ethabi:"
},
{
"path": "crates/anychain-ethereum/src/transaction/eip1559.rs",
"chars": 11191,
"preview": "use crate::util::{adapt2, pad_zeros, restore_sender, trim_leading_zeros};\nuse crate::{EthereumAddress, EthereumFormat, E"
},
{
"path": "crates/anychain-ethereum/src/transaction/eip3009.rs",
"chars": 9841,
"preview": "use core::marker::PhantomData;\nuse core::str::FromStr;\n\nuse crate::contract::eip3009_transfer_func;\nuse crate::{Ethereum"
},
{
"path": "crates/anychain-ethereum/src/transaction/eip7702.rs",
"chars": 23377,
"preview": "use crate::contract::{erc20_transfer_func, execute_batch_transfer_func, schedule_func};\nuse crate::util::{adapt2, pad_ze"
},
{
"path": "crates/anychain-ethereum/src/transaction/legacy.rs",
"chars": 7609,
"preview": "use super::EthereumTransactionId;\nuse crate::util::{adapt2, pad_zeros, restore_sender, trim_leading_zeros};\nuse crate::{"
},
{
"path": "crates/anychain-ethereum/src/transaction/mod.rs",
"chars": 580,
"preview": "pub mod contract;\npub mod eip1559;\npub mod eip3009;\npub mod eip7702;\npub mod legacy;\n\npub use contract::*;\npub use eip15"
},
{
"path": "crates/anychain-ethereum/src/util.rs",
"chars": 1689,
"preview": "use crate::{EthereumAddress, EthereumFormat, EthereumPublicKey};\nuse anychain_core::{PublicKey, TransactionError};\nuse l"
},
{
"path": "crates/anychain-filecoin/Cargo.toml",
"chars": 1489,
"preview": "[package]\nname = \"anychain-filecoin\"\ndescription = \"A Rust library for Filecoin-focused cryptocurrency wallets, enabling"
},
{
"path": "crates/anychain-filecoin/README.md",
"chars": 1603,
"preview": "# anychain-filecoin\n\nanychain-filecoin is a Rust library that provides a simple and unified interface for interacting wi"
},
{
"path": "crates/anychain-filecoin/src/address.rs",
"chars": 17498,
"preview": "#![allow(non_local_definitions)]\nuse crate::format::FilecoinFormat;\nuse crate::public_key::FilecoinPublicKey;\n\nuse std::"
},
{
"path": "crates/anychain-filecoin/src/amount.rs",
"chars": 3617,
"preview": "use anychain_core::to_basic_unit as to_atto_fil;\n\nuse core::fmt;\nuse num_bigint::BigInt;\n\n/// Represents the amount of f"
},
{
"path": "crates/anychain-filecoin/src/format.rs",
"chars": 397,
"preview": "use anychain_core::Format;\n\nuse core::fmt;\nuse serde::Serialize;\n\n/// Represents the format of a Filecoin address\n#[deri"
},
{
"path": "crates/anychain-filecoin/src/lib.rs",
"chars": 245,
"preview": "pub mod address;\npub use self::address::*;\n\npub mod amount;\npub use self::amount::*;\n\npub mod format;\npub use self::form"
},
{
"path": "crates/anychain-filecoin/src/public_key.rs",
"chars": 6380,
"preview": "use crate::address::FilecoinAddress;\nuse crate::format::FilecoinFormat;\nuse anychain_core::{hex, Address, AddressError, "
},
{
"path": "crates/anychain-filecoin/src/transaction.rs",
"chars": 25922,
"preview": "#![allow(non_local_definitions)]\nuse crate::address::ADDRESS_ENCODER as BASE32_ENCODER;\nuse crate::address::{FilecoinAdd"
},
{
"path": "crates/anychain-filecoin/src/utilities/crypto.rs",
"chars": 1143,
"preview": "/// Hash length of payload for addresses of filecoin.\npub const PAYLOAD_HASH_LEN: usize = 20;\n\n/// Returns a 20-byte add"
},
{
"path": "crates/anychain-filecoin/src/utilities/mod.rs",
"chars": 16,
"preview": "pub mod crypto;\n"
},
{
"path": "crates/anychain-kms/.gitignore",
"chars": 19,
"preview": "target/\n.DS_Store/\n"
},
{
"path": "crates/anychain-kms/Cargo.toml",
"chars": 1556,
"preview": "[package]\nname = \"anychain-kms\"\ndescription = \"A Rust library providing Key Management Schema for AnyChain. Handles gene"
},
{
"path": "crates/anychain-kms/README.md",
"chars": 358,
"preview": "# KMS\nKey Management Schema\n## Introduction\nRust implementation of BIP32、BIP39\n\n\n## Reference\n* [BIP32 Official Doc](htt"
},
{
"path": "crates/anychain-kms/src/bip32/child_number.rs",
"chars": 3328,
"preview": "//! Child numbers\n\nuse crate::bip32::{Error, Result};\nuse core::{\n fmt::{self, Display},\n str::FromStr,\n};\n\n/// In"
},
{
"path": "crates/anychain-kms/src/bip32/derivation_path.rs",
"chars": 4484,
"preview": "//! Derivation paths\n\nuse crate::bip32::{ChildNumber, Error, Result};\nuse alloc::vec::{self, Vec};\nuse core::{\n fmt::"
},
{
"path": "crates/anychain-kms/src/bip32/error.rs",
"chars": 2239,
"preview": "//! Error type.\n\nuse core::fmt::{self, Display};\n\nuse hmac::digest::InvalidLength;\n\n/// Result type.\npub type Result<T> "
},
{
"path": "crates/anychain-kms/src/bip32/extended_key/attrs.rs",
"chars": 565,
"preview": "//! Extended key attributes.\n\nuse crate::bip32::{ChainCode, ChildNumber, Depth, KeyFingerprint};\n\n/// Extended key attri"
},
{
"path": "crates/anychain-kms/src/bip32/extended_key/extended_private_key.rs",
"chars": 8982,
"preview": "//! Extended private keys\n\nuse crate::bip32::{\n ChildNumber, Depth, Error, ExtendedKey, ExtendedKeyAttrs, ExtendedPub"
},
{
"path": "crates/anychain-kms/src/bip32/extended_key/extended_public_key.rs",
"chars": 4719,
"preview": "//! Extended public keys\n\nuse crate::bip32::{\n ChildNumber, DerivationPath, Error, ExtendedKey, ExtendedKeyAttrs, Ext"
},
{
"path": "crates/anychain-kms/src/bip32/extended_key/mod.rs",
"chars": 7753,
"preview": "//! Parser for extended key types (i.e. `xprv` and `xpub`)\n\npub(crate) mod attrs;\npub(crate) mod extended_private_key;\np"
},
{
"path": "crates/anychain-kms/src/bip32/mod.rs",
"chars": 4048,
"preview": "mod child_number;\nmod derivation_path;\nmod error;\nmod extended_key;\nmod prefix;\nmod private_key;\nmod public_key;\n\npub us"
},
{
"path": "crates/anychain-kms/src/bip32/prefix.rs",
"chars": 7123,
"preview": "//! Extended key prefixes.\n\nuse crate::bip32::{Error, ExtendedKey, Result, Version};\nuse core::{\n fmt::{self, Debug, "
},
{
"path": "crates/anychain-kms/src/bip32/private_key.rs",
"chars": 4284,
"preview": "//! Trait for deriving child keys on a given type.\n\nuse crate::bip32::{Error, PublicKey, Result, XprvEd25519, XprvSecp25"
},
{
"path": "crates/anychain-kms/src/bip32/public_key.rs",
"chars": 4549,
"preview": "//! Trait for deriving child keys on a given type.\n\nuse crate::bip32::{KeyFingerprint, Result};\nuse curve25519_dalek::{\n"
},
{
"path": "crates/anychain-kms/src/bip39/crypto.rs",
"chars": 1194,
"preview": "//! These are internal helper functions used when creating a new [`Mnemonic`][Mnemonic], and when turning a [`Mnemonic`]"
},
{
"path": "crates/anychain-kms/src/bip39/error.rs",
"chars": 1209,
"preview": "use super::MnemonicType;\nuse thiserror::Error;\n\n#[derive(Debug, Error)]\npub enum ErrorKind {\n #[error(\"invalid checks"
},
{
"path": "crates/anychain-kms/src/bip39/langs/chinese_simplified.txt",
"chars": 4096,
"preview": "的\n一\n是\n在\n不\n了\n有\n和\n人\n这\n中\n大\n为\n上\n个\n国\n我\n以\n要\n他\n时\n来\n用\n们\n生\n到\n作\n地\n于\n出\n就\n分\n对\n成\n会\n可\n主\n发\n年\n动\n同\n工\n也\n能\n下\n过\n子\n说\n产\n种\n面\n而\n方\n后\n多\n定\n行\n学\n法\n所\n"
},
{
"path": "crates/anychain-kms/src/bip39/langs/chinese_traditional.txt",
"chars": 4096,
"preview": "的\n一\n是\n在\n不\n了\n有\n和\n人\n這\n中\n大\n為\n上\n個\n國\n我\n以\n要\n他\n時\n來\n用\n們\n生\n到\n作\n地\n於\n出\n就\n分\n對\n成\n會\n可\n主\n發\n年\n動\n同\n工\n也\n能\n下\n過\n子\n說\n產\n種\n面\n而\n方\n後\n多\n定\n行\n學\n法\n所\n"
},
{
"path": "crates/anychain-kms/src/bip39/langs/english.txt",
"chars": 13116,
"preview": "abandon\nability\nable\nabout\nabove\nabsent\nabsorb\nabstract\nabsurd\nabuse\naccess\naccident\naccount\naccuse\nachieve\nacid\nacousti"
},
{
"path": "crates/anychain-kms/src/bip39/langs/french.txt",
"chars": 16389,
"preview": "abaisser\nabandon\nabdiquer\nabeille\nabolir\naborder\naboutir\naboyer\nabrasif\nabreuver\nabriter\nabroger\nabrupt\nabsence\nabsolu\na"
},
{
"path": "crates/anychain-kms/src/bip39/langs/italian.txt",
"chars": 16033,
"preview": "abaco\nabbaglio\nabbinato\nabete\nabisso\nabolire\nabrasivo\nabrogato\naccadere\naccenno\naccusato\nacetone\nachille\nacido\nacqua\nacr"
},
{
"path": "crates/anychain-kms/src/bip39/langs/japanese.txt",
"chars": 10173,
"preview": "あいこくしん\nあいさつ\nあいだ\nあおぞら\nあかちゃん\nあきる\nあけがた\nあける\nあこがれる\nあさい\nあさひ\nあしあと\nあじわう\nあずかる\nあずき\nあそぶ\nあたえる\nあたためる\nあたりまえ\nあたる\nあつい\nあつかう\nあっしゅく"
},
{
"path": "crates/anychain-kms/src/bip39/langs/korean.txt",
"chars": 13976,
"preview": "가격\n가끔\n가난\n가능\n가득\n가르침\n가뭄\n가방\n가상\n가슴\n가운데\n가을\n가이드\n가입\n가장\n가정\n가족\n가죽\n각오\nᄀ"
},
{
"path": "crates/anychain-kms/src/bip39/langs/spanish.txt",
"chars": 13659,
"preview": "ábaco\nabdomen\nabeja\nabierto\nabogado\nabono\naborto\nabrazo\nabrir\nabuelo\nabuso\nacabar\nacademia\nacceso\nacción\naceite\nacelga"
},
{
"path": "crates/anychain-kms/src/bip39/language.rs",
"chars": 14712,
"preview": "use super::util::{Bits, Bits11};\nuse super::ErrorKind;\nuse rustc_hash::FxHashMap;\n\npub struct WordMap {\n inner: FxHas"
},
{
"path": "crates/anychain-kms/src/bip39/mnemonic.rs",
"chars": 13969,
"preview": "use super::crypto::{gen_random_bytes, sha256_first_byte};\nuse super::util::{checksum, BitWriter, IterExt};\nuse super::Er"
},
{
"path": "crates/anychain-kms/src/bip39/mnemonic_type.rs",
"chars": 7977,
"preview": "use super::ErrorKind;\nuse anyhow::Error;\nuse std::fmt;\n\nconst ENTROPY_OFFSET: usize = 8;\n\n/// Determines the number of w"
},
{
"path": "crates/anychain-kms/src/bip39/mod.rs",
"chars": 12657,
"preview": "mod crypto;\nmod error;\nmod language;\nmod mnemonic;\nmod mnemonic_type;\nmod seed;\nmod util;\n\npub use error::ErrorKind;\npub"
},
{
"path": "crates/anychain-kms/src/bip39/seed.rs",
"chars": 7058,
"preview": "use super::crypto::pbkdf2;\nuse super::Mnemonic;\nuse std::fmt;\nuse unicode_normalization::UnicodeNormalization;\nuse zeroi"
},
{
"path": "crates/anychain-kms/src/bip39/util.rs",
"chars": 4433,
"preview": "use unicode_normalization::Decompositions;\n\npub(crate) trait IterExt: Iterator {\n fn join<R>(&mut self, glue: &str) -"
},
{
"path": "crates/anychain-kms/src/crypto.rs",
"chars": 429,
"preview": "use hex;\nuse ripemd::{Digest, Ripemd160};\n\npub fn ripemd(msg: &[u8]) -> String {\n // create a RIPEMD-160 hasher insta"
},
{
"path": "crates/anychain-kms/src/error.rs",
"chars": 135,
"preview": "#[derive(Debug, thiserror::Error)]\npub enum Error {\n #[error(\"secp256k1 error\")]\n Secp256k1Error(#[from] libsecp25"
},
{
"path": "crates/anychain-kms/src/lib.rs",
"chars": 7357,
"preview": "#[cfg(feature = \"alloc\")]\nextern crate alloc;\n\n#[cfg(feature = \"std\")]\nextern crate std;\n\npub mod bip32;\npub mod bip39;\n"
},
{
"path": "crates/anychain-neo/Cargo.toml",
"chars": 520,
"preview": "[package]\nname = \"anychain-neo\"\nversion = \"0.1.1\"\nauthors.workspace = true\nedition.workspace = true\nhomepage.workspace ="
},
{
"path": "crates/anychain-neo/src/address.rs",
"chars": 4886,
"preview": "use crate::{NeoFormat, NeoPublicKey};\nuse anychain_core::{\n crypto::{checksum, hash160},\n Address, AddressError, P"
},
{
"path": "crates/anychain-neo/src/format.rs",
"chars": 353,
"preview": "use anychain_core::Format;\n\nuse core::fmt;\n\n/// Represents the format of a Ethereum address\n#[derive(Debug, Clone, Parti"
},
{
"path": "crates/anychain-neo/src/lib.rs",
"chars": 147,
"preview": "mod address;\npub use address::*;\n\nmod format;\npub use format::*;\n\nmod public_key;\npub use public_key::*;\n\nmod transactio"
},
{
"path": "crates/anychain-neo/src/public_key.rs",
"chars": 2082,
"preview": "use crate::{NeoAddress, NeoFormat};\nuse anychain_core::{hex, Address, AddressError, PublicKey, PublicKeyError};\nuse std:"
},
{
"path": "crates/anychain-neo/src/transaction.rs",
"chars": 7628,
"preview": "use crate::{NeoAddress, NeoFormat, NeoPublicKey};\nuse anychain_core::{crypto::sha256, hex, Transaction, TransactionError"
},
{
"path": "crates/anychain-polkadot/Cargo.toml",
"chars": 969,
"preview": "[package]\nname = \"anychain-polkadot\"\ndescription = \"A Rust library for Polkadot cryptocurrency wallets, enabling seamles"
},
{
"path": "crates/anychain-polkadot/README.md",
"chars": 1020,
"preview": "# anychain-polkadot\n\nanychain-polkadot is a Rust library for Polkadot cryptocurrency wallets. It enables seamless transa"
},
{
"path": "crates/anychain-polkadot/src/address.rs",
"chars": 4620,
"preview": "use std::{fmt::Display, marker::PhantomData, str::FromStr};\n\nuse anychain_core::{hex, Address, AddressError, PublicKey, "
},
{
"path": "crates/anychain-polkadot/src/format.rs",
"chars": 323,
"preview": "use anychain_core::Format;\nuse std::fmt::Display;\n\n#[derive(Hash, Clone, PartialEq, PartialOrd, Eq, Ord, Debug)]\npub enu"
},
{
"path": "crates/anychain-polkadot/src/lib.rs",
"chars": 197,
"preview": "mod public_key;\npub use public_key::*;\n\nmod address;\npub use address::*;\n\nmod format;\npub use format::*;\n\nmod transactio"
},
{
"path": "crates/anychain-polkadot/src/network/kusama.rs",
"chars": 708,
"preview": "use std::{fmt::Display, str::FromStr};\n\nuse crate::PolkadotNetwork;\nuse anychain_core::{Network, NetworkError};\n\n#[deriv"
},
{
"path": "crates/anychain-polkadot/src/network/mod.rs",
"chars": 324,
"preview": "mod polkadot;\npub use polkadot::*;\n\nmod kusama;\npub use kusama::*;\n\nmod westend;\npub use westend::*;\n\nmod rococo;\npub us"
},
{
"path": "crates/anychain-polkadot/src/network/polkadot.rs",
"chars": 720,
"preview": "use std::{fmt::Display, str::FromStr};\n\nuse crate::PolkadotNetwork;\nuse anychain_core::{Network, NetworkError};\n\n#[deriv"
},
{
"path": "crates/anychain-polkadot/src/network/rococo.rs",
"chars": 708,
"preview": "use std::{fmt::Display, str::FromStr};\n\nuse crate::PolkadotNetwork;\nuse anychain_core::{Network, NetworkError};\n\n#[deriv"
},
{
"path": "crates/anychain-polkadot/src/network/westend.rs",
"chars": 714,
"preview": "use std::{fmt::Display, str::FromStr};\n\nuse crate::PolkadotNetwork;\nuse anychain_core::{Network, NetworkError};\n\n#[deriv"
},
{
"path": "crates/anychain-polkadot/src/public_key.rs",
"chars": 2656,
"preview": "use crate::{PolkadotAddress, PolkadotFormat, PolkadotNetwork};\nuse anychain_core::{Address, PublicKey, PublicKeyError};\n"
},
{
"path": "crates/anychain-polkadot/src/transaction.rs",
"chars": 14546,
"preview": "use crate::utilities::crypto::blake2b_256;\nuse crate::{PolkadotAddress, PolkadotFormat, PolkadotNetwork, PolkadotPublicK"
},
{
"path": "crates/anychain-polkadot/src/utilities/crypto.rs",
"chars": 323,
"preview": "/// Returns a 32-byte hash for given data\n#[inline]\npub fn blake2b_256(ingest: &[u8]) -> [u8; 32] {\n let digest = bla"
},
{
"path": "crates/anychain-polkadot/src/utilities/mod.rs",
"chars": 16,
"preview": "pub mod crypto;\n"
},
{
"path": "crates/anychain-ripple/Cargo.toml",
"chars": 823,
"preview": "[package]\nname = \"anychain-ripple\"\ndescription = \"A Rust library for interacting with the Ripple blockchain. It provides"
},
{
"path": "crates/anychain-ripple/README.md",
"chars": 1311,
"preview": "anychain-ripple\n\nanychain-ripple is a Rust library that provides a unified interface for interacting with the Ripple blo"
},
{
"path": "crates/anychain-ripple/src/address.rs",
"chars": 7075,
"preview": "use base58::{FromBase58, ToBase58};\nuse std::{fmt::Display, str::FromStr};\n\nuse crate::{RippleFormat, RipplePublicKey};\n"
},
{
"path": "crates/anychain-ripple/src/format.rs",
"chars": 360,
"preview": "use anychain_core::Format;\n\nuse core::fmt;\n\n/// Represents the format of a Ripple address\n#[derive(Debug, Clone, Partial"
},
{
"path": "crates/anychain-ripple/src/lib.rs",
"chars": 187,
"preview": "pub mod address;\npub use self::address::*;\n\npub mod format;\npub use self::format::*;\n\npub mod public_key;\npub use self::"
},
{
"path": "crates/anychain-ripple/src/public_key.rs",
"chars": 2910,
"preview": "use crate::{RippleAddress, RippleFormat};\nuse anychain_core::{hex, Address, AddressError, PublicKey, PublicKeyError};\nus"
},
{
"path": "crates/anychain-ripple/src/transaction.rs",
"chars": 34223,
"preview": "use std::cmp::{Ord, Ordering};\nuse std::{fmt, str::FromStr};\n\nuse crate::{RippleAddress, RippleFormat, RipplePublicKey};"
},
{
"path": "crates/anychain-tron/Cargo.toml",
"chars": 986,
"preview": "[package]\nname = \"anychain-tron\"\ndescription = \"A Rust library for Tron-focused cryptocurrency wallets, enabling seamles"
},
{
"path": "crates/anychain-tron/README.md",
"chars": 1463,
"preview": "# anychain-tron\n\nanychain-tron is a Rust library that provides a simple and unified interface for interacting with the T"
},
{
"path": "crates/anychain-tron/src/abi.rs",
"chars": 2562,
"preview": "use crate::TronAddress;\nuse anychain_core::utilities::crypto::keccak256;\nuse ethabi::{encode, Token};\nuse ethereum_types"
},
{
"path": "crates/anychain-tron/src/address.rs",
"chars": 7829,
"preview": "use crate::{TronFormat, TronPublicKey};\nuse anychain_core::{Address, AddressError, PublicKey};\nuse base58::{FromBase58, "
},
{
"path": "crates/anychain-tron/src/format.rs",
"chars": 391,
"preview": "use anychain_core::Format;\n\nuse core::fmt;\nuse serde::Serialize;\n\n/// Represents the format of a Ethereum address\n#[deri"
},
{
"path": "crates/anychain-tron/src/lib.rs",
"chars": 208,
"preview": "pub mod address;\npub use address::*;\n\npub mod format;\npub use format::*;\n\npub mod public_key;\npub use public_key::*;\n\npu"
},
{
"path": "crates/anychain-tron/src/protocol/Discover.rs",
"chars": 42745,
"preview": "// This file is generated by rust-protobuf 3.3.0. Do not edit\n// .proto file is parsed by protoc --rust-out=...\n// @gene"
},
{
"path": "crates/anychain-tron/src/protocol/Tron.rs",
"chars": 899791,
"preview": "// This file is generated by rust-protobuf 3.3.0. Do not edit\n// .proto file is parsed by protoc --rust-out=...\n// @gene"
},
{
"path": "crates/anychain-tron/src/protocol/account_contract.rs",
"chars": 32049,
"preview": "// This file is generated by rust-protobuf 3.3.0. Do not edit\n// .proto file is parsed by protoc --rust-out=...\n// @gene"
},
{
"path": "crates/anychain-tron/src/protocol/asset_issue_contract.rs",
"chars": 62308,
"preview": "// This file is generated by rust-protobuf 3.3.0. Do not edit\n// .proto file is parsed by protoc --rust-out=...\n// @gene"
},
{
"path": "crates/anychain-tron/src/protocol/balance_contract.rs",
"chars": 125559,
"preview": "// This file is generated by rust-protobuf 3.3.0. Do not edit\n// .proto file is parsed by protoc --rust-out=...\n// @gene"
},
{
"path": "crates/anychain-tron/src/protocol/common.rs",
"chars": 5883,
"preview": "// This file is generated by rust-protobuf 3.3.0. Do not edit\n// .proto file is parsed by protoc --rust-out=...\n// @gene"
},
{
"path": "crates/anychain-tron/src/protocol/exchange_contract.rs",
"chars": 36779,
"preview": "// This file is generated by rust-protobuf 3.3.0. Do not edit\n// .proto file is parsed by protoc --rust-out=...\n// @gene"
},
{
"path": "crates/anychain-tron/src/protocol/market_contract.rs",
"chars": 17878,
"preview": "// This file is generated by rust-protobuf 3.3.0. Do not edit\n// .proto file is parsed by protoc --rust-out=...\n// @gene"
},
{
"path": "crates/anychain-tron/src/protocol/mod.rs",
"chars": 355,
"preview": "// @generated\n\npub mod Discover;\npub mod Tron;\n\npub mod account_contract;\npub mod asset_issue_contract;\npub mod balance_"
},
{
"path": "crates/anychain-tron/src/protocol/proposal_contract.rs",
"chars": 22726,
"preview": "// This file is generated by rust-protobuf 3.3.0. Do not edit\n// .proto file is parsed by protoc --rust-out=...\n// @gene"
},
{
"path": "crates/anychain-tron/src/protocol/shield_contract.rs",
"chars": 85629,
"preview": "// This file is generated by rust-protobuf 3.3.0. Do not edit\n// .proto file is parsed by protoc --rust-out=...\n// @gene"
},
{
"path": "crates/anychain-tron/src/protocol/smart_contract.rs",
"chars": 109727,
"preview": "// This file is generated by rust-protobuf 3.3.0. Do not edit\n// .proto file is parsed by protoc --rust-out=...\n// @gene"
},
{
"path": "crates/anychain-tron/src/protocol/storage_contract.rs",
"chars": 25988,
"preview": "// This file is generated by rust-protobuf 3.3.0. Do not edit\n// .proto file is parsed by protoc --rust-out=...\n// @gene"
},
{
"path": "crates/anychain-tron/src/protocol/vote_asset_contract.rs",
"chars": 10473,
"preview": "// This file is generated by rust-protobuf 3.3.0. Do not edit\n// .proto file is parsed by protoc --rust-out=...\n// @gene"
},
{
"path": "crates/anychain-tron/src/protocol/witness_contract.rs",
"chars": 27399,
"preview": "// This file is generated by rust-protobuf 3.3.0. Do not edit\n// .proto file is parsed by protoc --rust-out=...\n// @gene"
},
{
"path": "crates/anychain-tron/src/public_key.rs",
"chars": 2029,
"preview": "use crate::{TronAddress, TronFormat};\nuse anychain_core::{Address, AddressError, PublicKey, PublicKeyError};\nuse core::{"
},
{
"path": "crates/anychain-tron/src/transaction.rs",
"chars": 10073,
"preview": "use crate::protocol::Tron::transaction::{Contract, Raw as TransactionRaw};\nuse crate::protocol::Tron::Transaction as Tra"
},
{
"path": "crates/anychain-tron/src/trx.rs",
"chars": 8143,
"preview": "use crate::{\n abi,\n protocol::{\n account_contract::AccountCreateContract,\n balance_contract::{\n "
},
{
"path": "docs/design-cn.md",
"chars": 2984,
"preview": "# 设计 AnyChain Wallet SDK 的出发点\n\n1. 支持市值 TVL Top100 Token 的转账交易,包括:BTC、ETH、USDT、BNB、SOL、USDC、TON 等。相应地,需要接入的区块链包括:比特币、以太坊、"
},
{
"path": "docs/design-en.md",
"chars": 3934,
"preview": "# Design Principles for AnyChain Wallet SDK\n\n1. Support transfer transactions for the top 100 tokens by market cap and T"
},
{
"path": "examples/anychain-bitcoin-cli/Cargo.toml",
"chars": 445,
"preview": "[package]\nname = \"anychain-bitcoin-cli\"\nversion = \"0.1.0\"\nedition = \"2021\"\npublish = false\n# See more keys and their def"
},
{
"path": "examples/anychain-bitcoin-cli/README.md",
"chars": 4345,
"preview": "# anychain-bitcoin-cli\n\nA command line program for the generation and/or validation of addresses and transactions of utx"
},
{
"path": "examples/anychain-bitcoin-cli/src/main.rs",
"chars": 16707,
"preview": "use clap::{Arg, Command};\nuse serde_json::Value;\nuse std::str::FromStr;\n\nuse anychain_bitcoin::{\n Bitcoin, BitcoinAdd"
},
{
"path": "examples/anychain-bitcoin-client/Cargo.toml",
"chars": 372,
"preview": "[package]\nname = \"anychain-bitcoin-client\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n# See more keys and their definitions at "
},
{
"path": "examples/anychain-bitcoin-client/src/main.rs",
"chars": 6096,
"preview": "use std::str::FromStr;\n\nuse anychain_bitcoin::{\n BitcoinAddress, BitcoinAmount, BitcoinFormat, BitcoinPublicKey, Bitc"
},
{
"path": "examples/anychain-ethereum-cli/Cargo.toml",
"chars": 465,
"preview": "[package]\nname = \"anychain-ethereum-cli\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n# See more keys and their definitions at ht"
},
{
"path": "examples/anychain-ethereum-cli/README.md",
"chars": 5525,
"preview": "# anychain-ethereum-cli\n\nA command line program for the generation and/or validation of addresses and transactions of ev"
},
{
"path": "examples/anychain-ethereum-cli/src/main.rs",
"chars": 12665,
"preview": "use clap::value_parser;\nuse clap::{Arg, Command};\nuse primitive_types::H160;\nuse primitive_types::U256;\nuse rlp::Encodab"
},
{
"path": "examples/anychain-neo-cli/Cargo.toml",
"chars": 323,
"preview": "[package]\nname = \"anychain-neo-cli\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n# See more keys and their definitions at https:/"
},
{
"path": "examples/anychain-neo-cli/README.md",
"chars": 1687,
"preview": "# anychain-neo-cli\n\nA command line program for the generation and/or validation of addresses and transactions of utxo co"
},
{
"path": "examples/anychain-neo-cli/src/main.rs",
"chars": 2838,
"preview": "use clap::{Arg, Command};\n\nfn main() {\n let matches = Command::new(\"anychain-neo-cli\")\n .subcommands(vec![\n "
},
{
"path": "lib.rs",
"chars": 462,
"preview": "pub extern crate anychain_bitcoin as bitcoin;\npub extern crate anychain_bitcoin_cli as bitcoin_cli;\npub extern crate any"
},
{
"path": "rust-toolchain.toml",
"chars": 99,
"preview": "[toolchain]\nchannel = \"1.95.0\"\ncomponents = [\"clippy\", \"rustfmt\"]\ntargets = []\nprofile = \"minimal\"\n"
}
]
About this extraction
This page contains the full source code of the 0xcregis/anychain GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 177 files (2.2 MB), approximately 582.3k tokens, and a symbol index with 4376 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.