Showing preview only (934K chars total). Download the full file or copy to clipboard to get everything.
Repository: renproject/multichain
Branch: master
Commit: d2e2ed340047
Files: 217
Total size: 876.5 KB
Directory structure:
gitextract_3n3pcdpe/
├── .github/
│ ├── CODEOWNERS
│ └── workflows/
│ ├── build.yml
│ └── test.yml
├── .gitignore
├── .gitmodules
├── Dockerfile
├── LICENSE
├── README.md
├── api/
│ ├── account/
│ │ └── account.go
│ ├── address/
│ │ └── address.go
│ ├── contract/
│ │ └── contract.go
│ ├── gas/
│ │ └── gas.go
│ └── utxo/
│ └── utxo.go
├── chain/
│ ├── arbitrum/
│ │ ├── address.go
│ │ ├── address_test.go
│ │ ├── client.go
│ │ ├── encode.go
│ │ ├── encode_test.go
│ │ ├── gas.go
│ │ └── tx.go
│ ├── avalanche/
│ │ ├── address.go
│ │ ├── address_test.go
│ │ ├── client.go
│ │ ├── encode.go
│ │ ├── encode_test.go
│ │ ├── gas.go
│ │ └── tx.go
│ ├── bitcoin/
│ │ ├── address.go
│ │ ├── address_test.go
│ │ ├── bitcoin.go
│ │ ├── bitcoin_suite_test.go
│ │ ├── bitcoin_test.go
│ │ ├── gas.go
│ │ ├── gas_test.go
│ │ ├── utxo.go
│ │ └── utxo_test.go
│ ├── bitcoincash/
│ │ ├── address.go
│ │ ├── address_test.go
│ │ ├── bitcoincash.go
│ │ ├── bitcoincash_suite_test.go
│ │ ├── bitcoincash_test.go
│ │ ├── gas.go
│ │ ├── gas_test.go
│ │ ├── utxo.go
│ │ └── utxo_test.go
│ ├── bsc/
│ │ ├── address.go
│ │ ├── address_test.go
│ │ ├── client.go
│ │ ├── encode.go
│ │ ├── encode_test.go
│ │ ├── gas.go
│ │ └── tx.go
│ ├── cosmos/
│ │ ├── address.go
│ │ ├── address_test.go
│ │ ├── client.go
│ │ ├── cosmos.go
│ │ ├── cosmos_suite_test.go
│ │ ├── cosmos_test.go
│ │ ├── gas.go
│ │ ├── gas_test.go
│ │ └── tx.go
│ ├── digibyte/
│ │ ├── address.go
│ │ ├── address_test.go
│ │ ├── digibyte.go
│ │ ├── digibyte_suite_test.go
│ │ ├── digibyte_test.go
│ │ ├── gas.go
│ │ ├── gas_test.go
│ │ ├── utxo.go
│ │ └── utxo_test.go
│ ├── dogecoin/
│ │ ├── address.go
│ │ ├── address_test.go
│ │ ├── dogecoin.go
│ │ ├── dogecoin_suite_test.go
│ │ ├── dogecoin_test.go
│ │ ├── gas.go
│ │ ├── gas_test.go
│ │ ├── utxo.go
│ │ └── utxo_test.go
│ ├── ethereum/
│ │ ├── address.go
│ │ ├── address_test.go
│ │ ├── client.go
│ │ ├── encode.go
│ │ ├── encode_test.go
│ │ ├── gas.go
│ │ └── tx.go
│ ├── evm/
│ │ ├── address.go
│ │ ├── address_test.go
│ │ ├── client.go
│ │ ├── encode.go
│ │ ├── encode_test.go
│ │ ├── gas.go
│ │ └── tx.go
│ ├── fantom/
│ │ ├── address.go
│ │ ├── address_test.go
│ │ ├── client.go
│ │ ├── encode.go
│ │ ├── encode_test.go
│ │ ├── gas.go
│ │ └── tx.go
│ ├── filecoin/
│ │ ├── account.go
│ │ ├── account_test.go
│ │ ├── address.go
│ │ ├── address_test.go
│ │ ├── client.go
│ │ ├── client_test.go
│ │ ├── filecoin.go
│ │ ├── filecoin_suite_test.go
│ │ ├── filecoin_test.go
│ │ ├── gas.go
│ │ └── gas_test.go
│ ├── kava/
│ │ ├── address.go
│ │ ├── address_test.go
│ │ ├── client.go
│ │ ├── encode.go
│ │ ├── encode_test.go
│ │ ├── gas.go
│ │ └── tx.go
│ ├── moonbeam/
│ │ ├── address.go
│ │ ├── address_test.go
│ │ ├── client.go
│ │ ├── encode.go
│ │ ├── encode_test.go
│ │ ├── gas.go
│ │ └── tx.go
│ ├── optimism/
│ │ ├── address.go
│ │ ├── address_test.go
│ │ ├── client.go
│ │ ├── encode.go
│ │ ├── encode_test.go
│ │ ├── gas.go
│ │ └── tx.go
│ ├── polygon/
│ │ ├── address.go
│ │ ├── address_test.go
│ │ ├── client.go
│ │ ├── encode.go
│ │ ├── encode_test.go
│ │ ├── gas.go
│ │ └── tx.go
│ ├── solana/
│ │ ├── address.go
│ │ ├── rpc.go
│ │ ├── solana.go
│ │ ├── solana_ffi.go
│ │ ├── solana_ffi_test.go
│ │ ├── solana_suite_test.go
│ │ ├── solana_test.go
│ │ └── solanarpc.go
│ ├── substrate/
│ │ ├── address.go
│ │ └── address_test.go
│ ├── terra/
│ │ ├── address.go
│ │ ├── address_test.go
│ │ ├── terra.go
│ │ ├── terra_suite_test.go
│ │ └── terra_test.go
│ └── zcash/
│ ├── address.go
│ ├── address_test.go
│ ├── gas.go
│ ├── gas_test.go
│ ├── utxo.go
│ ├── utxo_test.go
│ ├── zcash.go
│ ├── zcash_suite_test.go
│ └── zcash_test.go
├── go.mod
├── go.sum
├── infra/
│ ├── acala/
│ │ ├── Dockerfile
│ │ └── run.sh
│ ├── avalanche/
│ │ ├── Dockerfile
│ │ └── run.sh
│ ├── binance/
│ │ ├── Dockerfile
│ │ ├── Dockerfile-riolta
│ │ └── run.sh
│ ├── bitcoin/
│ │ ├── Dockerfile
│ │ ├── bitcoin.conf
│ │ ├── keygen.go
│ │ └── run.sh
│ ├── bitcoincash/
│ │ ├── Dockerfile
│ │ ├── bitcoin.conf
│ │ └── run.sh
│ ├── digibyte/
│ │ ├── Dockerfile
│ │ ├── README.md
│ │ ├── keygen.go
│ │ └── run.sh
│ ├── docker-compose.yaml
│ ├── dogecoin/
│ │ ├── Dockerfile
│ │ ├── dogecoin.conf
│ │ ├── keygen.go
│ │ └── run.sh
│ ├── ethereum/
│ │ ├── Dockerfile
│ │ ├── hardhat.config.js
│ │ ├── package.json
│ │ └── run.sh
│ ├── fantom/
│ │ └── Dockerfile
│ ├── filecoin/
│ │ ├── Dockerfile
│ │ ├── miner.key
│ │ ├── run.sh
│ │ └── user.key
│ ├── goerli/
│ │ ├── Dockerfile
│ │ ├── hardhat.config.js
│ │ ├── package.json
│ │ └── run.sh
│ ├── polygon/
│ │ ├── Dockerfile
│ │ ├── genesis.json
│ │ ├── json-keystore
│ │ ├── nodekey
│ │ ├── password.txt
│ │ ├── run.sh
│ │ └── static-nodes.json
│ ├── terra/
│ │ ├── Dockerfile
│ │ └── run.sh
│ └── zcash/
│ ├── Dockerfile
│ ├── run.sh
│ └── zcash.conf
├── multichain.go
├── multichain_suite_test.go
├── multichain_test.go
└── test.sh
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/CODEOWNERS
================================================
@jazg @tok-kkk
================================================
FILE: .github/workflows/build.yml
================================================
name: Docker Build
on:
push:
tags:
- 'v*.*.*'
jobs:
build:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "1.16.6"
- name: Set output
id: push-info
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Configure git for private modules
env:
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: git config --global url."https://tok-kkk:${TOKEN}@github.com".insteadOf "https://github.com"
- name: Check out solana-ffi with the reference
uses: actions/checkout@v2
with:
repository: renproject/solana-ffi
ref: ${{ env.SOLANA_FFI_COMMIT }}
path: solana-ffi
- name: Install dependencies (Solana FFI)
run: |
sudo apt-get install -y libudev-dev
cd solana-ffi
go get -u github.com/xlab/c-for-go@cef5ec7
make clean
make
go install ./...
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
context: /home/runner/work/multichain/multichain
tags: renbot/multichain:${{ steps.push-info.outputs.tag }}, renbot/multichain:latest
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
================================================
FILE: .github/workflows/test.yml
================================================
name: go
on: [pull_request]
jobs:
test-solana:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: "1.17.13"
- name: Configure git for Private Modules
env:
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: git config --global url."https://jazg:${TOKEN}@github.com".insteadOf "https://github.com"
- name: Check out code into the Go module directory
uses: actions/checkout@v1
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
submodules: recursive
- name: Caching modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-aw-${{ hashFiles('**/go.sum') }}
- name: Cache extern dependencies (FFI)
id: cache-extern
uses: actions/cache@v2
env:
cache-name: cache-externs
with:
path: .extern
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.FILECOIN_FFI_COMMIT }}-${{ env.SOLANA_FFI_COMMIT }}
# Remove apt repos that are known to break from time to time
# See https://github.com/actions/virtual-environments/issues/323
- name: Install dependency packages
run: |
for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y jq mesa-opencl-icd ocl-icd-opencl-dev pkg-config libudev-dev hwloc libhwloc-dev
curl https://sh.rustup.rs -sSf | sh -s -- -y
source $HOME/.cargo/env
- name: Get dependencies
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
go get -u github.com/onsi/ginkgo/ginkgo
go get github.com/onsi/gomega@v1.13.0
go get -u golang.org/x/lint/golint
go get -u github.com/loongy/covermerge
go get -u github.com/mattn/goveralls
go get -u github.com/xlab/c-for-go@cef5ec7
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
cd $GITHUB_WORKSPACE
mkdir .extern && cd .extern
git clone https://github.com/filecoin-project/filecoin-ffi.git
cd filecoin-ffi
git checkout ${{ env.FILECOIN_FFI_COMMIT }}
make
- name: Install dependencies (Solana FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
cd $GITHUB_WORKSPACE/.extern
git clone https://github.com/renproject/solana-ffi.git
cd solana-ffi
git checkout ${{ env.SOLANA_FFI_COMMIT }}
make clean
make
- name: Run vetting
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
go mod edit -replace=github.com/filecoin-project/filecoin-ffi=./.extern/filecoin-ffi
go mod edit -replace=github.com/renproject/solana-ffi=./.extern/solana-ffi
go mod tidy
go vet ./...
- name: Setup environment for Solana tests
run: |
sh -c "$(curl -sSfL https://release.solana.com/v1.8.14/install)"
cd $GITHUB_WORKSPACE
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
echo ${{ secrets.SOLANA_KEY }} > ~/.config/solana/id.json
docker run -d -h 0.0.0.0 -p 8899:8899 -p 8900:8900 renbot/ren-solana:latest
- name: Sleep until the node is up
uses: jakejarvis/wait-action@master
with:
time: "1m"
- name: Check on docker containers
run: docker ps -a
- name: Run tests for Solana
run: |
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
cd $GITHUB_WORKSPACE/chain/solana
go test -timeout 100s
test-filecoin:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: "1.17.13"
id: go
- name: Configure git for Private Modules
env:
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: git config --global url."https://jazg:${TOKEN}@github.com".insteadOf "https://github.com"
- name: Check out code into the Go module directory
uses: actions/checkout@v1
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
submodules: recursive
- name: Caching modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-aw-${{ hashFiles('**/go.sum') }}
- name: Cache extern dependencies (FFI)
id: cache-extern
uses: actions/cache@v2
env:
cache-name: cache-externs
with:
path: .extern
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.FILECOIN_FFI_COMMIT }}-${{ env.SOLANA_FFI_COMMIT }}
# Remove apt repos that are known to break from time to time
# See https://github.com/actions/virtual-environments/issues/323
- name: Install dependency packages
run: |
for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y jq mesa-opencl-icd ocl-icd-opencl-dev pkg-config libudev-dev hwloc libhwloc-dev
curl https://sh.rustup.rs -sSf | sh -s -- -y
source $HOME/.cargo/env
- name: Get dependencies
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
go get -u github.com/onsi/ginkgo/ginkgo
go get github.com/onsi/gomega@v1.13.0
go get -u golang.org/x/lint/golint
go get -u github.com/loongy/covermerge
go get -u github.com/mattn/goveralls
go get -u github.com/xlab/c-for-go@cef5ec7
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
cd $GITHUB_WORKSPACE
mkdir .extern && cd .extern
git clone https://github.com/filecoin-project/filecoin-ffi.git
cd filecoin-ffi
git checkout ${{ env.FILECOIN_FFI_COMMIT }}
make
- name: Install dependencies (Solana FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
cd $GITHUB_WORKSPACE/.extern
git clone https://github.com/renproject/solana-ffi.git
cd solana-ffi
git checkout ${{ env.SOLANA_FFI_COMMIT }}
make clean
make
- name: Run vetting
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
go mod edit -replace=github.com/filecoin-project/filecoin-ffi=./.extern/filecoin-ffi
go mod edit -replace=github.com/renproject/solana-ffi=./.extern/solana-ffi
go mod tidy
go vet ./...
- name: Run linting
run: |
cd $GITHUB_WORKSPACE
export PATH=$PATH:$(go env GOPATH)/bin
go get -u golang.org/x/lint/golint
golint $(go list ./... | grep -v filecoin-ffi)
- name: Run multichain infrastructure
run: |
cd $GITHUB_WORKSPACE/infra
source .env
docker run -d -p 1234:1234 -h 0.0.0.0 \
--name infra_filecoin_1 rohitnarurkar/multichain_filecoin:latest
- name: Sleep until the nodes are up
uses: jakejarvis/wait-action@master
with:
time: "10m"
- name: Check on docker containers
run: docker ps -a
- name: Run tests and report test coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source ./infra/.env
cd $GITHUB_WORKSPACE
go test \
-fil=true \
-timeout 1500s
test-zcash:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: "1.17.13"
id: go
- name: Configure git for Private Modules
env:
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: git config --global url."https://jazg:${TOKEN}@github.com".insteadOf "https://github.com"
- name: Check out code into the Go module directory
uses: actions/checkout@v1
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
submodules: recursive
- name: Caching modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-aw-${{ hashFiles('**/go.sum') }}
- name: Cache extern dependencies (FFI)
id: cache-extern
uses: actions/cache@v2
env:
cache-name: cache-externs
with:
path: .extern
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.FILECOIN_FFI_COMMIT }}-${{ env.SOLANA_FFI_COMMIT }}
# Remove apt repos that are known to break from time to time
# See https://github.com/actions/virtual-environments/issues/323
- name: Install dependency packages
run: |
for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y jq mesa-opencl-icd ocl-icd-opencl-dev pkg-config libudev-dev hwloc libhwloc-dev
curl https://sh.rustup.rs -sSf | sh -s -- -y
source $HOME/.cargo/env
- name: Get dependencies
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
go get -u github.com/onsi/ginkgo/ginkgo
go get github.com/onsi/gomega@v1.13.0
go get -u golang.org/x/lint/golint
go get -u github.com/loongy/covermerge
go get -u github.com/mattn/goveralls
go get -u github.com/xlab/c-for-go@cef5ec7
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
cd $GITHUB_WORKSPACE
mkdir .extern && cd .extern
git clone https://github.com/filecoin-project/filecoin-ffi.git
cd filecoin-ffi
git checkout ${{ env.FILECOIN_FFI_COMMIT }}
make
- name: Install dependencies (Solana FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
cd $GITHUB_WORKSPACE/.extern
git clone https://github.com/renproject/solana-ffi.git
cd solana-ffi
git checkout ${{ env.SOLANA_FFI_COMMIT }}
make clean
make
- name: Run vetting
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
go mod edit -replace=github.com/filecoin-project/filecoin-ffi=./.extern/filecoin-ffi
go mod edit -replace=github.com/renproject/solana-ffi=./.extern/solana-ffi
go mod tidy
go vet ./...
- name: Run linting
run: |
cd $GITHUB_WORKSPACE
export PATH=$PATH:$(go env GOPATH)/bin
go get -u golang.org/x/lint/golint
golint $(go list ./... | grep -v filecoin-ffi)
- name: Run multichain infrastructure
run: |
cd $GITHUB_WORKSPACE/infra
source .env
docker-compose up -d --build zcash
- name: Sleep until the nodes are up
uses: jakejarvis/wait-action@master
with:
time: "1m"
- name: Check on docker containers
run: docker ps -a
- name: Run tests and report test coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source ./infra/.env
cd $GITHUB_WORKSPACE
go test \
-zec=true \
-timeout 1500s
test-terra:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: "1.17.13"
id: go
- name: Configure git for Private Modules
env:
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: git config --global url."https://jazg:${TOKEN}@github.com".insteadOf "https://github.com"
- name: Check out code into the Go module directory
uses: actions/checkout@v1
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
submodules: recursive
- name: Caching modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-aw-${{ hashFiles('**/go.sum') }}
- name: Cache extern dependencies (FFI)
id: cache-extern
uses: actions/cache@v2
env:
cache-name: cache-externs
with:
path: .extern
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.FILECOIN_FFI_COMMIT }}-${{ env.SOLANA_FFI_COMMIT }}
# Remove apt repos that are known to break from time to time
# See https://github.com/actions/virtual-environments/issues/323
- name: Install dependency packages
run: |
for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y jq mesa-opencl-icd ocl-icd-opencl-dev pkg-config libudev-dev hwloc libhwloc-dev
curl https://sh.rustup.rs -sSf | sh -s -- -y
source $HOME/.cargo/env
- name: Get dependencies
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
go get -u github.com/onsi/ginkgo/ginkgo
go get github.com/onsi/gomega@v1.13.0
go get -u golang.org/x/lint/golint
go get -u github.com/loongy/covermerge
go get -u github.com/mattn/goveralls
go get -u github.com/xlab/c-for-go@cef5ec7
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
cd $GITHUB_WORKSPACE
mkdir .extern && cd .extern
git clone https://github.com/filecoin-project/filecoin-ffi.git
cd filecoin-ffi
git checkout ${{ env.FILECOIN_FFI_COMMIT }}
make
- name: Install dependencies (Solana FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
cd $GITHUB_WORKSPACE/.extern
git clone https://github.com/renproject/solana-ffi.git
cd solana-ffi
git checkout ${{ env.SOLANA_FFI_COMMIT }}
eval `ssh-agent -s`
make
- name: Run vetting
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
go mod edit -replace=github.com/filecoin-project/filecoin-ffi=./.extern/filecoin-ffi
go mod edit -replace=github.com/renproject/solana-ffi=./.extern/solana-ffi
go mod tidy
go vet ./...
- name: Run linting
run: |
cd $GITHUB_WORKSPACE
export PATH=$PATH:$(go env GOPATH)/bin
go get -u golang.org/x/lint/golint
golint $(go list ./... | grep -v filecoin-ffi)
- name: Run multichain infrastructure
run: |
cd $GITHUB_WORKSPACE/infra
source .env
docker-compose up -d --build terra
- name: Sleep until the nodes are up
uses: jakejarvis/wait-action@master
with:
time: "1m"
- name: Check on docker containers
run: docker ps -a
- name: Run tests and report test coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source ./infra/.env
cd $GITHUB_WORKSPACE
go test \
-luna=true \
-timeout 1500s
test-dogecoin:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: "1.17.13"
id: go
- name: Configure git for Private Modules
env:
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: git config --global url."https://jazg:${TOKEN}@github.com".insteadOf "https://github.com"
- name: Check out code into the Go module directory
uses: actions/checkout@v1
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
submodules: recursive
- name: Caching modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-aw-${{ hashFiles('**/go.sum') }}
- name: Cache extern dependencies (FFI)
id: cache-extern
uses: actions/cache@v2
env:
cache-name: cache-externs
with:
path: .extern
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.FILECOIN_FFI_COMMIT }}-${{ env.SOLANA_FFI_COMMIT }}
# Remove apt repos that are known to break from time to time
# See https://github.com/actions/virtual-environments/issues/323
- name: Install dependency packages
run: |
for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y jq mesa-opencl-icd ocl-icd-opencl-dev pkg-config libudev-dev hwloc libhwloc-dev
curl https://sh.rustup.rs -sSf | sh -s -- -y
source $HOME/.cargo/env
- name: Get dependencies
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
go get -u github.com/onsi/ginkgo/ginkgo
go get github.com/onsi/gomega@v1.13.0
go get -u golang.org/x/lint/golint
go get -u github.com/loongy/covermerge
go get -u github.com/mattn/goveralls
go get -u github.com/xlab/c-for-go@cef5ec7
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
cd $GITHUB_WORKSPACE
mkdir .extern && cd .extern
git clone https://github.com/filecoin-project/filecoin-ffi.git
cd filecoin-ffi
git checkout ${{ env.FILECOIN_FFI_COMMIT }}
make
- name: Install dependencies (Solana FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
cd $GITHUB_WORKSPACE/.extern
git clone https://github.com/renproject/solana-ffi.git
cd solana-ffi
git checkout ${{ env.SOLANA_FFI_COMMIT }}
make clean
make
- name: Run vetting
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
go mod edit -replace=github.com/filecoin-project/filecoin-ffi=./.extern/filecoin-ffi
go mod edit -replace=github.com/renproject/solana-ffi=./.extern/solana-ffi
go mod tidy
go vet ./...
- name: Run linting
run: |
cd $GITHUB_WORKSPACE
export PATH=$PATH:$(go env GOPATH)/bin
go get -u golang.org/x/lint/golint
golint $(go list ./... | grep -v filecoin-ffi)
- name: Run multichain infrastructure
run: |
cd $GITHUB_WORKSPACE/infra
source .env
docker-compose up -d --build dogecoin
- name: Sleep until the nodes are up
uses: jakejarvis/wait-action@master
with:
time: "1m"
- name: Check on docker containers
run: docker ps -a
- name: Run tests and report test coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source ./infra/.env
cd $GITHUB_WORKSPACE
go test \
-doge=true \
-timeout 1500s
test-btc-bch:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: "1.17.13"
id: go
- name: Configure git for Private Modules
env:
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: git config --global url."https://jazg:${TOKEN}@github.com".insteadOf "https://github.com"
- name: Check out code into the Go module directory
uses: actions/checkout@v1
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
submodules: recursive
- name: Caching modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-aw-${{ hashFiles('**/go.sum') }}
- name: Cache extern dependencies (FFI)
id: cache-extern
uses: actions/cache@v2
env:
cache-name: cache-externs
with:
path: .extern
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.FILECOIN_FFI_COMMIT }}-${{ env.SOLANA_FFI_COMMIT }}
# Remove apt repos that are known to break from time to time
# See https://github.com/actions/virtual-environments/issues/323
- name: Install dependency packages
run: |
for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y jq mesa-opencl-icd ocl-icd-opencl-dev pkg-config libudev-dev hwloc libhwloc-dev
curl https://sh.rustup.rs -sSf | sh -s -- -y
source $HOME/.cargo/env
- name: Get dependencies
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
go get -u github.com/onsi/ginkgo/ginkgo
go get github.com/onsi/gomega@v1.13.0
go get -u golang.org/x/lint/golint
go get -u github.com/loongy/covermerge
go get -u github.com/mattn/goveralls
go get -u github.com/xlab/c-for-go@cef5ec7
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
cd $GITHUB_WORKSPACE
mkdir .extern && cd .extern
git clone https://github.com/filecoin-project/filecoin-ffi.git
cd filecoin-ffi
git checkout ${{ env.FILECOIN_FFI_COMMIT }}
make
- name: Install dependencies (Solana FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
cd $GITHUB_WORKSPACE/.extern
git clone https://github.com/renproject/solana-ffi.git
cd solana-ffi
git checkout ${{ env.SOLANA_FFI_COMMIT }}
make clean
make
- name: Run vetting
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
go mod edit -replace=github.com/filecoin-project/filecoin-ffi=./.extern/filecoin-ffi
go mod edit -replace=github.com/renproject/solana-ffi=./.extern/solana-ffi
go mod tidy
go vet ./...
- name: Run linting
run: |
cd $GITHUB_WORKSPACE
export PATH=$PATH:$(go env GOPATH)/bin
go get -u golang.org/x/lint/golint
golint $(go list ./... | grep -v filecoin-ffi)
- name: Run multichain infrastructure
run: |
cd $GITHUB_WORKSPACE/infra
source .env
docker-compose up -d --build \
bitcoin \
bitcoincash
- name: Sleep until the nodes are up
uses: jakejarvis/wait-action@master
with:
time: "1m"
- name: Check on docker containers
run: docker ps -a
- name: Run tests and report test coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source ./infra/.env
cd $GITHUB_WORKSPACE
go test \
-btc=true \
-bch=true \
-timeout 1500s
test-avax:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: "1.17.13"
id: go
- name: Configure git for Private Modules
env:
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: git config --global url."https://jazg:${TOKEN}@github.com".insteadOf "https://github.com"
- name: Check out code into the Go module directory
uses: actions/checkout@v1
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
submodules: recursive
- name: Caching modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-aw-${{ hashFiles('**/go.sum') }}
- name: Cache extern dependencies (FFI)
id: cache-extern
uses: actions/cache@v2
env:
cache-name: cache-externs
with:
path: .extern
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.FILECOIN_FFI_COMMIT }}-${{ env.SOLANA_FFI_COMMIT }}
# Remove apt repos that are known to break from time to time
# See https://github.com/actions/virtual-environments/issues/323
- name: Install dependency packages
run: |
for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y jq mesa-opencl-icd ocl-icd-opencl-dev pkg-config libudev-dev hwloc libhwloc-dev
curl https://sh.rustup.rs -sSf | sh -s -- -y
source $HOME/.cargo/env
- name: Get dependencies
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
go get -u github.com/onsi/ginkgo/ginkgo
go get github.com/onsi/gomega@v1.13.0
go get -u golang.org/x/lint/golint
go get -u github.com/loongy/covermerge
go get -u github.com/mattn/goveralls
go get -u github.com/xlab/c-for-go@cef5ec7
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
cd $GITHUB_WORKSPACE
mkdir .extern && cd .extern
git clone https://github.com/filecoin-project/filecoin-ffi.git
cd filecoin-ffi
git checkout ${{ env.FILECOIN_FFI_COMMIT }}
make
- name: Install dependencies (Solana FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
cd $GITHUB_WORKSPACE/.extern
git clone https://github.com/renproject/solana-ffi.git
cd solana-ffi
git checkout ${{ env.SOLANA_FFI_COMMIT }}
make clean
make
- name: Run vetting
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
go mod edit -replace=github.com/filecoin-project/filecoin-ffi=./.extern/filecoin-ffi
go mod edit -replace=github.com/renproject/solana-ffi=./.extern/solana-ffi
go mod tidy
go vet ./...
- name: Run linting
run: |
cd $GITHUB_WORKSPACE
export PATH=$PATH:$(go env GOPATH)/bin
go get -u golang.org/x/lint/golint
golint $(go list ./... | grep -v filecoin-ffi)
- name: Run multichain infrastructure
run: |
cd $GITHUB_WORKSPACE/infra
source .env
docker-compose up -d --build avalanche
- name: Sleep until the nodes are up
uses: jakejarvis/wait-action@master
with:
time: "1m"
- name: Check on docker containers
run: docker ps -a
- name: Run tests and report test coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source ./infra/.env
cd $GITHUB_WORKSPACE
go test \
-avax=true \
-timeout 1500s
test-ftm:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: "1.17.13"
id: go
- name: Configure git for Private Modules
env:
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: git config --global url."https://jazg:${TOKEN}@github.com".insteadOf "https://github.com"
- name: Check out code into the Go module directory
uses: actions/checkout@v1
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
submodules: recursive
- name: Caching modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-aw-${{ hashFiles('**/go.sum') }}
- name: Cache extern dependencies (FFI)
id: cache-extern
uses: actions/cache@v2
env:
cache-name: cache-externs
with:
path: .extern
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.FILECOIN_FFI_COMMIT }}-${{ env.SOLANA_FFI_COMMIT }}
# Remove apt repos that are known to break from time to time
# See https://github.com/actions/virtual-environments/issues/323
- name: Install dependency packages
run: |
for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y jq mesa-opencl-icd ocl-icd-opencl-dev pkg-config libudev-dev hwloc libhwloc-dev
curl https://sh.rustup.rs -sSf | sh -s -- -y
source $HOME/.cargo/env
- name: Get dependencies
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
go get -u github.com/onsi/ginkgo/ginkgo
go get github.com/onsi/gomega@v1.13.0
go get -u golang.org/x/lint/golint
go get -u github.com/loongy/covermerge
go get -u github.com/mattn/goveralls
go get -u github.com/xlab/c-for-go@cef5ec7
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
cd $GITHUB_WORKSPACE
mkdir .extern && cd .extern
git clone https://github.com/filecoin-project/filecoin-ffi.git
cd filecoin-ffi
git checkout ${{ env.FILECOIN_FFI_COMMIT }}
make
- name: Install dependencies (Solana FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
cd $GITHUB_WORKSPACE/.extern
git clone https://github.com/renproject/solana-ffi.git
cd solana-ffi
git checkout ${{ env.SOLANA_FFI_COMMIT }}
make clean
make
- name: Run vetting
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
go mod edit -replace=github.com/filecoin-project/filecoin-ffi=./.extern/filecoin-ffi
go mod edit -replace=github.com/renproject/solana-ffi=./.extern/solana-ffi
go mod tidy
go vet ./...
- name: Run linting
run: |
cd $GITHUB_WORKSPACE
export PATH=$PATH:$(go env GOPATH)/bin
go get -u golang.org/x/lint/golint
golint $(go list ./... | grep -v filecoin-ffi)
- name: Run multichain infrastructure
run: |
cd $GITHUB_WORKSPACE/infra
source .env
docker-compose up -d --build fantom
- name: Sleep until the nodes are up
uses: jakejarvis/wait-action@master
with:
time: "1m"
- name: Check on docker containers
run: docker ps -a
- name: Run tests and report test coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source ./infra/.env
cd $GITHUB_WORKSPACE
go test \
-ftm=true \
-timeout 1500s
test-polygon:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: "1.17.13"
id: go
- name: Configure git for Private Modules
env:
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: git config --global url."https://jazg:${TOKEN}@github.com".insteadOf "https://github.com"
- name: Check out code into the Go module directory
uses: actions/checkout@v1
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
submodules: recursive
- name: Caching modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-aw-${{ hashFiles('**/go.sum') }}
- name: Cache extern dependencies (FFI)
id: cache-extern
uses: actions/cache@v2
env:
cache-name: cache-externs
with:
path: .extern
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.FILECOIN_FFI_COMMIT }}-${{ env.SOLANA_FFI_COMMIT }}
# Remove apt repos that are known to break from time to time
# See https://github.com/actions/virtual-environments/issues/323
- name: Install dependency packages
run: |
for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y jq mesa-opencl-icd ocl-icd-opencl-dev pkg-config libudev-dev hwloc libhwloc-dev
curl https://sh.rustup.rs -sSf | sh -s -- -y
source $HOME/.cargo/env
- name: Get dependencies
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
go get -u github.com/onsi/ginkgo/ginkgo
go get github.com/onsi/gomega@v1.13.0
go get -u golang.org/x/lint/golint
go get -u github.com/loongy/covermerge
go get -u github.com/mattn/goveralls
go get -u github.com/xlab/c-for-go@cef5ec7
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
cd $GITHUB_WORKSPACE
mkdir .extern && cd .extern
git clone https://github.com/filecoin-project/filecoin-ffi.git
cd filecoin-ffi
git checkout ${{ env.FILECOIN_FFI_COMMIT }}
make
- name: Install dependencies (Solana FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
cd $GITHUB_WORKSPACE/.extern
git clone https://github.com/renproject/solana-ffi.git
cd solana-ffi
git checkout ${{ env.SOLANA_FFI_COMMIT }}
make clean
make
- name: Run vetting
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
go mod edit -replace=github.com/filecoin-project/filecoin-ffi=./.extern/filecoin-ffi
go mod edit -replace=github.com/renproject/solana-ffi=./.extern/solana-ffi
go mod tidy
go vet ./...
- name: Run linting
run: |
cd $GITHUB_WORKSPACE
export PATH=$PATH:$(go env GOPATH)/bin
go get -u golang.org/x/lint/golint
golint $(go list ./... | grep -v filecoin-ffi)
- name: Run multichain infrastructure
run: |
cd $GITHUB_WORKSPACE/infra
source .env
docker-compose up -d --build polygon
- name: Sleep until the nodes are up
uses: jakejarvis/wait-action@master
with:
time: "1m"
- name: Check on docker containers
run: docker ps -a
- name: Run tests and report test coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source ./infra/.env
cd $GITHUB_WORKSPACE
go test \
-matic=true \
-timeout 1500s
test-bsc:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: "1.17.13"
id: go
- name: Configure git for Private Modules
env:
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: git config --global url."https://jazg:${TOKEN}@github.com".insteadOf "https://github.com"
- name: Check out code into the Go module directory
uses: actions/checkout@v1
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
submodules: recursive
- name: Caching modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-aw-${{ hashFiles('**/go.sum') }}
- name: Cache extern dependencies (FFI)
id: cache-extern
uses: actions/cache@v2
env:
cache-name: cache-externs
with:
path: .extern
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.FILECOIN_FFI_COMMIT }}-${{ env.SOLANA_FFI_COMMIT }}
# Remove apt repos that are known to break from time to time
# See https://github.com/actions/virtual-environments/issues/323
- name: Install dependency packages
run: |
for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y jq mesa-opencl-icd ocl-icd-opencl-dev pkg-config libudev-dev hwloc libhwloc-dev
curl https://sh.rustup.rs -sSf | sh -s -- -y
source $HOME/.cargo/env
- name: Get dependencies
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
go get -u github.com/onsi/ginkgo/ginkgo
go get github.com/onsi/gomega@v1.13.0
go get -u golang.org/x/lint/golint
go get -u github.com/loongy/covermerge
go get -u github.com/mattn/goveralls
go get -u github.com/xlab/c-for-go@cef5ec7
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
cd $GITHUB_WORKSPACE
mkdir .extern && cd .extern
git clone https://github.com/filecoin-project/filecoin-ffi.git
cd filecoin-ffi
git checkout ${{ env.FILECOIN_FFI_COMMIT }}
make
- name: Install dependencies (Solana FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
cd $GITHUB_WORKSPACE/.extern
git clone https://github.com/renproject/solana-ffi.git
cd solana-ffi
git checkout ${{ env.SOLANA_FFI_COMMIT }}
make clean
make
- name: Run vetting
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
go mod edit -replace=github.com/filecoin-project/filecoin-ffi=./.extern/filecoin-ffi
go mod edit -replace=github.com/renproject/solana-ffi=./.extern/solana-ffi
go mod tidy
go vet ./...
- name: Run linting
run: |
cd $GITHUB_WORKSPACE
export PATH=$PATH:$(go env GOPATH)/bin
go get -u golang.org/x/lint/golint
golint $(go list ./... | grep -v filecoin-ffi)
- name: Run multichain infrastructure
run: |
cd $GITHUB_WORKSPACE/infra
source .env
docker-compose up -d --build binance
- name: Sleep until the nodes are up
uses: jakejarvis/wait-action@master
with:
time: "1m"
- name: Check on docker containers
run: docker ps -a
- name: Run tests and report test coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source ./infra/.env
cd $GITHUB_WORKSPACE
go test \
-bsc=true \
-timeout 1500s
test-eth:
runs-on: ubuntu-latest
env:
FILECOIN_FFI_COMMIT: 7912389334e347bbb2eac0520c836830875c39de
SOLANA_FFI_COMMIT: 720c0143d8655bfcd412ae73c949474df2c1dcf3
steps:
- name: Set up Go 1.17
uses: actions/setup-go@v2
with:
go-version: "1.17.13"
id: go
- name: Configure git for Private Modules
env:
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: git config --global url."https://jazg:${TOKEN}@github.com".insteadOf "https://github.com"
- name: Check out code into the Go module directory
uses: actions/checkout@v1
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
submodules: recursive
- name: Caching modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-aw-${{ hashFiles('**/go.sum') }}
- name: Cache extern dependencies (FFI)
id: cache-extern
uses: actions/cache@v2
env:
cache-name: cache-externs
with:
path: .extern
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ env.FILECOIN_FFI_COMMIT }}-${{ env.SOLANA_FFI_COMMIT }}
# Remove apt repos that are known to break from time to time
# See https://github.com/actions/virtual-environments/issues/323
- name: Install dependency packages
run: |
for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y jq mesa-opencl-icd ocl-icd-opencl-dev pkg-config libudev-dev hwloc libhwloc-dev
curl https://sh.rustup.rs -sSf | sh -s -- -y
source $HOME/.cargo/env
- name: Get dependencies
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
go get -u github.com/onsi/ginkgo/ginkgo
go get github.com/onsi/gomega@v1.13.0
go get -u golang.org/x/lint/golint
go get -u github.com/loongy/covermerge
go get -u github.com/mattn/goveralls
go get -u github.com/xlab/c-for-go@cef5ec7
- name: Install dependencies (Filecoin FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
cd $GITHUB_WORKSPACE
mkdir .extern && cd .extern
git clone https://github.com/filecoin-project/filecoin-ffi.git
cd filecoin-ffi
git checkout ${{ env.FILECOIN_FFI_COMMIT }}
make
- name: Install dependencies (Solana FFI)
if: steps.cache-extern.outputs.cache-hit != 'true'
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
cd $GITHUB_WORKSPACE/.extern
git clone https://github.com/renproject/solana-ffi.git
cd solana-ffi
git checkout ${{ env.SOLANA_FFI_COMMIT }}
make clean
make
- name: Run vetting
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source $HOME/.cargo/env
go mod edit -replace=github.com/filecoin-project/filecoin-ffi=./.extern/filecoin-ffi
go mod edit -replace=github.com/renproject/solana-ffi=./.extern/solana-ffi
go mod tidy
go vet ./...
- name: Run linting
run: |
cd $GITHUB_WORKSPACE
export PATH=$PATH:$(go env GOPATH)/bin
go get -u golang.org/x/lint/golint
golint $(go list ./... | grep -v filecoin-ffi)
- name: Run multichain infrastructure
run: |
cd $GITHUB_WORKSPACE/infra
source .env
docker-compose up -d --build ethereum
- name: Sleep until the nodes are up
uses: jakejarvis/wait-action@master
with:
time: "1m"
- name: Check on docker containers
run: docker ps -a
- name: Run tests and report test coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export PATH=$PATH:$(go env GOPATH)/bin
source ./infra/.env
cd $GITHUB_WORKSPACE
go test \
-eth=true \
-timeout 1500s
================================================
FILE: .gitignore
================================================
# Binaries and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Tests
*.test
# Outputs from tools
*.out
# IDE specific files
.idea/
================================================
FILE: .gitmodules
================================================
[submodule "chain/filecoin/filecoin-ffi"]
path = chain/filecoin/filecoin-ffi
url = https://github.com/filecoin-project/filecoin-ffi
[submodule "chain/solana/solana-ffi"]
path = chain/solana/solana-ffi
url = https://github.com/renproject/solana-ffi
================================================
FILE: Dockerfile
================================================
FROM golang
# doing all updates and installs in a single step and removing the apt cache helps reduce the image size
RUN apt-get update && \
apt-get install -y \
mesa-opencl-icd \
ocl-icd-opencl-dev \
libssl-dev \
libudev-dev \
hwloc \
libhwloc-dev \
gcc \
git \
bzr \
jq \
pkg-config \
curl \
wget && \
apt-get upgrade -y && \
rm -rf /var/lib/apt/lists/*
ENV GO111MODULE=on
ENV GOPROXY=https://proxy.golang.org
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN mkdir -p $(go env GOPATH)
WORKDIR $GOPATH
RUN mkdir -p src/github.com/filecoin-project
WORKDIR $GOPATH/src/github.com/filecoin-project
RUN git clone https://github.com/filecoin-project/filecoin-ffi
WORKDIR $GOPATH/src/github.com/filecoin-project/filecoin-ffi
RUN git checkout 7912389334e347bbb2eac0520c836830875c39de
RUN make
RUN go install
COPY ./solana-ffi $GOPATH/src/github.com/renproject/solana-ffi
================================================
FILE: LICENSE
================================================
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
================================================
FILE: README.md
================================================
# `🔗 multichain`
## Layout
`/` declares the assets and chains that exist, but provides no chain-specific implementations.
`/infra` defines a local deployment of the multichain using `docker-compose`. All underlying chains provide a `Dockerfile` and service definition to make running node instances easy. All chains need to add a `Dockerfile` and service definition that allows the multichain to spin up a local development-mode instance of the chain. This is necessary for running comprehensive local test suites.
`/api` defines the different compatibility APIs that exist: Account, Address, Contract, Gas, and UTXO. Chains should implement the APIs that are relevant to them. For example, Bitcoin (and its forks) implements the Address, Gas, and UTXO APIs. No actual implementations should be added to this folder.
`/chain` defines all of the chain-specific implementations of the APIs. Each chain has its own sub-package. For example, Bitcoin, Bitcoin Cash, Dogecoin, and Zcash are all chains that implement the Address, Gas, and UTXO APIs, and each of these implementations are in `/chain/bitcoin`, `/chain/bitcoincash`, `/chain/dogecoin`, and `/chain/zcash` respectively.
## Example
The `🔗 multichain` is designed to be flexible enough to support any kind of chain. Anyone is free to contribute to the `🔗 multichain` by adding support for a new chain, or improving support for an existing chain. To show how this is done, we will walk-through an example: adding support for Dogecoin.
### Chains and Assets
Before doing anything else, let's add an enumeration for the `Asset` and `Chain` types, which can be found in `package multichain`. To avoid favouritism, all assets and chains are listed in alphabetical order. Unless otherwise advised by an offiical team member, the names and tickers found on https://coinmarketcap.com must be used.
Adding an `Asset`:
```go
// Enumeration of supported assets. When introducing a new chain, or new asset
// from an existing chain, you must add a human-readable string to this set of
// enumerated values. Assets must be listed in alphabetical order.
const (
BCH = Asset("BCH") // Bitcoin Cash
BTC = Asset("BTC") // Bitcoin
DOGE = Asset("DOGE") // Dogecoin (This is our new asset!)
ETH = Asset("ETH") // Ether
ZEC = Asset("ZEC") // Zcash
)
```
Adding a `Chain`:
```go
// Enumeration of supported chains. When introducing a new chain, you must add a
// human-readable string to this set of enumerated values. Chains must be listed
// in alphabetical order.
const (
Bitcoin = Chain("Bitcoin")
BitcoinCash = Chain("BitcoinCash")
Dogecoin = Chain("Dogecoin") // (This is our new chain!)
Ethereum = Chain("Ethereum")
Zcash = Chain("Zcash")
)
```
### Docker
Next, we need to setup a Docker container in the `/infra` folder. This is needed for local test suites, allowing for end-to-end integrated testing directly against a node. Doing this requires a couple of steps.
First, we create a new `dogecoin/` folder in the `/infra` folder:
```
/infra
|-- /bitcoin
|-- /bitcoincash
|-- /dogecoin # This is our new folder!
| |-- Dockerfile # This is our new Dockerfile!
| |-- dogecoin.conf
| |-- run.sh # This is our new run file!
|-- /zcash
|-- .env
|-- docker-compose.yaml
```
The new folder _must_ at least contain a `Dockerfile` that installs the node, and a `run.sh` file that runs the nodes. The node _should_ be run in test mode. The new folder can also contain other files that are specific to the needs of the chain being added. In our case, the `dogecoin.conf` file is also needed to configure the node. (We will omit showing all the code here, since there is quite a bit of it, but you can check it out in the `/infra/dogecoin` folder.)
Second, we add an entry to the `.env` file. Our entry _must_ include a private key that will have access to funds, and the public address associated with that private key. We will add:
```sh
#
# Dogecoin
#
# Address that will receive mining rewards. Generally, this is set to an address
# for which the private key is known by a test suite. This allows the test suite
# access to plenty of testing funds.
export DOGECOIN_PK=cRZnRgH2ztcJupCzkWbq2mjiT8PSFAmtYRYb1phg1vSRRcNBX4w4
export DOGECOIN_ADDRESS=n3PSSpR4zqUKWH4tcRjP9aTwJ4GmixQXmt
```
Last, we add a service to the `docker-compose.yaml` file. This allows the node to boot alongside the other nodes in the multichain. This entry must expose the node for use in tests, and must not overlap with other nodes that already exist (ports are reserved on a first-come-first-serve basis). We will define the service as:
```yaml
##
## Dogecoin
##
dogecoin:
build:
context: ./dogecoin
ports:
- "0.0.0.0:18332:18332"
entrypoint:
- "./root/run.sh"
- "${DOGECOIN_ADDRESS}"
```
### Address API
All chains _should_ implement the Address API. Luckily for Dogecoin, it is so similar to Bitcoin that we can re-export the Bitcoin implementation without the need for custom modifications. In `/chain/dogecoin/address.go` we add:
```go
package dogecoin
import "github.com/renproject/multichain/chain/bitcoin"
type (
AddressEncoder = bitcoin.AddressEncoder
AddressDecoder = bitcoin.AddressDecoder
AddressEncodeDecoder = bitcoin.AddressEncodeDecoder
)
```
These three interfaces allow users of the `🔗 multichain` to easily encode and decode Dogecoin addresses. Other chains will need to provide their own implementations, based on their chains address standards.
### Gas API
Most, but not all, chains _should_ implement the Gas API. Again, Dogecoin is so similar to Bitcoin that we can re-export the Bitcoin implementation in `/chain/dogecoin/gas.go`:
```go
package dogecoin
import "github.com/renproject/multichain/chain/bitcoin"
type GasEstimator = bitcoin.GasEstimator
var NewGasEstimator = bitcoin.NewGasEstimator
```
The interface allows users of the `🔗 multichain` to estimate gas prices (although, the current implementation is _very_ simple). The associated function allows users to construct an instance of the interface for Dogecoin.
### UTXO API
Generally speaking, chains fall into two categories: account-based or UTXO-based (and some can even be both). Bitcoin, and its forks, are all UTXO-based chains. As a fork of Bitcoin, Dogecoin is a UTXO-based chain, so we implement the UTXO API. To implement the UTXO API, we must implement the `Tx`, `TxBuilder`, and `Client` interfaces. More information can be found in the comments of `/api/utxo` folder.
Again, the implementation for Dogecoin is trivial. In `/chain/dogecoin/utxo`, we have:
```go
package dogecoin
import "github.com/renproject/multichain/chain/bitcoin"
type (
Tx = bitcoin.Tx
TxBuilder = bitcoin.TxBuilder
Client = bitcoin.Client
ClientOptions = bitcoin.ClientOptions
)
var (
NewTxBuilder = bitcoin.NewTxBuilder
NewClient = bitcoin.NewClient
DefaultClientOptions = bitcoin.DefaultClientOptions
)
```
Up to this point, we have done nothing but re-export Bitcoin. So what makes Dogecoin different? And how can we express that difference? Well, the `/chain/dogecoin` folder is the place where we must define anything else Dogecoin users will need. In the case of Dogecoin, the only thing that differentiates it from Bitcoin is the `*chaincfg.Param` object. We define this in `/chain/dogecoin/dogecoin.go`:
```go
package dogecoin
import (
"github.com/btcsuite/btcd/chaincfg"
)
func init() {
if err := chaincfg.Register(&MainNetParams); err != nil {
panic(err)
}
if err := chaincfg.Register(&RegressionNetParams); err != nil {
panic(err)
}
}
var MainNetParams = chaincfg.Params{
Name: "mainnet",
Net: 0xc0c0c0c0,
// Address encoding magics
PubKeyHashAddrID: 30,
ScriptHashAddrID: 22,
PrivateKeyID: 158,
// BIP32 hierarchical deterministic extended key magics
HDPrivateKeyID: [4]byte{0x02, 0xfa, 0xc3, 0x98}, // starts with xprv
HDPublicKeyID: [4]byte{0x02, 0xfa, 0xca, 0xfd}, // starts with xpub
// Human-readable part for Bech32 encoded segwit addresses, as defined in
// BIP 173. Dogecoin does not actually support this, but we do not want to
// collide with real addresses, so we specify it.
Bech32HRPSegwit: "doge",
}
var RegressionNetParams = chaincfg.Params{
Name: "regtest",
// Dogecoin has 0xdab5bffa as RegTest (same as Bitcoin's RegTest).
// Setting it to an arbitrary value (leet_hex(dogecoin)), so that we can
// register the regtest network.
Net: 0xd063c017,
// Address encoding magics
PubKeyHashAddrID: 111,
ScriptHashAddrID: 196,
PrivateKeyID: 239,
// BIP32 hierarchical deterministic extended key magics
HDPrivateKeyID: [4]byte{0x04, 0x35, 0x83, 0x94}, // starts with xprv
HDPublicKeyID: [4]byte{0x04, 0x35, 0x87, 0xcf}, // starts with xpub
// Human-readable part for Bech32 encoded segwit addresses, as defined in
// BIP 173. Dogecoin does not actually support this, but we do not want to
// collide with real addresses, so we specify it.
Bech32HRPSegwit: "dogert",
}
```
Most of the functions that we have re-exported expected `*chaincfg.Params` as an argument. By defining one for regnet and mainnet, users can construct Dogecoin instances of the UTXO API by using these params.
## Test Suite
1. Install Docker
2. Install Docker Compose
3. Run Docker
4. Run `./test.sh`
Example output:
```sh
Creating network "docker_default" with the default driver
Building bitcoin
...
Successfully built 1ebb03faa04f
Successfully tagged docker_bitcoin:latest
Building bitcoincash
...
Successfully built e12e98011869
Successfully tagged docker_bitcoincash:latest
Building zcash
...
Successfully built 56231a29ca2e
Successfully tagged docker_zcash:latest
docker_bitcoin_1 is up-to-date
docker_bitcoincash_1 is up-to-date
docker_zcash_1 is up-to-date
Waiting for multichain to boot...
=== RUN TestMultichain
Running Suite: Multichain Suite
===============================
...
Stopping docker_bitcoincash_1 ... done
Stopping docker_zcash_1 ... done
Stopping docker_bitcoin_1 ... done
Removing docker_bitcoincash_1 ... done
Removing docker_zcash_1 ... done
Removing docker_bitcoin_1 ... done
Removing network docker_default
Done!
```
================================================
FILE: api/account/account.go
================================================
// Package account defines the Account API. All chains that use an account-based
// model should implement this API. The Account API is used to send and confirm
// transactions between addresses.
package account
import (
"context"
"github.com/renproject/id"
"github.com/renproject/multichain/api/address"
"github.com/renproject/multichain/api/contract"
"github.com/renproject/pack"
)
// The Tx interfaces defines the functionality that must be exposed by
// account-based transactions.
type Tx interface {
// Hash that uniquely identifies the transaction. Hashes are usually the
// result of an irreversible hashing function applied to some serialized
// representation of the transaction.
Hash() pack.Bytes
// From returns the address from which value is being sent.
From() address.Address
// To returns the address to which value is being sent.
To() address.Address
// Value being sent from one address to another.
Value() pack.U256
// Nonce used to order the transaction with respect to all other
// transactions signed and submitted by the sender of this transaction.
Nonce() pack.U256
// Payload returns arbitrary data that is associated with the transaction.
// This payload is often used to send notes between external accounts, or
// call functions on a contract.
Payload() contract.CallData
// Sighashes that must be signed before the transaction can be submitted by
// the client.
Sighashes() ([]pack.Bytes32, error)
// Sign the transaction by injecting signatures for the required sighashes.
// The serialized public key used to sign the sighashes should also be
// specified whenever it is available.
Sign([]pack.Bytes65, pack.Bytes) error
// Serialize the transaction into bytes. This is the format in which the
// transaction will be submitted by the client.
Serialize() (pack.Bytes, error)
}
// The TxBuilder interface defines the functionality required to build
// account-based transactions. Most chain implementations require additional
// information, and this should be accepted during the construction of the
// chain-specific transaction builder.
type TxBuilder interface {
BuildTx(ctx context.Context, fromPubKey *id.PubKey, to address.Address, value, nonce, gasLimit, gasPrice, gasCap pack.U256, payload pack.Bytes) (Tx, error)
}
// The Client interface defines the functionality required to interact with a
// chain over RPC.
type Client interface {
// LatestBlock returns the block number of the latest block.
LatestBlock(context.Context) (pack.U64, error)
// AccountBalance returns the current balance of the given account.
AccountBalance(context.Context, address.Address) (pack.U256, error)
// AccountNonce is the current nonce of this account, which must be used to
// build a new transaction.
AccountNonce(context.Context, address.Address) (pack.U256, error)
// Tx returns the transaction uniquely identified by the given transaction
// hash. It also returns the number of confirmations for the transaction. If
// the transaction cannot be found before the context is done, or the
// transaction is invalid, then an error should be returned.
Tx(context.Context, pack.Bytes) (Tx, pack.U64, error)
// SubmitTx to the underlying chain. If the transaction cannot be found
// before the context is done, or the transaction is invalid, then an error
// should be returned.
SubmitTx(context.Context, Tx) error
}
================================================
FILE: api/address/address.go
================================================
// Package address defines the Address API. All chains must implement this API,
// so that addresses can be encoded/decoded.
package address
import "github.com/renproject/pack"
// An Address is a human-readable representation of a public identity. It can be
// the address of an external account, contract, or script.
type Address pack.String
// SizeHint returns the number of bytes required to represent the address in
// binary.
func (addr Address) SizeHint() int {
return pack.String(addr).SizeHint()
}
// Marshal the address to binary. You should not call this function directly,
// unless you are implementing marshalling for a container type.
func (addr Address) Marshal(buf []byte, rem int) ([]byte, int, error) {
return pack.String(addr).Marshal(buf, rem)
}
// Unmarshal the address from binary. You should not call this function
// directly, unless you are implementing unmarshalling for a container type.
func (addr *Address) Unmarshal(buf []byte, rem int) ([]byte, int, error) {
return (*pack.String)(addr).Unmarshal(buf, rem)
}
// RawAddress is an address that has been decoded into its binary form.
type RawAddress pack.Bytes
// SizeHint returns the number of bytes required to represent the address in
// binary.
func (addr RawAddress) SizeHint() int {
return pack.Bytes(addr).SizeHint()
}
// Marshal the address to binary. You should not call this function directly,
// unless you are implementing marshalling for a container type.
func (addr RawAddress) Marshal(buf []byte, rem int) ([]byte, int, error) {
return pack.Bytes(addr).Marshal(buf, rem)
}
// Unmarshal the address from binary. You should not call this function
// directly, unless you are implementing unmarshalling for a container type.
func (addr *RawAddress) Unmarshal(buf []byte, rem int) ([]byte, int, error) {
return (*pack.Bytes)(addr).Unmarshal(buf, rem)
}
// The Encoder interface is used to convert raw addresses into human-readable
// addresses.
type Encoder interface {
EncodeAddress(RawAddress) (Address, error)
}
// The Decoder interfaces is used to convert human-readable addresses into raw
// addresses.
type Decoder interface {
DecodeAddress(Address) (RawAddress, error)
}
// The EncodeDecoder interfaces combines encoding and decoding functionality
// into one interface.
type EncodeDecoder interface {
Encoder
Decoder
}
================================================
FILE: api/contract/contract.go
================================================
// Package contract defines the Contract API. All chains that have "smart
// contracts" should implement this API. UTXO-based chains that support
// scripting must not attempt to implementing scripting using this API.
package contract
import (
"context"
"github.com/renproject/multichain/api/address"
"github.com/renproject/pack"
)
// CallData is used to specify a function and its parameters when invoking
// business logic on a contract.
type CallData pack.Bytes
// SizeHint returns the number of bytes required to represent the calldata in
// binary.
func (data CallData) SizeHint() int {
return pack.Bytes(data).SizeHint()
}
// Marshal the address to binary. You should not call this function directly,
// unless you are implementing marshalling for a container type.
func (data CallData) Marshal(buf []byte, rem int) ([]byte, int, error) {
return pack.Bytes(data).Marshal(buf, rem)
}
// Unmarshal the address from binary. You should not call this function
// directly, unless you are implementing unmarshalling for a container type.
func (data *CallData) Unmarshal(buf []byte, rem int) ([]byte, int, error) {
return (*pack.Bytes)(data).Unmarshal(buf, rem)
}
// The Caller interface defines the functionality required to call readonly
// functions on a contract. Calling functions that mutate contract state should
// be done using the Account API.
type Caller interface {
// CallContract at the specified address, using the specified calldata as
// input (this encodes the function and its parameters). The function output
// is returned as raw uninterpreted bytes. It is up to the application to
// interpret these bytes in a meaningful way. If the call cannot be
// completed before the context is done, or the call is invalid, then an
// error should be returned.
CallContract(context.Context, address.Address, CallData) (pack.Bytes, error)
}
================================================
FILE: api/gas/gas.go
================================================
// Package gas defines the Gas API. All chains that support transactions (either
// account-based or utxo-based) should implement this API. This API is used to
// understand the current recommended gas costs required to get confirmations in
// a reasonable amount of time.
package gas
import (
"context"
"github.com/renproject/pack"
)
// The Estimator interface defines the functionality required to know the
// current recommended gas price per gas unit and gas cap per gas unit. Not all
// chains have the concept of a gas cap, in which case it should be set to be
// equal to the gas price.
type Estimator interface {
// EstimateGas base/price that should be used in order to get a transaction
// confirmed within a reasonable amount of time. The precise definition of
// "reasonable amount of time" varies from chain to chain, and so is left
// open to interpretation by the implementation.
// For example, in Bitcoin, the gas price (and gas cap) would be the
// recommended SATs-per-byte required to get a transaction into the next
// block.
// In Ethereum without EIP-1559, the gas price (and gas cap) would be the
// recommended GWEI-per-gas required to get a transaction into one of the
// next few blocks (because blocks happen a lot faster). In Ethereum with
// EIP1559, the gas price and gas cap would be back calculated given the gas
// cap and an estimate of the current gas base.
//
// The assumption is that the total gas cost will be gasLimit * gasPrice <
// gasLimit * gasCap. If chain nodes give back values based on different
// assumptions, then the values must be normalised as needed.
EstimateGas(context.Context) (gasPrice, gasCap pack.U256, err error)
}
================================================
FILE: api/utxo/utxo.go
================================================
// Package utxo defines the UTXO API. All chains that use a utxo-based model
// should implement this API. The UTXO API is used to send and confirm
// transactions between addresses.
package utxo
import (
"context"
"github.com/renproject/multichain/api/address"
"github.com/renproject/pack"
)
// An Outpoint identifies a specific output produced by a transaction.
type Outpoint struct {
Hash pack.Bytes `json:"hash"`
Index pack.U32 `json:"index"`
}
// An Output is produced by a transaction. It includes the conditions required
// to spend the output (called the pubkey script, based on Bitcoin).
type Output struct {
Outpoint `json:"outpoint"`
Value pack.U256 `json:"value"`
PubKeyScript pack.Bytes `json:"pubKeyScript"`
}
// An Input specifies an existing output, produced by a previous transaction, to
// be consumed by another transaction. It includes the script that meets the
// conditions specified by the consumed output (called the sig script, based on
// Bitcoin).
type Input struct {
Output `json:"output"`
SigScript pack.Bytes `json:"sigScript"`
}
// A Recipient specifies an address, and an amount, for which a transaction will
// produce an output. Depending on the output, the address can take on different
// formats (e.g. in Bitcoin, addresses can be P2PK, P2PKH, or P2SH).
type Recipient struct {
To address.Address `json:"to"`
Value pack.U256 `json:"value"`
}
// The Tx interfaces defines the functionality that must be exposed by
// utxo-based transactions.
type Tx interface {
// Hash returns the hash that uniquely identifies the transaction.
// Generally, hashes are irreversible hash functions that consume the
// content of the transaction.
Hash() (pack.Bytes, error)
// Inputs consumed by the transaction.
Inputs() ([]Input, error)
// Outputs produced by the transaction.
Outputs() ([]Output, error)
// Sighashes that must be signed before the transaction can be submitted by
// the client.
Sighashes() ([]pack.Bytes32, error)
// Sign the transaction by injecting signatures for the required sighashes.
// The serialized public key used to sign the sighashes should also be
// specified whenever it is available.
Sign([]pack.Bytes65, pack.Bytes) error
// Serialize the transaction into bytes. This is the format in which the
// transaction will be submitted by the client.
Serialize() (pack.Bytes, error)
}
// The TxBuilder interface defines the functionality required to build
// account-based transactions. Most chain implementations require additional
// information, and this should be accepted during the construction of the
// chain-specific transaction builder.
type TxBuilder interface {
BuildTx([]Input, []Recipient) (Tx, error)
}
// The Client interface defines the functionality required to interact with a
// chain over RPC.
type Client interface {
// LatestBlock returns the height of the longest blockchain.
LatestBlock(context.Context) (pack.U64, error)
// Output returns the transaction output identified by the given outpoint.
// It also returns the number of confirmations for the output. If the output
// cannot be found before the context is done, or the output is invalid,
// then an error should be returned. This method will not error, even if the
// output has been spent.
Output(context.Context, Outpoint) (Output, pack.U64, error)
// UnspentOutput returns the unspent transaction output identified by the
// given outpoint. It also returns the number of confirmations for the
// output. If the output cannot be found before the context is done, the
// output is invalid, or the output has been spent, then an error should be
// returned.
UnspentOutput(context.Context, Outpoint) (Output, pack.U64, error)
// SubmitTx to the underlying chain. If the transaction cannot be found
// before the context is done, or the transaction is invalid, then an error
// should be returned.
SubmitTx(context.Context, Tx) error
// TxSenders returns the senders' addresses of the transaction.
TxSenders(context.Context, pack.Bytes) ([]pack.String, error)
}
================================================
FILE: chain/arbitrum/address.go
================================================
package arbitrum
import (
"github.com/renproject/multichain/chain/evm"
)
type (
// AddressEncodeDecoder re-exports evm.AddressEncodeDecoder.
AddressEncodeDecoder = evm.AddressEncodeDecoder
// AddressEncoder re-exports evm.AddressEncoder.
AddressEncoder = evm.AddressEncoder
// AddressDecoder re-exports evm.AddressDecoder.
AddressDecoder = evm.AddressDecoder
// Address re-exports evm.Address.
Address = evm.Address
)
var (
// NewAddressEncodeDecoder re-exports evm.NewAddressEncodeDecoder.
NewAddressEncodeDecoder = evm.NewAddressEncodeDecoder
// NewAddressDecoder re-exports evm.NewAddressDecoder.
NewAddressDecoder = evm.NewAddressDecoder
// NewAddressEncoder re-exports evm.NewAddressEncoder.
NewAddressEncoder = evm.NewAddressEncoder
// NewAddressFromHex re-exports evm.NewAddressFromHex.
NewAddressFromHex = evm.NewAddressFromHex
)
================================================
FILE: chain/arbitrum/address_test.go
================================================
package arbitrum_test
import (
"encoding/hex"
"encoding/json"
"testing/quick"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/renproject/multichain/chain/arbitrum"
"github.com/renproject/surge"
)
var _ = Describe("Address", func() {
Context("when unmarshaling and unmarshaling", func() {
It("should equal itself", func() {
f := func(x [20]byte) bool {
addr := arbitrum.Address(x)
Expect(addr.SizeHint()).To(Equal(20))
bytes, err := surge.ToBinary(addr)
Expect(err).ToNot(HaveOccurred())
var newAddr arbitrum.Address
err = surge.FromBinary(&newAddr, bytes)
Expect(err).ToNot(HaveOccurred())
Expect(addr).To(Equal(newAddr))
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Context("when unmarshaling and unmarshaling to/from JSON", func() {
It("should equal itself", func() {
f := func(x [20]byte) bool {
addr := arbitrum.Address(x)
bytes, err := json.Marshal(addr)
Expect(err).ToNot(HaveOccurred())
var newAddr arbitrum.Address
err = json.Unmarshal(bytes, &newAddr)
Expect(err).ToNot(HaveOccurred())
Expect(addr).To(Equal(newAddr))
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
Context("when the address is invalid hex", func() {
It("should return an error", func() {
f := func(x [40]byte) bool {
bytes, err := json.Marshal(string(x[:]))
Expect(err).ToNot(HaveOccurred())
var newAddr arbitrum.Address
err = json.Unmarshal(bytes, &newAddr)
Expect(err).To(HaveOccurred())
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Context("when the address is invalid length", func() {
It("should return an error", func() {
f := func(x [10]byte) bool {
addr := hex.EncodeToString(x[:])
bytes, err := json.Marshal(addr)
Expect(err).ToNot(HaveOccurred())
var newAddr arbitrum.Address
err = json.Unmarshal(bytes, &newAddr)
Expect(err).To(HaveOccurred())
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
})
Context("when unmarshalling random data", func() {
It("should not panic", func() {
f := func(x []byte) bool {
var addr arbitrum.Address
Expect(func() { addr.Unmarshal(x, surge.MaxBytes) }).ToNot(Panic())
Expect(func() { json.Unmarshal(x, &addr) }).ToNot(Panic())
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
})
================================================
FILE: chain/arbitrum/client.go
================================================
package arbitrum
import (
"github.com/renproject/multichain/chain/evm"
)
const (
// DefaultClientRPCURL is the RPC URL used by default, to interact with the
// arbitrum node.
DefaultClientRPCURL = "http://127.0.0.1:8547"
)
// Client re-exports evm.Client.
type Client = evm.Client
// NewClient re-exports evm.NewClient.
var NewClient = evm.NewClient
================================================
FILE: chain/arbitrum/encode.go
================================================
package arbitrum
import (
"github.com/renproject/multichain/chain/evm"
)
// Payload re-exports evm.Payload.
type Payload = evm.Payload
// Encode re-exports evm.Encode.
var Encode = evm.Encode
================================================
FILE: chain/arbitrum/encode_test.go
================================================
package arbitrum_test
import (
"encoding/hex"
"fmt"
"math"
"testing/quick"
"github.com/renproject/multichain/chain/arbitrum"
"github.com/renproject/pack"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
)
var _ = Describe("Encoding", func() {
Context("when encoding bytes", func() {
It("should return the correct result", func() {
f := func(x []byte) bool {
arg := pack.NewBytes(x)
resBytes := arbitrum.Encode(arg)
resString := hex.EncodeToString(resBytes)
expectedBytes := make([]byte, int(math.Ceil(float64(len(x))/32)*32))
copy(expectedBytes, x)
// Note: since the first parameter has a dynamic length, the
// first 32 bytes instead contain a pointer to the data.
expectedString := fmt.Sprintf("%064x", 32) + fmt.Sprintf("%064x", len(x)) + hex.EncodeToString(expectedBytes)
Expect(resString).To(Equal(expectedString))
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Context("when encoding 32 bytes", func() {
It("should return the correct result", func() {
f := func(x [32]byte) bool {
arg := pack.NewBytes32(x)
resBytes := arbitrum.Encode(arg)
resString := hex.EncodeToString(resBytes)
expectedString := hex.EncodeToString(x[:])
Expect(resString).To(Equal(expectedString))
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Context("when encoding 8-bit unsigned integers", func() {
It("should return the correct result", func() {
f := func(x uint8) bool {
arg := pack.NewU8(x)
resBytes := arbitrum.Encode(arg)
resString := hex.EncodeToString(resBytes)
expectedString := fmt.Sprintf("%064x", x)
Expect(resString).To(Equal(expectedString))
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Context("when encoding 16-bit unsigned integers", func() {
It("should return the correct result", func() {
f := func(x uint16) bool {
arg := pack.NewU16(x)
resBytes := arbitrum.Encode(arg)
resString := hex.EncodeToString(resBytes)
expectedString := fmt.Sprintf("%064x", x)
Expect(resString).To(Equal(expectedString))
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Context("when encoding 32-bit unsigned integers", func() {
It("should return the correct result", func() {
f := func(x uint32) bool {
arg := pack.NewU32(x)
resBytes := arbitrum.Encode(arg)
resString := hex.EncodeToString(resBytes)
expectedString := fmt.Sprintf("%064x", x)
Expect(resString).To(Equal(expectedString))
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Context("when encoding 64-bit unsigned integers", func() {
It("should return the correct result", func() {
f := func(x uint64) bool {
arg := pack.NewU64(x)
resBytes := arbitrum.Encode(arg)
resString := hex.EncodeToString(resBytes)
expectedString := fmt.Sprintf("%064x", x)
Expect(resString).To(Equal(expectedString))
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Context("when encoding 128-bit unsigned integers", func() {
It("should return the correct result", func() {
f := func(x [16]byte) bool {
arg := pack.NewU128(x)
resBytes := arbitrum.Encode(arg)
resString := hex.EncodeToString(resBytes)
expectedString := fmt.Sprintf("%064x", x)
Expect(resString).To(Equal(expectedString))
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Context("when encoding 256-bit unsigned integers", func() {
It("should return the correct result", func() {
f := func(x [32]byte) bool {
arg := pack.NewU256(x)
resBytes := arbitrum.Encode(arg)
resString := hex.EncodeToString(resBytes)
expectedString := fmt.Sprintf("%064x", x)
Expect(resString).To(Equal(expectedString))
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Context("when encoding Ethereum addresses", func() {
It("should return the correct result", func() {
f := func(x [20]byte) bool {
arg := arbitrum.Address(x)
resBytes := arbitrum.Encode(arg)
resString := hex.EncodeToString(resBytes)
expectedBytes := make([]byte, 32)
copy(expectedBytes, x[:])
expectedString := hex.EncodeToString(expectedBytes)
Expect(resString).To(Equal(expectedString))
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Context("when encoding an unsupported type", func() {
It("should panic", func() {
f := func(x bool) bool {
arg := pack.NewBool(x)
Expect(func() { arbitrum.Encode(arg) }).To(Panic())
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
type testCase struct {
addr string
amount uint64
hash string
result string
}
testCases := []testCase{
{
addr: "797522Fb74d42bB9fbF6b76dEa24D01A538d5D66",
amount: 10000,
hash: "702826c3977ee72158db2ce1fb758075ee2799db65fb27b5d0952f860a8084ed",
result: "797522fb74d42bb9fbf6b76dea24d01a538d5d660000000000000000000000000000000000000000000000000000000000000000000000000000000000002710702826c3977ee72158db2ce1fb758075ee2799db65fb27b5d0952f860a8084ed",
},
{
addr: "58afb504ef2444a267b8c7ce57279417f1377ceb",
amount: 50000000000000000,
hash: "dabff9ceb1b3dabb696d143326fdb98a8c7deb260e65d08a294b16659d573f93",
result: "58afb504ef2444a267b8c7ce57279417f1377ceb00000000000000000000000000000000000000000000000000000000000000000000000000b1a2bc2ec50000dabff9ceb1b3dabb696d143326fdb98a8c7deb260e65d08a294b16659d573f93",
},
{
addr: "0000000000000000000000000000000000000000",
amount: 0,
hash: "0000000000000000000000000000000000000000000000000000000000000000",
result: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
},
}
DescribeTable("when encoding args",
func(test testCase) {
addrBytes, err := hex.DecodeString(test.addr)
Expect(err).ToNot(HaveOccurred())
var addr arbitrum.Address
copy(addr[:], addrBytes)
hashBytes32 := [32]byte{}
hashBytes, err := hex.DecodeString(test.hash)
Expect(err).ToNot(HaveOccurred())
copy(hashBytes32[:], hashBytes)
args := []interface{}{
addr,
pack.NewU64(test.amount),
pack.NewBytes32(hashBytes32),
}
result := arbitrum.Encode(args...)
Expect(hex.EncodeToString(result)).To(Equal(test.result))
},
Entry("should return the same result as solidity for small transactions", testCases[0]),
Entry("should return the same result as solidity for large transactions", testCases[1]),
Entry("should return the same result as solidity for empty transactions", testCases[2]),
)
})
================================================
FILE: chain/arbitrum/gas.go
================================================
package arbitrum
import (
"github.com/renproject/multichain/chain/evm"
)
// GasEstimator re-exports evm.GasEstimator.
type GasEstimator = evm.GasEstimator
// NewGasEstimator re-exports evm.NewGasEstimator.
var NewGasEstimator = evm.NewGasEstimator
================================================
FILE: chain/arbitrum/tx.go
================================================
package arbitrum
import (
"github.com/renproject/multichain/chain/evm"
)
type (
// TxBuilder re-exports evm.TxBuilder.
TxBuilder = evm.TxBuilder
// Tx re-exports evm.Tx.
Tx = evm.Tx
)
// NewTxBuilder re-exports evm.NewTxBuilder.
var NewTxBuilder = evm.NewTxBuilder
================================================
FILE: chain/avalanche/address.go
================================================
package avalanche
import (
"github.com/renproject/multichain/chain/evm"
)
type (
// AddressEncodeDecoder re-exports evm.AddressEncodeDecoder.
AddressEncodeDecoder = evm.AddressEncodeDecoder
// AddressEncoder re-exports evm.AddressEncoder.
AddressEncoder = evm.AddressEncoder
// AddressDecoder re-exports evm.AddressDecoder.
AddressDecoder = evm.AddressDecoder
// Address re-exports evm.Address.
Address = evm.Address
)
var (
// NewAddressEncodeDecoder re-exports evm.NewAddressEncodeDecoder.
NewAddressEncodeDecoder = evm.NewAddressEncodeDecoder
// NewAddressDecoder re-exports evm.NewAddressDecoder.
NewAddressDecoder = evm.NewAddressDecoder
// NewAddressEncoder re-exports evm.NewAddressEncoder.
NewAddressEncoder = evm.NewAddressEncoder
// NewAddressFromHex re-exports evm.NewAddressFromHex.
NewAddressFromHex = evm.NewAddressFromHex
)
================================================
FILE: chain/avalanche/address_test.go
================================================
package avalanche_test
import (
"encoding/hex"
"encoding/json"
"testing/quick"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/renproject/multichain/chain/avalanche"
"github.com/renproject/surge"
)
var _ = Describe("Address", func() {
Context("when unmarshaling and unmarshaling", func() {
It("should equal itself", func() {
f := func(x [20]byte) bool {
addr := avalanche.Address(x)
Expect(addr.SizeHint()).To(Equal(20))
bytes, err := surge.ToBinary(addr)
Expect(err).ToNot(HaveOccurred())
var newAddr avalanche.Address
err = surge.FromBinary(&newAddr, bytes)
Expect(err).ToNot(HaveOccurred())
Expect(addr).To(Equal(newAddr))
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Context("when unmarshaling and unmarshaling to/from JSON", func() {
It("should equal itself", func() {
f := func(x [20]byte) bool {
addr := avalanche.Address(x)
bytes, err := json.Marshal(addr)
Expect(err).ToNot(HaveOccurred())
var newAddr avalanche.Address
err = json.Unmarshal(bytes, &newAddr)
Expect(err).ToNot(HaveOccurred())
Expect(addr).To(Equal(newAddr))
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
Context("when the address is invalid hex", func() {
It("should return an error", func() {
f := func(x [40]byte) bool {
bytes, err := json.Marshal(string(x[:]))
Expect(err).ToNot(HaveOccurred())
var newAddr avalanche.Address
err = json.Unmarshal(bytes, &newAddr)
Expect(err).To(HaveOccurred())
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Context("when the address is invalid length", func() {
It("should return an error", func() {
f := func(x [10]byte) bool {
addr := hex.EncodeToString(x[:])
bytes, err := json.Marshal(addr)
Expect(err).ToNot(HaveOccurred())
var newAddr avalanche.Address
err = json.Unmarshal(bytes, &newAddr)
Expect(err).To(HaveOccurred())
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
})
Context("when unmarshalling random data", func() {
It("should not panic", func() {
f := func(x []byte) bool {
var addr avalanche.Address
Expect(func() { addr.Unmarshal(x, surge.MaxBytes) }).ToNot(Panic())
Expect(func() { json.Unmarshal(x, &addr) }).ToNot(Panic())
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
})
================================================
FILE: chain/avalanche/client.go
================================================
package avalanche
import (
"github.com/renproject/multichain/chain/evm"
)
const (
// DefaultClientRPCURL is the RPC URL used by default, to interact with the
// avalanche node.
DefaultClientRPCURL = "http://127.0.0.1:9650/ext/bc/C/rpc"
)
// Client re-exports evm.Client.
type Client = evm.Client
// NewClient re-exports evm.NewClient.
var NewClient = evm.NewClient
================================================
FILE: chain/avalanche/encode.go
================================================
package avalanche
import (
"github.com/renproject/multichain/chain/evm"
)
// Payload re-exports evm.Payload.
type Payload = evm.Payload
// Encode re-exports evm.Encode.
var Encode = evm.Encode
================================================
FILE: chain/avalanche/encode_test.go
================================================
package avalanche_test
import (
"encoding/hex"
"fmt"
"math"
"testing/quick"
"github.com/renproject/multichain/chain/avalanche"
"github.com/renproject/pack"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
)
var _ = Describe("Encoding", func() {
Context("when encoding bytes", func() {
It("should return the correct result", func() {
f := func(x []byte) bool {
arg := pack.NewBytes(x)
resBytes := avalanche.Encode(arg)
resString := hex.EncodeToString(resBytes)
expectedBytes := make([]byte, int(math.Ceil(float64(len(x))/32)*32))
copy(expectedBytes, x)
// Note: since the first parameter has a dynamic length, the
// first 32 bytes instead contain a pointer to the data.
expectedString := fmt.Sprintf("%064x", 32) + fmt.Sprintf("%064x", len(x)) + hex.EncodeToString(expectedBytes)
Expect(resString).To(Equal(expectedString))
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Context("when encoding 32 bytes", func() {
It("should return the correct result", func() {
f := func(x [32]byte) bool {
arg := pack.NewBytes32(x)
resBytes := avalanche.Encode(arg)
resString := hex.EncodeToString(resBytes)
expectedString := hex.EncodeToString(x[:])
Expect(resString).To(Equal(expectedString))
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Context("when encoding 8-bit unsigned integers", func() {
It("should return the correct result", func() {
f := func(x uint8) bool {
arg := pack.NewU8(x)
resBytes := avalanche.Encode(arg)
resString := hex.EncodeToString(resBytes)
expectedString := fmt.Sprintf("%064x", x)
Expect(resString).To(Equal(expectedString))
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Context("when encoding 16-bit unsigned integers", func() {
It("should return the correct result", func() {
f := func(x uint16) bool {
arg := pack.NewU16(x)
resBytes := avalanche.Encode(arg)
resString := hex.EncodeToString(resBytes)
expectedString := fmt.Sprintf("%064x", x)
Expect(resString).To(Equal(expectedString))
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Context("when encoding 32-bit unsigned integers", func() {
It("should return the correct result", func() {
f := func(x uint32) bool {
arg := pack.NewU32(x)
resBytes := avalanche.Encode(arg)
resString := hex.EncodeToString(resBytes)
expectedString := fmt.Sprintf("%064x", x)
Expect(resString).To(Equal(expectedString))
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Context("when encoding 64-bit unsigned integers", func() {
It("should return the correct result", func() {
f := func(x uint64) bool {
arg := pack.NewU64(x)
resBytes := avalanche.Encode(arg)
resString := hex.EncodeToString(resBytes)
expectedString := fmt.Sprintf("%064x", x)
Expect(resString).To(Equal(expectedString))
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Context("when encoding 128-bit unsigned integers", func() {
It("should return the correct result", func() {
f := func(x [16]byte) bool {
arg := pack.NewU128(x)
resBytes := avalanche.Encode(arg)
resString := hex.EncodeToString(resBytes)
expectedString := fmt.Sprintf("%064x", x)
Expect(resString).To(Equal(expectedString))
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Context("when encoding 256-bit unsigned integers", func() {
It("should return the correct result", func() {
f := func(x [32]byte) bool {
arg := pack.NewU256(x)
resBytes := avalanche.Encode(arg)
resString := hex.EncodeToString(resBytes)
expectedString := fmt.Sprintf("%064x", x)
Expect(resString).To(Equal(expectedString))
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Context("when encoding Ethereum addresses", func() {
It("should return the correct result", func() {
f := func(x [20]byte) bool {
arg := avalanche.Address(x)
resBytes := avalanche.Encode(arg)
resString := hex.EncodeToString(resBytes)
expectedBytes := make([]byte, 32)
copy(expectedBytes, x[:])
expectedString := hex.EncodeToString(expectedBytes)
Expect(resString).To(Equal(expectedString))
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
Context("when encoding an unsupported type", func() {
It("should panic", func() {
f := func(x bool) bool {
arg := pack.NewBool(x)
Expect(func() { avalanche.Encode(arg) }).To(Panic())
return true
}
err := quick.Check(f, nil)
Expect(err).ToNot(HaveOccurred())
})
})
type testCase struct {
addr string
amount uint64
hash string
result string
}
testCases := []testCase{
{
addr: "797522Fb74d42bB9fbF6b76dEa24D01A538d5D66",
amount: 10000,
hash: "702826c3977ee72158db2ce1fb758075ee2799db65fb27b5d0952f860a8084ed",
result: "797522fb74d42bb9fbf6b76dea24d01a538d5d660000000000000000000000000000000000000000000000000000000000000000000000000000000000002710702826c3977ee72158db2ce1fb758075ee2799db65fb27b5d0952f860a8084ed",
},
{
addr: "58afb504ef2444a267b8c7ce57279417f1377ceb",
amount: 50000000000000000,
hash: "dabff9ceb1b3dabb696d143326fdb98a8c7deb260e65d08a294b16659d573f93",
result: "58afb504ef2444a267b8c7ce57279417f1377ceb00000000000000000000000000000000000000000000000000000000000000000000000000b1a2bc2ec50000dabff9ceb1b3dabb696d143326fdb98a8c7deb260e65d08a294b16659d573f93",
},
{
addr: "0000000000000000000000000000000000000000",
amount: 0,
hash: "0000000000000000000000000000000000000000000000000000000000000000",
result: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
},
}
DescribeTable("when encoding args",
func(test testCase) {
addrBytes, err := hex.DecodeString(test.addr)
Expect(err).ToNot(HaveOccurred())
var addr avalanche.Address
copy(addr[:], addrBytes)
hashBytes32 := [32]byte{}
hashBytes, err := hex.DecodeString(test.hash)
Expect(err).ToNot(HaveOccurred())
copy(hashBytes32[:], hashBytes)
args := []interface{}{
addr,
pack.NewU64(test.amount),
pack.NewBytes32(hashBytes32),
}
result := avalanche.Encode(args...)
Expect(hex.EncodeToString(result)).To(Equal(test.result))
},
Entry("should return the same result as solidity for small transactions", testCases[0]),
Entry("should return the same result as solidity for large transactions", testCases[1]),
Entry("should return the same result as solidity for empty transactions", testCases[2]),
)
})
================================================
FILE: chain/avalanche/gas.go
================================================
package avalanche
import (
"github.com/renproject/multichain/chain/evm"
)
// GasEstimator re-exports evm.GasEstimator.
type GasEstimator = evm.GasEstimator
// NewGasEstimator re-exports evm.NewGasEstimator.
var NewGasEstimator = evm.NewGasEstimator
================================================
FILE: chain/avalanche/tx.go
================================================
package avalanche
import (
"github.com/renproject/multichain/chain/evm"
)
type (
// TxBuilder re-exports evm.TxBuilder.
TxBuilder = evm.TxBuilder
// Tx re-exports evm.Tx.
Tx = evm.Tx
)
// NewTxBuilder re-exports evm.NewTxBuilder.
var NewTxBuilder = evm.NewTxBuilder
================================================
FILE: chain/bitcoin/address.go
================================================
package bitcoin
import (
"fmt"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcutil/base58"
"github.com/renproject/multichain/api/address"
)
// AddressEncodeDecoder implements the address.EncodeDecoder interface
type AddressEncodeDecoder struct {
AddressEncoder
AddressDecoder
}
// NewAddressEncodeDecoder constructs a new AddressEncodeDecoder with the
// chain specific configurations
func NewAddressEncodeDecoder(params *chaincfg.Params) AddressEncodeDecoder {
return AddressEncodeDecoder{
AddressEncoder: NewAddressEncoder(params),
AddressDecoder: NewAddressDecoder(params),
}
}
// AddressEncoder encapsulates the chain specific configurations and implements
// the address.Encoder interface
type AddressEncoder struct {
params *chaincfg.Params
}
// NewAddressEncoder constructs a new AddressEncoder with the chain specific
// configurations
func NewAddressEncoder(params *chaincfg.Params) AddressEncoder {
return AddressEncoder{params: params}
}
// EncodeAddress implements the address.Encoder interface
func (encoder AddressEncoder) EncodeAddress(rawAddr address.RawAddress) (address.Address, error) {
switch len(rawAddr) {
case 25:
return encoder.encodeBase58(rawAddr)
case 21, 33:
return encoder.encodeBech32(rawAddr)
default:
return address.Address(""), fmt.Errorf("non-exhaustive pattern: address length %v", len(rawAddr))
}
}
func (encoder AddressEncoder) encodeBase58(rawAddr address.RawAddress) (address.Address, error) {
// Validate that the base58 address is in fact in correct format.
encodedAddr := base58.Encode([]byte(rawAddr))
if _, err := btcutil.DecodeAddress(encodedAddr, encoder.params); err != nil {
return address.Address(""), err
}
return address.Address(encodedAddr), nil
}
func (encoder AddressEncoder) encodeBech32(rawAddr address.RawAddress) (address.Address, error) {
switch len(rawAddr) {
case 21:
addr, err := btcutil.NewAddressWitnessPubKeyHash(rawAddr[1:], encoder.params)
if err != nil {
return address.Address(""), fmt.Errorf("new address witness pubkey hash: %v", err)
}
return address.Address(addr.EncodeAddress()), nil
case 33:
addr, err := btcutil.NewAddressWitnessScriptHash(rawAddr[1:], encoder.params)
if err != nil {
return address.Address(""), fmt.Errorf("new address witness script hash: %v", err)
}
return address.Address(addr.EncodeAddress()), nil
default:
return address.Address(""), fmt.Errorf("non-exhaustive pattern: bech32 address length %v", len(rawAddr))
}
}
// AddressDecoder encapsulates the chain specific configurations and implements
// the address.Decoder interface
type AddressDecoder struct {
params *chaincfg.Params
}
// NewAddressDecoder constructs a new AddressDecoder with the chain specific
// configurations
func NewAddressDecoder(params *chaincfg.Params) AddressDecoder {
return AddressDecoder{params: params}
}
// DecodeAddress implements the address.Decoder interface
func (decoder AddressDecoder) DecodeAddress(addr address.Address) (address.RawAddress, error) {
// The btcutil package assumes the address being decoded only contains
// valid ASCII characters between 0-255.
for _, c := range addr {
if c > 255 {
return nil, fmt.Errorf("invalid address: bad character %v", c)
}
}
decodedAddr, err := btcutil.DecodeAddress(string(addr), decoder.params)
if err != nil {
return nil, fmt.Errorf("decode address: %v", err)
}
if !decodedAddr.IsForNet(decoder.params) {
return nil, fmt.Errorf("address of different network")
}
switch a := decodedAddr.(type) {
case *btcutil.AddressPubKeyHash, *btcutil.AddressScriptHash:
return address.RawAddress(base58.Decode(string(addr))), nil
case *btcutil.AddressWitnessPubKeyHash:
rawAddr := append([]byte{a.WitnessVersion()}, a.WitnessProgram()...)
return address.RawAddress(rawAddr), nil
case *btcutil.AddressWitnessScriptHash:
rawAddr := append([]byte{a.WitnessVersion()}, a.WitnessProgram()...)
return address.RawAddress(rawAddr), nil
default:
return nil, fmt.Errorf("non-exhaustive pattern: address %T", a)
}
}
================================================
FILE: chain/bitcoin/address_test.go
================================================
package bitcoin_test
import (
"github.com/btcsuite/btcd/chaincfg"
"github.com/renproject/multichain/api/address"
"github.com/renproject/multichain/chain/bitcoin"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Bitcoin", func() {
Context("when decoding address with invalid characters", func() {
It("should not panic", func() {
decoder := bitcoin.NewAddressDecoder(&chaincfg.MainNetParams)
Expect(func() {
_, err := decoder.DecodeAddress(address.Address(rune(256)))
Expect(err).To(HaveOccurred())
}).ToNot(Panic())
})
})
})
================================================
FILE: chain/bitcoin/bitcoin.go
================================================
package bitcoin
import (
"bytes"
"context"
"encoding/hex"
"encoding/json"
"fmt"
"io"
"log"
"math/rand"
"net/http"
"time"
"github.com/btcsuite/btcd/btcjson"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcutil"
"github.com/renproject/multichain/api/address"
"github.com/renproject/multichain/api/utxo"
"github.com/renproject/pack"
)
const (
// DefaultClientTimeout used by the Client.
DefaultClientTimeout = time.Minute
// DefaultClientTimeoutRetry used by the Client.
DefaultClientTimeoutRetry = time.Second
// DefaultClientHost used by the Client. This should only be used for local
// deployments of the multichain.
DefaultClientHost = "http://0.0.0.0:18443"
// DefaultClientUser used by the Client. This is insecure, and should only
// be used for local — or publicly accessible — deployments of the
// multichain.
DefaultClientUser = "user"
// DefaultClientPassword used by the Client. This is insecure, and should
// only be used for local — or publicly accessible — deployments of the
// multichain.
DefaultClientPassword = "password"
)
// ClientOptions are used to parameterise the behaviour of the Client.
type ClientOptions struct {
Timeout time.Duration
TimeoutRetry time.Duration
Host string
User string
Password string
}
// DefaultClientOptions returns ClientOptions with the default settings. These
// settings are valid for use with the default local deployment of the
// multichain. In production, the host, user, and password should be changed.
func DefaultClientOptions() ClientOptions {
return ClientOptions{
Timeout: DefaultClientTimeout,
TimeoutRetry: DefaultClientTimeoutRetry,
Host: DefaultClientHost,
User: DefaultClientUser,
Password: DefaultClientPassword,
}
}
// WithHost sets the URL of the Bitcoin node.
func (opts ClientOptions) WithHost(host string) ClientOptions {
opts.Host = host
return opts
}
// WithUser sets the username that will be used to authenticate with the Bitcoin
// node.
func (opts ClientOptions) WithUser(user string) ClientOptions {
opts.User = user
return opts
}
// WithPassword sets the password that will be used to authenticate with the
// Bitcoin node.
func (opts ClientOptions) WithPassword(password string) ClientOptions {
opts.Password = password
return opts
}
// A Client interacts with an instance of the Bitcoin network using the RPC
// interface exposed by a Bitcoin node.
type Client interface {
utxo.Client
// UnspentOutputs spendable by the given address.
UnspentOutputs(ctx context.Context, minConf, maxConf int64, address address.Address) ([]utxo.Output, error)
// Confirmations of a transaction in the Bitcoin network.
Confirmations(ctx context.Context, txHash pack.Bytes) (int64, error)
// EstimateSmartFee
EstimateSmartFee(ctx context.Context, numBlocks int64) (float64, error)
// EstimateFeeLegacy
EstimateFeeLegacy(ctx context.Context, numBlocks int64) (float64, error)
}
type client struct {
opts ClientOptions
httpClient http.Client
}
// NewClient returns a new Client.
func NewClient(opts ClientOptions) Client {
httpClient := http.Client{}
httpClient.Timeout = opts.Timeout
return &client{
opts: opts,
httpClient: httpClient,
}
}
// LatestBlock returns the height of the longest blockchain.
func (client *client) LatestBlock(ctx context.Context) (pack.U64, error) {
var resp int64
if err := client.send(ctx, &resp, "getblockcount"); err != nil {
return pack.NewU64(0), fmt.Errorf("get block count: %v", err)
}
if resp < 0 {
return pack.NewU64(0), fmt.Errorf("unexpected block count, expected > 0, got: %v", resp)
}
return pack.NewU64(uint64(resp)), nil
}
// Output associated with an outpoint, and its number of confirmations.
func (client *client) Output(ctx context.Context, outpoint utxo.Outpoint) (utxo.Output, pack.U64, error) {
resp := btcjson.TxRawResult{}
hash := chainhash.Hash{}
copy(hash[:], outpoint.Hash)
if err := client.send(ctx, &resp, "getrawtransaction", hash.String(), 1); err != nil {
return utxo.Output{}, pack.NewU64(0), fmt.Errorf("bad \"getrawtransaction\": %v", err)
}
if outpoint.Index.Uint32() >= uint32(len(resp.Vout)) {
return utxo.Output{}, pack.NewU64(0), fmt.Errorf("bad index: %v is out of range", outpoint.Index)
}
vout := resp.Vout[outpoint.Index.Uint32()]
amount, err := btcutil.NewAmount(vout.Value)
if err != nil {
return utxo.Output{}, pack.NewU64(0), fmt.Errorf("bad amount: %v", err)
}
if amount < 0 {
return utxo.Output{}, pack.NewU64(0), fmt.Errorf("bad amount: %v", amount)
}
pubKeyScript, err := hex.DecodeString(vout.ScriptPubKey.Hex)
if err != nil {
return utxo.Output{}, pack.NewU64(0), fmt.Errorf("bad pubkey script: %v", err)
}
output := utxo.Output{
Outpoint: outpoint,
Value: pack.NewU256FromU64(pack.NewU64(uint64(amount))),
PubKeyScript: pack.NewBytes(pubKeyScript),
}
return output, pack.NewU64(resp.Confirmations), nil
}
// UnspentOutput returns the unspent transaction output identified by the
// given outpoint. It also returns the number of confirmations for the
// output. If the output cannot be found before the context is done, the
// output is invalid, or the output has been spent, then an error should be
// returned.
func (client *client) UnspentOutput(ctx context.Context, outpoint utxo.Outpoint) (utxo.Output, pack.U64, error) {
resp := btcjson.GetTxOutResult{}
hash := chainhash.Hash{}
copy(hash[:], outpoint.Hash)
if err := client.send(ctx, &resp, "gettxout", hash.String(), outpoint.Index.Uint32()); err != nil {
return utxo.Output{}, pack.NewU64(0), fmt.Errorf("bad \"gettxout\": %v", err)
}
amount, err := btcutil.NewAmount(resp.Value)
if err != nil {
return utxo.Output{}, pack.NewU64(0), fmt.Errorf("bad amount: %v", err)
}
if amount < 0 {
return utxo.Output{}, pack.NewU64(0), fmt.Errorf("bad amount: %v", amount)
}
if resp.Confirmations < 0 {
return utxo.Output{}, pack.NewU64(0), fmt.Errorf("bad confirmations: %v", resp.Confirmations)
}
pubKeyScript, err := hex.DecodeString(resp.ScriptPubKey.Hex)
if err != nil {
return utxo.Output{}, pack.NewU64(0), fmt.Errorf("bad pubkey script: %v", err)
}
output := utxo.Output{
Outpoint: outpoint,
Value: pack.NewU256FromU64(pack.NewU64(uint64(amount))),
PubKeyScript: pack.NewBytes(pubKeyScript),
}
return output, pack.NewU64(uint64(resp.Confirmations)), nil
}
// SubmitTx to the Bitcoin network.
func (client *client) SubmitTx(ctx context.Context, tx utxo.Tx) error {
serial, err := tx.Serialize()
if err != nil {
return fmt.Errorf("bad tx: %v", err)
}
resp := ""
if err := client.send(ctx, &resp, "sendrawtransaction", hex.EncodeToString(serial)); err != nil {
return fmt.Errorf("bad \"sendrawtransaction\": %v", err)
}
return nil
}
// TxSenders returns the senders of the transaction.
func (client *client) TxSenders(ctx context.Context, id pack.Bytes) ([]pack.String, error) {
resp, err := client.getRawTransaction(ctx, id)
if err != nil {
return nil, fmt.Errorf("bad \"getrawtransaction\": %v", err)
}
addrs := make([]pack.String, 0)
for _, vin := range resp.Vin {
txHash, err := chainhash.NewHashFromStr(vin.Txid)
if err != nil {
return nil, err
}
rawTx, err := client.getRawTransaction(ctx, txHash.CloneBytes())
if err != nil {
return nil, err
}
for _, addr := range rawTx.Vout[int(vin.Vout)].ScriptPubKey.Addresses {
addrs = append(addrs, pack.String(addr))
}
}
return addrs, nil
}
// UnspentOutputs spendable by the given address.
func (client *client) UnspentOutputs(ctx context.Context, minConf, maxConf int64, addr address.Address) ([]utxo.Output, error) {
resp := []btcjson.ListUnspentResult{}
if err := client.send(ctx, &resp, "listunspent", minConf, maxConf, []string{string(addr)}); err != nil && err != io.EOF {
return []utxo.Output{}, fmt.Errorf("bad \"listunspent\": %v", err)
}
outputs := make([]utxo.Output, len(resp))
for i := range outputs {
amount, err := btcutil.NewAmount(resp[i].Amount)
if err != nil {
return []utxo.Output{}, fmt.Errorf("bad amount: %v", err)
}
if amount < 0 {
return []utxo.Output{}, fmt.Errorf("bad amount: %v", amount)
}
pubKeyScript, err := hex.DecodeString(resp[i].ScriptPubKey)
if err != nil {
return []utxo.Output{}, fmt.Errorf("bad pubkey script: %v", err)
}
txid, err := chainhash.NewHashFromStr(resp[i].TxID)
if err != nil {
return []utxo.Output{}, fmt.Errorf("bad txid: %v", err)
}
outputs[i] = utxo.Output{
Outpoint: utxo.Outpoint{
Hash: pack.NewBytes(txid[:]),
Index: pack.NewU32(resp[i].Vout),
},
Value: pack.NewU256FromU64(pack.NewU64(uint64(amount))),
PubKeyScript: pack.NewBytes(pubKeyScript),
}
}
return outputs, nil
}
// Confirmations of a transaction in the Bitcoin network.
func (client *client) Confirmations(ctx context.Context, txHash pack.Bytes) (int64, error) {
resp := btcjson.GetTransactionResult{}
size := len(txHash)
txHashReversed := make([]byte, size)
copy(txHashReversed[:], txHash[:])
for i := 0; i < size/2; i++ {
txHashReversed[i], txHashReversed[size-1-i] = txHashReversed[size-1-i], txHashReversed[i]
}
if err := client.send(ctx, &resp, "gettransaction", hex.EncodeToString(txHashReversed)); err != nil {
return 0, fmt.Errorf("bad \"gettransaction\": %v", err)
}
confirmations := resp.Confirmations
if confirmations < 0 {
confirmations = 0
}
return confirmations, nil
}
// EstimateSmartFee fetches the estimated bitcoin network fees to be paid (in
// BTC per kilobyte) needed for a transaction to be confirmed within `numBlocks`
// blocks. An error will be returned if the bitcoin node hasn't observed enough
// blocks to make an estimate for the provided target `numBlocks`.
func (client *client) EstimateSmartFee(ctx context.Context, numBlocks int64) (float64, error) {
resp := btcjson.EstimateSmartFeeResult{}
if err := client.send(ctx, &resp, "estimatesmartfee", numBlocks); err != nil {
return 0.0, fmt.Errorf("estimating smart fee: %v", err)
}
if resp.Errors != nil && len(resp.Errors) > 0 {
return 0.0, fmt.Errorf("estimating smart fee: %v", resp.Errors[0])
}
return *resp.FeeRate, nil
}
func (client *client) EstimateFeeLegacy(ctx context.Context, numBlocks int64) (float64, error) {
var resp float64
switch numBlocks {
case int64(0):
if err := client.send(ctx, &resp, "estimatefee"); err != nil {
return 0.0, fmt.Errorf("estimating fee: %v", err)
}
default:
if err := client.send(ctx, &resp, "estimatefee", numBlocks); err != nil {
return 0.0, fmt.Errorf("estimating fee: %v", err)
}
}
return resp, nil
}
func (client *client) getRawTransaction(ctx context.Context, txhash pack.Bytes) (btcjson.TxRawResult, error) {
resp := btcjson.TxRawResult{}
hash := chainhash.Hash{}
copy(hash[:], txhash)
if err := client.send(ctx, &resp, "getrawtransaction", hash.String(), 1); err != nil {
return resp, fmt.Errorf("bad \"getrawtransaction\": %v", err)
}
return resp, nil
}
func (client *client) send(ctx context.Context, resp interface{}, method string, params ...interface{}) error {
// Encode the request.
data, err := encodeRequest(method, params)
if err != nil {
return err
}
return retry(ctx, client.opts.TimeoutRetry, func() error {
// Create request and add basic authentication headers. The context is
// not attached to the request, and instead we all each attempt to run
// for the timeout duration, and we keep attempting until success, or
// the context is done.
req, err := http.NewRequest("POST", client.opts.Host, bytes.NewBuffer(data))
if err != nil {
return fmt.Errorf("building http request: %v", err)
}
req.SetBasicAuth(client.opts.User, client.opts.Password)
// Send the request and decode the response.
res, err := client.httpClient.Do(req)
if err != nil {
return fmt.Errorf("sending http request: %v", err)
}
defer res.Body.Close()
if err := decodeResponse(resp, res.Body); err != nil {
return fmt.Errorf("decoding http response: %v", err)
}
return nil
})
}
func encodeRequest(method string, params []interface{}) ([]byte, error) {
rawParams, err := json.Marshal(params)
if err != nil {
return nil, fmt.Errorf("encoding params: %v", err)
}
req := struct {
Version string `json:"version"`
ID int `json:"id"`
Method string `json:"method"`
Params json.RawMessage `json:"params"`
}{
Version: "2.0",
ID: rand.Int(),
Method: method,
Params: rawParams,
}
rawReq, err := json.Marshal(req)
if err != nil {
return nil, fmt.Errorf("encoding request: %v", err)
}
return rawReq, nil
}
func decodeResponse(resp interface{}, r io.Reader) error {
res := struct {
Version string `json:"version"`
ID int `json:"id"`
Result *json.RawMessage `json:"result"`
Error *json.RawMessage `json:"error"`
}{}
if err := json.NewDecoder(r).Decode(&res); err != nil {
return fmt.Errorf("decoding response: %v", err)
}
if res.Error != nil {
return fmt.Errorf("decoding response: %v", string(*res.Error))
}
if res.Result == nil {
return fmt.Errorf("decoding result: result is nil")
}
if err := json.Unmarshal(*res.Result, resp); err != nil {
return fmt.Errorf("decoding result: %v", err)
}
return nil
}
func retry(ctx context.Context, dur time.Duration, f func() error) error {
ticker := time.NewTicker(dur)
err := f()
for err != nil {
log.Printf("retrying: %v", err)
select {
case <-ctx.Done():
return fmt.Errorf("%v: %v", ctx.Err(), err)
case <-ticker.C:
err = f()
}
}
return nil
}
================================================
FILE: chain/bitcoin/bitcoin_suite_test.go
================================================
package bitcoin_test
import (
"testing"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
func TestBitcoin(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Bitcoin Suite")
}
================================================
FILE: chain/bitcoin/bitcoin_test.go
================================================
package bitcoin_test
import (
"context"
"log"
"os"
"reflect"
"time"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcutil"
"github.com/renproject/id"
"github.com/renproject/multichain/api/address"
"github.com/renproject/multichain/api/utxo"
"github.com/renproject/multichain/chain/bitcoin"
"github.com/renproject/pack"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Bitcoin", func() {
Context("when submitting transactions", func() {
Context("when sending BTC to multiple addresses", func() {
It("should work", func() {
// Load private key, and assume that the associated address has
// funds to spend. You can do this by setting BITCOIN_PK to the
// value specified in the `./multichaindeploy/.env` file.
pkEnv := os.Getenv("BITCOIN_PK")
if pkEnv == "" {
panic("BITCOIN_PK is undefined")
}
wif, err := btcutil.DecodeWIF(pkEnv)
Expect(err).ToNot(HaveOccurred())
// PKH
pkhAddr, err := btcutil.NewAddressPubKeyHash(btcutil.Hash160(wif.PrivKey.PubKey().SerializeCompressed()), &chaincfg.RegressionNetParams)
Expect(err).ToNot(HaveOccurred())
pkhAddrUncompressed, err := btcutil.NewAddressPubKeyHash(btcutil.Hash160(wif.PrivKey.PubKey().SerializeUncompressed()), &chaincfg.RegressionNetParams)
Expect(err).ToNot(HaveOccurred())
log.Printf("PKH %v", pkhAddr.EncodeAddress())
log.Printf("PKH (uncompressed) %v", pkhAddrUncompressed.EncodeAddress())
// WPKH
wpkAddr, err := btcutil.NewAddressWitnessPubKeyHash([]byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19}, &chaincfg.RegressionNetParams)
Expect(err).ToNot(HaveOccurred())
log.Printf("WPKH %v", wpkAddr.EncodeAddress())
// Setup the client and load the unspent transaction outputs.
client := bitcoin.NewClient(bitcoin.DefaultClientOptions())
outputs, err := client.UnspentOutputs(context.Background(), 0, 999999999, address.Address(pkhAddr.EncodeAddress()))
Expect(err).ToNot(HaveOccurred())
Expect(len(outputs)).To(BeNumerically(">", 0))
output := outputs[0]
// Check that we can load the output and that it is equal.
// Otherwise, something strange is happening with the RPC
// client.
output2, _, err := client.Output(context.Background(), output.Outpoint)
Expect(err).ToNot(HaveOccurred())
Expect(reflect.DeepEqual(output, output2)).To(BeTrue())
output2, _, err = client.UnspentOutput(context.Background(), output.Outpoint)
Expect(err).ToNot(HaveOccurred())
Expect(reflect.DeepEqual(output, output2)).To(BeTrue())
// Build the transaction by consuming the outputs and spending
// them to a set of recipients.
inputs := []utxo.Input{
{Output: utxo.Output{
Outpoint: utxo.Outpoint{
Hash: output.Outpoint.Hash[:],
Index: output.Outpoint.Index,
},
PubKeyScript: output.PubKeyScript,
Value: output.Value,
}},
}
recipients := []utxo.Recipient{
{
To: address.Address(pkhAddr.EncodeAddress()),
Value: pack.NewU256FromU64(pack.NewU64((output.Value.Int().Uint64() - 1000) / 3)),
},
{
To: address.Address(pkhAddrUncompressed.EncodeAddress()),
Value: pack.NewU256FromU64(pack.NewU64((output.Value.Int().Uint64() - 1000) / 3)),
},
{
To: address.Address(wpkAddr.EncodeAddress()),
Value: pack.NewU256FromU64(pack.NewU64((output.Value.Int().Uint64() - 1000) / 3)),
},
}
tx, err := bitcoin.NewTxBuilder(&chaincfg.RegressionNetParams).BuildTx(inputs, recipients)
Expect(err).ToNot(HaveOccurred())
// Get the digests that need signing from the transaction, and
// sign them. In production, this would be done using the RZL
// MPC algorithm, but for the purposes of this test, using an
// explicit privkey is ok.
sighashes, err := tx.Sighashes()
signatures := make([]pack.Bytes65, len(sighashes))
Expect(err).ToNot(HaveOccurred())
for i := range sighashes {
hash := id.Hash(sighashes[i])
privKey := (*id.PrivKey)(wif.PrivKey)
signature, err := privKey.Sign(&hash)
Expect(err).ToNot(HaveOccurred())
signatures[i] = pack.NewBytes65(signature)
}
Expect(tx.Sign(signatures, pack.NewBytes(wif.SerializePubKey()))).To(Succeed())
// Submit the transaction to the Bitcoin node. Again, this
// should be running a la `./multichaindeploy`.
txHash, err := tx.Hash()
Expect(err).ToNot(HaveOccurred())
err = client.SubmitTx(context.Background(), tx)
Expect(err).ToNot(HaveOccurred())
log.Printf("TXID %v", txHash)
for {
// Loop until the transaction has at least a few
// confirmations. This implies that the transaction is
// definitely valid, and the test has passed. We were
// successfully able to use the multichain to construct and
// submit a Bitcoin transaction!
confs, err := client.Confirmations(context.Background(), txHash)
Expect(err).ToNot(HaveOccurred())
log.Printf(" %v/3 confirmations", confs)
if confs >= 1 {
break
}
time.Sleep(10 * time.Second)
}
ctxWithTimeout, cancelCtxWithTimeout := context.WithTimeout(context.Background(), time.Second)
defer cancelCtxWithTimeout()
_, _, err = client.UnspentOutput(ctxWithTimeout, output.Outpoint)
Expect(err).To(HaveOccurred())
// Check that we can load the output and that it is equal.
// Otherwise, something strange is happening with the RPC
// client.
output2, _, err = client.Output(context.Background(), output.Outpoint)
Expect(err).ToNot(HaveOccurred())
Expect(reflect.DeepEqual(output, output2)).To(BeTrue())
// Check we can get the transaction inputs
senders, err := client.TxSenders(context.Background(), txHash)
Expect(err).ToNot(HaveOccurred())
Expect(len(senders)).Should(Equal(1))
Expect(senders[0]).Should(Equal(pkhAddr.EncodeAddress()))
})
})
})
})
================================================
FILE: chain/bitcoin/gas.go
================================================
package bitcoin
import (
"context"
"fmt"
"math"
"github.com/renproject/pack"
)
const (
btcToSatoshis = 1e8
kilobyteToByte = 1024
)
// A GasEstimator returns the SATs-per-byte that is needed in order to confirm
// transactions with an estimated maximum delay of one block. In distributed
// networks that collectively build, sign, and submit transactions, it is
// important that all nodes in the network have reached consensus on the
// SATs-per-byte.
type GasEstimator struct {
client Client
numBlocks int64
fallbackGas pack.U256
}
// NewGasEstimator returns a simple gas estimator that always returns the given
// number of SATs-per-byte.
func NewGasEstimator(client Client, numBlocks int64, fallbackGas pack.U256) GasEstimator {
return GasEstimator{
client: client,
numBlocks: numBlocks,
fallbackGas: fallbackGas,
}
}
// EstimateGas returns the number of SATs-per-byte (for both price and cap) that
// is needed in order to confirm transactions with an estimated maximum delay of
// `numBlocks` block. It is the responsibility of the caller to know the number
// of bytes in their transaction. This method calls the `estimatesmartfee` RPC
// call to the node, which based on a conservative (considering longer history)
// strategy returns the estimated BTC per kilobyte of data in the transaction.
// An error will be returned if the bitcoin node hasn't observed enough blocks
// to make an estimate for the provided target `numBlocks`.
func (gasEstimator GasEstimator) EstimateGas(ctx context.Context) (pack.U256, pack.U256, error) {
feeRate, err := gasEstimator.client.EstimateSmartFee(ctx, gasEstimator.numBlocks)
if err != nil {
return gasEstimator.fallbackGas, gasEstimator.fallbackGas, err
}
if feeRate <= 0.0 {
return gasEstimator.fallbackGas, gasEstimator.fallbackGas, fmt.Errorf("invalid fee rate: %v", feeRate)
}
satsPerByte := uint64(math.Ceil(feeRate * btcToSatoshis / kilobyteToByte))
return pack.NewU256FromUint64(satsPerByte), pack.NewU256FromUint64(satsPerByte), nil
}
================================================
FILE: chain/bitcoin/gas_test.go
================================================
package bitcoin_test
import (
"context"
"github.com/renproject/multichain/chain/bitcoin"
"github.com/renproject/pack"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Gas", func() {
Context("when estimating bitcoin network fee", func() {
It("should work", func() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
client := bitcoin.NewClient(bitcoin.DefaultClientOptions())
// estimate fee to include tx within 1 block.
fallback1 := uint64(123)
gasEstimator1 := bitcoin.NewGasEstimator(client, 1, pack.NewU256FromUint64(fallback1))
gasPrice1, _, err := gasEstimator1.EstimateGas(ctx)
if err != nil {
Expect(gasPrice1).To(Equal(pack.NewU256FromUint64(fallback1)))
}
// estimate fee to include tx within 10 blocks.
fallback2 := uint64(234)
gasEstimator2 := bitcoin.NewGasEstimator(client, 10, pack.NewU256FromUint64(fallback2))
gasPrice2, _, err := gasEstimator2.EstimateGas(ctx)
if err != nil {
Expect(gasPrice2).To(Equal(pack.NewU256FromUint64(fallback2)))
}
// estimate fee to include tx within 100 blocks.
fallback3 := uint64(345)
gasEstimator3 := bitcoin.NewGasEstimator(client, 100, pack.NewU256FromUint64(fallback3))
gasPrice3, _, err := gasEstimator3.EstimateGas(ctx)
if err != nil {
Expect(gasPrice3).To(Equal(pack.NewU256FromUint64(fallback3)))
}
// expect fees in this order at the very least.
if err == nil {
Expect(gasPrice1.GreaterThanEqual(gasPrice2)).To(BeTrue())
Expect(gasPrice2.GreaterThanEqual(gasPrice3)).To(BeTrue())
}
})
})
})
================================================
FILE: chain/bitcoin/utxo.go
================================================
package bitcoin
import (
"bytes"
"fmt"
"math/big"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/renproject/multichain/api/utxo"
"github.com/renproject/pack"
)
// Version of Bitcoin transactions supported by the multichain.
const Version int32 = 2
// The TxBuilder is an implementation of a UTXO-compatible transaction builder
// for Bitcoin.
type TxBuilder struct {
params *chaincfg.Params
}
// NewTxBuilder returns a transaction builder that builds UTXO-compatible
// Bitcoin transactions for the given chain configuration (this means that it
// can be used for regnet, testnet, and mainnet, but also for networks that are
// minimally modified forks of the Bitcoin network).
func NewTxBuilder(params *chaincfg.Params) TxBuilder {
return TxBuilder{params: params}
}
// BuildTx returns a Bitcoin transaction that consumes funds from the given
// inputs, and sends them to the given recipients. The difference in the sum
// value of the inputs and the sum value of the recipients is paid as a fee to
// the Bitcoin network. This fee must be calculated independently of this
// function. Outputs produced for recipients will use P2PKH, P2SH, P2WPKH, or
// P2WSH scripts as the pubkey script, based on the format of the recipient
// address.
func (txBuilder TxBuilder) BuildTx(inputs []utxo.Input, recipients []utxo.Recipient) (utxo.Tx, error) {
msgTx := wire.NewMsgTx(Version)
// Inputs
for _, input := range inputs {
hash := chainhash.Hash{}
copy(hash[:], input.Hash)
index := input.Index.Uint32()
msgTx.AddTxIn(wire.NewTxIn(wire.NewOutPoint(&hash, index), nil, nil))
}
// Outputs
for _, recipient := range recipients {
addr, err := btcutil.DecodeAddress(string(recipient.To), txBuilder.params)
if err != nil {
return nil, err
}
if !addr.IsForNet(txBuilder.params) {
return nil, fmt.Errorf("addr of a different network")
}
script, err := txscript.PayToAddrScript(addr)
if err != nil {
return nil, err
}
value := recipient.Value.Int().Int64()
if value < 0 {
return nil, fmt.Errorf("expected value >= 0, got value %v", value)
}
msgTx.AddTxOut(wire.NewTxOut(value, script))
}
return &Tx{inputs: inputs, recipients: recipients, msgTx: msgTx, signed: false}, nil
}
// Tx represents a simple Bitcoin transaction that implements the Bitcoin Compat
// API.
type Tx struct {
inputs []utxo.Input
recipients []utxo.Recipient
msgTx *wire.MsgTx
signed bool
}
// Hash returns the transaction hash of the given underlying transaction.
func (tx *Tx) Hash() (pack.Bytes, error) {
txhash := tx.msgTx.TxHash()
return pack.NewBytes(txhash[:]), nil
}
// Inputs returns the UTXO inputs in the underlying transaction.
func (tx *Tx) Inputs() ([]utxo.Input, error) {
return tx.inputs, nil
}
// Outputs returns the UTXO outputs in the underlying transaction.
func (tx *Tx) Outputs() ([]utxo.Output, error) {
hash, err := tx.Hash()
if err != nil {
return nil, fmt.Errorf("bad hash: %v", err)
}
outputs := make([]utxo.Output, len(tx.msgTx.TxOut))
for i := range outputs {
outputs[i].Outpoint = utxo.Outpoint{
Hash: hash,
Index: pack.NewU32(uint32(i)),
}
outputs[i].PubKeyScript = pack.Bytes(tx.msgTx.TxOut[i].PkScript)
if tx.msgTx.TxOut[i].Value < 0 {
return nil, fmt.Errorf("bad output %v: value is less than zero", i)
}
outputs[i].Value = pack.NewU256FromU64(pack.NewU64(uint64(tx.msgTx.TxOut[i].Value)))
}
return outputs, nil
}
// Sighashes returns the digests that must be signed before the transaction
// can be submitted by the client.
func (tx *Tx) Sighashes() ([]pack.Bytes32, error) {
sighashes := make([]pack.Bytes32, len(tx.inputs))
for i, txin := range tx.inputs {
pubKeyScript := txin.PubKeyScript
sigScript := txin.SigScript
value := txin.Value.Int().Int64()
if value < 0 {
return []pack.Bytes32{}, fmt.Errorf("expected value >= 0, got value %v", value)
}
var hash []byte
var err error
if sigScript == nil {
if txscript.IsPayToWitnessPubKeyHash(pubKeyScript) {
hash, err = txscript.CalcWitnessSigHash(pubKeyScript, txscript.NewTxSigHashes(tx.msgTx), txscript.SigHashAll, tx.msgTx, i, value)
} else {
hash, err = txscript.CalcSignatureHash(pubKeyScript, txscript.SigHashAll, tx.msgTx, i)
}
} else {
if txscript.IsPayToWitnessScriptHash(pubKeyScript) {
hash, err = txscript.CalcWitnessSigHash(sigScript, txscript.NewTxSigHashes(tx.msgTx), txscript.SigHashAll, tx.msgTx, i, value)
} else {
hash, err = txscript.CalcSignatureHash(sigScript, txscript.SigHashAll, tx.msgTx, i)
}
}
if err != nil {
return []pack.Bytes32{}, err
}
sighash := [32]byte{}
copy(sighash[:], hash)
sighashes[i] = pack.NewBytes32(sighash)
}
return sighashes, nil
}
// Sign consumes a list of signatures, and adds them to the list of UTXOs in
// the underlying transactions.
func (tx *Tx) Sign(signatures []pack.Bytes65, pubKey pack.Bytes) error {
if tx.signed {
return fmt.Errorf("already signed")
}
if len(signatures) != len(tx.msgTx.TxIn) {
return fmt.Errorf("expected %v signatures, got %v signatures", len(tx.msgTx.TxIn), len(signatures))
}
for i, rsv := range signatures {
var err error
// Decode the signature and the pubkey script.
r := new(big.Int).SetBytes(rsv[:32])
s := new(big.Int).SetBytes(rsv[32:64])
signature := btcec.Signature{
R: r,
S: s,
}
pubKeyScript := tx.inputs[i].Output.PubKeyScript
sigScript := tx.inputs[i].SigScript
// Support segwit.
if sigScript == nil {
if txscript.IsPayToWitnessPubKeyHash(pubKeyScript) || txscript.IsPayToWitnessScriptHash(pubKeyScript) {
tx.msgTx.TxIn[i].Witness = wire.TxWitness([][]byte{append(signature.Serialize(), byte(txscript.SigHashAll)), pubKey})
continue
}
} else {
if txscript.IsPayToWitnessPubKeyHash(sigScript) || txscript.IsPayToWitnessScriptHash(sigScript) {
tx.msgTx.TxIn[i].Witness = wire.TxWitness([][]byte{append(signature.Serialize(), byte(txscript.SigHashAll)), pubKey, sigScript})
continue
}
}
// Support non-segwit
builder := txscript.NewScriptBuilder()
builder.AddData(append(signature.Serialize(), byte(txscript.SigHashAll)))
builder.AddData(pubKey)
if sigScript != nil {
builder.AddData(sigScript)
}
tx.msgTx.TxIn[i].SignatureScript, err = builder.Script()
if err != nil {
return err
}
}
tx.signed = true
return nil
}
// Serialize serializes the UTXO transaction to bytes
func (tx *Tx) Serialize() (pack.Bytes, error) {
buf := new(bytes.Buffer)
if err := tx.msgTx.Serialize(buf); err != nil {
return pack.Bytes{}, err
}
return pack.NewBytes(buf.Bytes()), nil
}
================================================
FILE: chain/bitcoin/utxo_test.go
================================================
package bitcoin_test
================================================
FILE: chain/bitcoincash/address.go
================================================
package bitcoincash
import (
"errors"
"fmt"
"strings"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcutil/base58"
"github.com/btcsuite/btcutil/bech32"
"github.com/renproject/multichain/api/address"
"github.com/renproject/pack"
"golang.org/x/crypto/ripemd160"
)
var (
// Alphabet used by Bitcoin Cash to encode addresses.
Alphabet = "qpzry9x8gf2tvdw0s3jn54khce6mua7l"
// AlphabetReverseLookup used by Bitcoin Cash to decode addresses.
AlphabetReverseLookup = func() map[rune]byte {
lookup := map[rune]byte{}
for i, char := range Alphabet {
lookup[char] = byte(i)
}
return lookup
}()
)
// AddressEncodeDecoder implements the address.EncodeDecoder interface
type AddressEncodeDecoder struct {
AddressEncoder
AddressDecoder
}
// NewAddressEncodeDecoder constructs a new AddressEncodeDecoder with the
// chain specific configurations
func NewAddressEncodeDecoder(params *chaincfg.Params) AddressEncodeDecoder {
return AddressEncodeDecoder{
AddressEncoder: NewAddressEncoder(params),
AddressDecoder: NewAddressDecoder(params),
}
}
// AddressEncoder encapsulates the chain specific configurations and implements
// the address.Encoder interface
type AddressEncoder struct {
params *chaincfg.Params
}
// NewAddressEncoder constructs a new AddressEncoder with the chain specific
// configurations
func NewAddressEncoder(params *chaincfg.Params) AddressEncoder {
return AddressEncoder{params: params}
}
// AddressDecoder encapsulates the chain specific configurations and implements
// the address.Decoder interface
type AddressDecoder struct {
params *chaincfg.Params
}
// NewAddressDecoder constructs a new AddressDecoder with the chain specific
// configurations
func NewAddressDecoder(params *chaincfg.Params) AddressDecoder {
return AddressDecoder{params: params}
}
// EncodeAddress implements the address.Encoder interface
func (encoder AddressEncoder) EncodeAddress(rawAddr address.RawAddress) (address.Address, error) {
rawAddrBytes := []byte(rawAddr)
var encodedAddr string
var err error
switch len(rawAddrBytes) - 1 {
case ripemd160.Size: // P2PKH or P2SH
switch rawAddrBytes[0] {
case 0: // P2PKH
encodedAddr, err = encodeAddress(0x00, rawAddrBytes[1:21], encoder.params)
case 8: // P2SH
encodedAddr, err = encodeAddress(8, rawAddrBytes[1:21], encoder.params)
default:
return address.Address(""), btcutil.ErrUnknownAddressType
}
default:
return encodeLegacyAddress(rawAddr, encoder.params)
}
if err != nil {
return address.Address(""), fmt.Errorf("encoding: %v", err)
}
return address.Address(encodedAddr), nil
}
// DecodeAddress implements the address.Decoder interface
func (decoder AddressDecoder) DecodeAddress(addr address.Address) (address.RawAddress, error) {
// Legacy address decoding
if legacyAddr, err := btcutil.DecodeAddress(string(addr), decoder.params); err == nil {
if !legacyAddr.IsForNet(decoder.params) {
return nil, fmt.Errorf("address of different network")
}
switch legacyAddr.(type) {
case *btcutil.AddressPubKeyHash, *btcutil.AddressScriptHash, *btcutil.AddressPubKey:
return decodeLegacyAddress(addr, decoder.params)
case *btcutil.AddressWitnessPubKeyHash, *btcutil.AddressWitnessScriptHash:
return nil, fmt.Errorf("unsuported segwit bitcoin address type %T", legacyAddr)
default:
return nil, fmt.Errorf("unsuported legacy bitcoin address type %T", legacyAddr)
}
}
if addrParts := strings.Split(string(addr), ":"); len(addrParts) != 1 {
addr = address.Address(addrParts[1])
}
decoded := DecodeString(string(addr))
if !VerifyChecksum(AddressPrefix(decoder.params), decoded) {
return nil, btcutil.ErrChecksumMismatch
}
addrBytes, err := bech32.ConvertBits(decoded[:len(decoded)-8], 5, 8, false)
if err != nil {
return nil, err
}
switch len(addrBytes) - 1 {
case ripemd160.Size: // P2PKH or P2SH
switch addrBytes[0] {
case 0, 8: // P2PKH or P2SH
return address.RawAddress(addrBytes), nil
default:
return nil, btcutil.ErrUnknownAddressType
}
default:
return nil, errors.New("decoded address is of unknown size")
}
}
func encodeLegacyAddress(rawAddr address.RawAddress, params *chaincfg.Params) (address.Address, error) {
// Validate that the base58 address is in fact in correct format.
encodedAddr := base58.Encode([]byte(rawAddr))
if _, err := btcutil.DecodeAddress(encodedAddr, params); err != nil {
return address.Address(""), fmt.Errorf("address validation error: %v", err)
}
return address.Address(encodedAddr), nil
}
func decodeLegacyAddress(addr address.Address, params *chaincfg.Params) (address.RawAddress, error) {
// Decode the checksummed base58 format address.
decoded, ver, err := base58.CheckDecode(string(addr))
if err != nil {
return nil, fmt.Errorf("checking: %v", err)
}
if len(decoded) != 20 {
return nil, fmt.Errorf("expected len 20, got len %v", len(decoded))
}
// Validate the address format.
switch ver {
case params.PubKeyHashAddrID, params.ScriptHashAddrID:
return address.RawAddress(pack.NewBytes(base58.Decode(string(addr)))), nil
default:
return nil, fmt.Errorf("unexpected address prefix")
}
}
// An Address represents a Bitcoin Cash address.
type Address interface {
btcutil.Address
BitcoinAddress() btcutil.Address
}
// AddressLegacy represents a legacy Bitcoin address.
type AddressLegacy struct {
btcutil.Address
}
// BitcoinAddress returns the address as if it was a Bitcoin address.
func (addr AddressLegacy) BitcoinAddress() btcutil.Address {
return addr.Address
}
// AddressPubKeyHash represents an address for P2PKH transactions for
// Bitcoin Cash that is compatible with the Bitcoin-compat API.
type AddressPubKeyHash struct {
*btcutil.AddressPubKeyHash
params *chaincfg.Params
}
// NewAddressPubKeyHash returns a new AddressPubKeyHash
// that is compatible with the Bitcoin-compat API.
func NewAddressPubKeyHash(pkh []byte, params *chaincfg.Params) (AddressPubKeyHash, error) {
addr, err := btcutil.NewAddressPubKeyHash(pkh, params)
return AddressPubKeyHash{AddressPubKeyHash: addr, params: params}, err
}
// NewAddressPubKey returns a new AddressPubKey
// that is compatible with the Bitcoin-compat API.
func NewAddressPubKey(pk []byte, params *chaincfg.Params) (AddressPubKeyHash, error) {
return NewAddressPubKeyHash(btcutil.Hash160(pk), params)
}
// String returns the string encoding of the transaction output
// destination.
//
// Please note that String differs subtly from EncodeAddress: String
// will return the value as a string without any conversion, while
// EncodeAddress may convert destination types (for example,
// converting pubkeys to P2PKH addresses) before encoding as a
// payment address string.
func (addr AddressPubKeyHash) String() string {
return addr.EncodeAddress()
}
// EncodeAddress returns the string encoding of the payment address
// associated with the Address value. See the comment on String
// for how this method differs from String.
func (addr AddressPubKeyHash) EncodeAddress() string {
hash := *addr.AddressPubKeyHash.Hash160()
encoded, err := encodeAddress(0x00, hash[:], addr.params)
if err != nil {
panic(fmt.Errorf("invalid address: %v", err))
}
return encoded
}
// ScriptAddress returns the raw bytes of the address to be used
// when inserting the address into a txout's script.
func (addr AddressPubKeyHash) ScriptAddress() []byte {
return addr.AddressPubKeyHash.ScriptAddress()
}
// IsForNet returns whether or not the address is associated with the passed
// bitcoin network.
func (addr AddressPubKeyHash) IsForNet(params *chaincfg.Params) bool {
return addr.AddressPubKeyHash.IsForNet(params)
}
// BitcoinAddress returns the address as if it was a Bitcoin address.
func (addr AddressPubKeyHash) BitcoinAddress() btcutil.Address {
return addr.AddressPubKeyHash
}
// AddressScriptHash represents an address for P2SH transactions for
// Bitcoin Cash that is compatible with the Bitcoin-compat API.
type AddressScriptHash struct {
*btcutil.AddressScriptHash
params *chaincfg.Params
}
// NewAddressScriptHash returns a new AddressScriptHash
// that is compatible with the Bitcoin-compat API.
func NewAddressScriptHash(script []byte, params *chaincfg.Params) (AddressScriptHash, error) {
addr, err := btcutil.NewAddressScriptHash(script, params)
return AddressScriptHash{AddressScriptHash: addr, params: params}, err
}
// NewAddressScriptHashFromHash returns a new AddressScriptHash
// that is compatible with the Bitcoin-compat API.
func NewAddressScriptHashFromHash(scriptHash []byte, params *chaincfg.Params) (AddressScriptHash, error) {
addr, err := btcutil.NewAddressScriptHashFromHash(scriptHash, params)
return AddressScriptHash{AddressScriptHash: addr, params: params}, err
}
// String returns the string encoding of the transaction output
// destination.
//
// Please note that String differs subtly from EncodeAddress: String
// will return the value as a string without any conversion, while
// EncodeAddress may convert destination types (for example,
// converting pubkeys to P2PKH addresses) before encoding as a
// payment address string.
func (addr AddressScriptHash) String() string {
return addr.EncodeAddress()
}
// EncodeAddress returns the string encoding of the payment address
// associated with the Address value. See the comment on String
// for how this method differs from String.
func (addr AddressScriptHash) EncodeAddress() string {
hash := *addr.AddressScriptHash.Hash160()
encoded, err := encodeAddress(8, hash[:], addr.params)
if err != nil {
panic(fmt.Errorf("invalid address: %v", err))
}
return encoded
}
// ScriptAddress returns the raw bytes of the address to be used
// when inserting the address into a txout's script.
func (addr AddressScriptHash) ScriptAddress() []byte {
return addr.AddressScriptHash.ScriptAddress()
}
// IsForNet returns whether or not the address is associated with the passed
// bitcoin network.
func (addr AddressScriptHash) IsForNet(params *chaincfg.Params) bool {
return addr.AddressScriptHash.IsForNet(params)
}
// BitcoinAddress returns the address as if it was a Bitcoin address.
func (addr AddressScriptHash) BitcoinAddress() btcutil.Address {
return addr.AddressScriptHash
}
// encodeAddress using Bitcoin Cash address encoding, assuming that the hash
// data has no prefix or checksum.
func encodeAddress(version byte, hash []byte, params *chaincfg.Params) (string, error) {
if (len(hash)-20)/4 != int(version)%8 {
return "", fmt.Errorf("invalid version: %d", version)
}
data, err := bech32.ConvertBits(append([]byte{version}, hash...), 8, 5, true)
if err != nil {
return "", fmt.Errorf("invalid bech32 encoding: %v", err)
}
return EncodeToString(AppendChecksum(AddressPrefix(params), data)), nil
}
// addressFromRawBytes consumes raw bytes representation of a bitcoincash
// address and returns a type that implements the bitcoincash.Address interface.
func addressFromRawBytes(addrBytes []byte, params *chaincfg.Params) (Address, error) {
switch len(addrBytes) - 1 {
case ripemd160.Size: // P2PKH or P2SH
switch addrBytes[0] {
case 0: // P2PKH
return NewAddressPubKeyHash(addrBytes[1:21], params)
case 8: // P2SH
return NewAddressScriptHashFromHash(addrBytes[1:21], params)
default:
return nil, btcutil.ErrUnknownAddressType
}
default:
addr, err := btcutil.DecodeAddress(base58.Encode(addrBytes), params)
if err != nil {
return nil, err
}
return AddressLegacy{Address: addr}, nil
}
}
// EncodeToString using Bitcoin Cash address encoding, assuming that the data
// has a prefix and checksum.
func EncodeToString(data []byte) string {
addr := strings.Builder{}
for _, d := range data {
addr.WriteByte(Alphabet[d])
}
return addr.String()
}
// DecodeString using Bitcoin Cash address encoding.
func DecodeString(address string) []byte {
data := []byte{}
for _, c := range address {
data = append(data, AlphabetReverseLookup[c])
}
return data
}
// AppendChecksum to the data payload.
//
// https://github.com/bitcoincashorg/bitcoincash.org/blob/master/spec/cashaddr.md#checksum
func AppendChecksum(prefix string, payload []byte) []byte {
prefixedPayload := append(EncodePrefix(prefix), payload...)
// Append 8 zeroes.
prefixedPayload = append(prefixedPayload, 0, 0, 0, 0, 0, 0, 0, 0)
// Determine what to XOR into those 8 zeroes.
mod := PolyMod(prefixedPayload)
checksum := make([]byte, 8)
for i := 0; i < 8; i++ {
// Convert the 5-bit groups in mod to checksum values.
checksum[i] = byte((mod >> uint(5*(7-i))) & 0x1f)
}
return append(payload, checksum...)
}
// VerifyChecksum verifies whether the given payload is well-formed.
//
// https://github.com/bitcoincashorg/bitcoincash.org/blob/master/spec/cashaddr.md#checksum
func VerifyChecksum(prefix string, payload []byte) bool {
return PolyMod(append(EncodePrefix(prefix), payload...)) == 0
}
// EncodePrefix string into bytes.
//
// https://github.com/bitcoincashorg/bitcoincash.org/blob/master/spec/cashaddr.md#checksum
func EncodePrefix(prefixString string) []byte {
prefixBytes := make([]byte, len(prefixString)+1)
for i := 0; i < len(prefixString); i++ {
prefixBytes[i] = byte(prefixString[i]) & 0x1f
}
prefixBytes[len(prefixString)] = 0
return prefixBytes
}
// AddressPrefix returns the string representations of an address prefix based
// on the network parameters: "bitcoincash" (for mainnet), "bchtest" (for
// testnet), and "bchreg" (for regtest). This function panics if the network
// parameters are not recognised.
func AddressPrefix(params *chaincfg.Params) string {
if params == nil {
panic(fmt.Errorf("non-exhaustive pattern: params %v", params))
}
switch params {
case &chaincfg.MainNetParams:
return "bitcoincash"
case &chaincfg.TestNet3Params:
return "bchtest"
case &chaincfg.RegressionNetParams:
return "bchreg"
default:
panic(fmt.Errorf("non-exhaustive pattern: params %v", params.Name))
}
}
// PolyMod is used to calculate the checksum for Bitcoin Cash
// addresses.
//
// uint64_t PolyMod(const data &v) {
// uint64_t c = 1;
// for (uint8_t d : v) {
// uint8_t c0 = c >> 35;
// c = ((c & 0x07ffffffff) << 5) ^ d;
// if (c0 & 0x01) c ^= 0x98f2bc8e61;
// if (c0 & 0x02) c ^= 0x79b76d99e2;
// if (c0 & 0x04) c ^= 0xf33e5fb3c4;
// if (c0 & 0x08) c ^= 0xae2eabe2a8;
// if (c0 & 0x10) c ^= 0x1e4f43e470;
// }
// return c ^ 1;
// }
//
// https://github.com/bitcoincashorg/bitcoincash.org/blob/master/spec/cashaddr.md
func PolyMod(v []byte) uint64 {
c := uint64(1)
for _, d := range v {
c0 := byte(c >> 35)
c = ((c & 0x07ffffffff) << 5) ^ uint64(d)
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
}
}
return c ^ 1
}
================================================
FILE: chain/bitcoincash/address_test.go
================================================
package bitcoincash_test
import (
"fmt"
"math/rand"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcutil"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/renproject/id"
"github.com/renproject/multichain/api/address"
"github.com/renproject/multichain/chain/bitcoincash"
)
var _ = Describe("Bitcoin Cash", func() {
Context("Address Encode/Decode", func() {
addrEncodeDecoders := []struct {
network *chaincfg.Params
encodeDecoder bitcoincash.AddressEncodeDecoder
}{
{
&chaincfg.MainNetParams,
bitcoincash.NewAddressEncodeDecoder(&chaincfg.MainNetParams),
},
{
&chaincfg.TestNet3Params,
bitcoincash.NewAddressEncodeDecoder(&chaincfg.TestNet3Params),
},
{
&chaincfg.RegressionNetParams,
bitcoincash.NewAddressEncodeDecoder(&chaincfg.RegressionNetParams),
},
}
for _, addrEncodeDecoder := range addrEncodeDecoders {
addrEncodeDecoder := addrEncodeDecoder
Context(fmt.Sprintf("Encode/Decode for %v network", addrEncodeDecoder.network.Name), func() {
Specify("AddressPubKeyHash", func() {
pk := id.NewPrivKey()
wif, err := btcutil.NewWIF((*btcec.PrivateKey)(pk), addrEncodeDecoder.network, true)
Expect(err).NotTo(HaveOccurred())
addrPubKeyHash, err := bitcoincash.NewAddressPubKeyHash(btcutil.Hash160(wif.PrivKey.PubKey().SerializeUncompressed()), addrEncodeDecoder.network)
Expect(err).NotTo(HaveOccurred())
addr := address.Address(addrPubKeyHash.EncodeAddress())
decodedRawAddr, err := addrEncodeDecoder.encodeDecoder.DecodeAddress(addr)
Expect(err).NotTo(HaveOccurred())
encodedAddr, err := addrEncodeDecoder.encodeDecoder.EncodeAddress(decodedRawAddr)
Expect(err).NotTo(HaveOccurred())
Expect(encodedAddr).To(Equal(addr))
})
Specify("AddressScriptHash", func() {
script := make([]byte, rand.Intn(100))
rand.Read(script)
addrScriptHash, err := bitcoincash.NewAddressScriptHash(script, addrEncodeDecoder.network)
Expect(err).NotTo(HaveOccurred())
addr := address.Address(addrScriptHash.EncodeAddress())
decodedRawAddr, err := addrEncodeDecoder.encodeDecoder.DecodeAddress(addr)
Expect(err).NotTo(HaveOccurred())
encodedAddr, err := addrEncodeDecoder.encodeDecoder.EncodeAddress(decodedRawAddr)
Expect(err).NotTo(HaveOccurred())
Expect(encodedAddr).To(Equal(addr))
})
Specify("AddressLegacy", func() {
pk := id.NewPrivKey()
wif, err := btcutil.NewWIF((*btcec.PrivateKey)(pk), addrEncodeDecoder.network, true)
Expect(err).NotTo(HaveOccurred())
addrPubKeyHash, err := btcutil.NewAddressPubKeyHash(btcutil.Hash160(wif.SerializePubKey()), addrEncodeDecoder.network)
Expect(err).NotTo(HaveOccurred())
addr := address.Address(addrPubKeyHash.EncodeAddress())
decodedRawAddr, err := addrEncodeDecoder.encodeDecoder.DecodeAddress(addr)
Expect(err).NotTo(HaveOccurred())
encodedAddr, err := addrEncodeDecoder.encodeDecoder.EncodeAddress(decodedRawAddr)
Expect(err).NotTo(HaveOccurred())
Expect(encodedAddr).To(Equal(addr))
})
})
}
})
})
================================================
FILE: chain/bitcoincash/bitcoincash.go
================================================
package bitcoincash
================================================
FILE: chain/bitcoincash/bitcoincash_suite_test.go
================================================
package bitcoincash_test
import (
"testing"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
func TestBitcoinCash(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Bitcoin Cash Suite")
}
================================================
FILE: chain/bitcoincash/bitcoincash_test.go
================================================
package bitcoincash_test
import (
"context"
"log"
"os"
"reflect"
"time"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcutil"
"github.com/renproject/id"
"github.com/renproject/multichain/api/address"
"github.com/renproject/multichain/api/utxo"
"github.com/renproject/multichain/chain/bitcoincash"
"github.com/renproject/pack"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Bitcoin Cash", func() {
Context("when submitting transactions", func() {
Context("when sending BCH to multiple addresses", func() {
It("should work", func() {
// Load private key, and assume that the associated address has
// funds to spend. You can do this by setting BITCOINCASH_PK to
// the value specified in the `./multichaindeploy/.env` file.
pkEnv := os.Getenv("BITCOINCASH_PK")
if pkEnv == "" {
panic("BITCOINCASH_PK is undefined")
}
wif, err := btcutil.DecodeWIF(pkEnv)
Expect(err).ToNot(HaveOccurred())
// PKH
pkhAddr, err := bitcoincash.NewAddressPubKeyHash(btcutil.Hash160(wif.PrivKey.PubKey().SerializeCompressed()), &chaincfg.RegressionNetParams)
Expect(err).ToNot(HaveOccurred())
pkhAddrUncompressed, err := bitcoincash.NewAddressPubKeyHash(btcutil.Hash160(wif.PrivKey.PubKey().SerializeUncompressed()), &chaincfg.RegressionNetParams)
Expect(err).ToNot(HaveOccurred())
log.Printf("PKH %v", pkhAddr.EncodeAddress())
log.Printf("PKH (uncompressed) %v", pkhAddrUncompressed.EncodeAddress())
// Setup the client and load the unspent transaction outputs.
client := bitcoincash.NewClient(bitcoincash.DefaultClientOptions())
outputs, err := client.UnspentOutputs(context.Background(), 0, 999999999, address.Address(pkhAddr.EncodeAddress()))
Expect(err).ToNot(HaveOccurred())
Expect(len(outputs)).To(BeNumerically(">", 0))
output := outputs[0]
// Check that we can load the output and that it is equal.
// Otherwise, something strange is happening with the RPC
// client.
output2, _, err := client.Output(context.Background(), output.Outpoint)
Expect(err).ToNot(HaveOccurred())
Expect(reflect.DeepEqual(output, output2)).To(BeTrue())
// Build the transaction by consuming the outputs and spending
// them to a set of recipients.
inputs := []utxo.Input{
{Output: output},
}
recipients := []utxo.Recipient{
{
To: address.Address(pkhAddr.EncodeAddress()),
Value: pack.NewU256FromU64(pack.NewU64((output.Value.Int().Uint64() - 1000) / 2)),
},
{
To: address.Address(pkhAddrUncompressed.EncodeAddress()),
Value: pack.NewU256FromU64(pack.NewU64((output.Value.Int().Uint64() - 1000) / 2)),
},
}
tx, err := bitcoincash.NewTxBuilder(&chaincfg.RegressionNetParams).BuildTx(inputs, recipients)
Expect(err).ToNot(HaveOccurred())
// Get the digests that need signing from the transaction, and
// sign them. In production, this would be done using the RZL
// MPC algorithm, but for the purposes of this test, using an
// explicit privkey is ok.
sighashes, err := tx.Sighashes()
signatures := make([]pack.Bytes65, len(sighashes))
Expect(err).ToNot(HaveOccurred())
for i := range sighashes {
hash := id.Hash(sighashes[i])
privKey := (*id.PrivKey)(wif.PrivKey)
signature, err := privKey.Sign(&hash)
Expect(err).ToNot(HaveOccurred())
signatures[i] = pack.NewBytes65(signature)
}
Expect(tx.Sign(signatures, pack.NewBytes(wif.SerializePubKey()))).To(Succeed())
// Submit the transaction to the Bitcoin Cash node. Again, this
// should be running a la `./multichaindeploy`.
txHash, err := tx.Hash()
Expect(err).ToNot(HaveOccurred())
err = client.SubmitTx(context.Background(), tx)
Expect(err).ToNot(HaveOccurred())
log.Printf("TXID %v", txHash)
for {
// Loop until the transaction has at least a few
// confirmations. This implies that the transaction is
// definitely valid, and the test has passed. We were
// successfully able to use the multichain to construct and
// submit a Bitcoin Cash transaction!
confs, err := client.Confirmations(context.Background(), txHash)
Expect(err).ToNot(HaveOccurred())
log.Printf(" %v/3 confirmations", confs)
if confs >= 3 {
break
}
time.Sleep(10 * time.Second)
}
// Check that we can load the output and that it is equal.
// Otherwise, something strange is happening with the RPC
// client.
output2, _, err = client.Output(context.Background(), output.Outpoint)
Expect(err).ToNot(HaveOccurred())
Expect(reflect.DeepEqual(output, output2)).To(BeTrue())
// Check we can get the transaction inputs
senders, err := client.TxSenders(context.Background(), txHash)
Expect(err).ToNot(HaveOccurred())
Expect(len(senders)).Should(Equal(1))
Expect(senders[0]).Should(Equal(pkhAddr.EncodeAddress()))
})
})
})
})
================================================
FILE: chain/bitcoincash/gas.go
================================================
package bitcoincash
import (
"context"
"fmt"
"math"
"github.com/renproject/pack"
)
const (
bchToSatoshis = 1e8
kilobyteToByte = 1024
)
// A GasEstimator returns the SATs-per-byte that is needed in order to confirm
// transactions with an estimated maximum delay of one block. In distributed
// networks that collectively build, sign, and submit transactions, it is
// important that all nodes in the network have reached consensus on the
// SATs-per-byte.
type GasEstimator struct {
client Client
fallbackGas pack.U256
}
// NewGasEstimator returns a simple gas estimator that always returns the given
// number of SATs-per-byte.
func NewGasEstimator(client Client, fallbackGas pack.U256) GasEstimator {
return GasEstimator{
client: client,
fallbackGas: fallbackGas,
}
}
// EstimateGas returns the number of SATs-per-byte (for both price and cap) that
// is needed in order to confirm transactions with a minimal delay. It is the
// responsibility of the caller to know the number of bytes in their
// transaction. This method calls the `estimatefee` RPC call to the node, which
// based on a conservative (considering longer history) strategy returns the
// estimated BCH per kilobyte of data in the transaction. An error will be
// returned if the node hasn't observed enough blocks to make an estimate.
func (gasEstimator GasEstimator) EstimateGas(ctx context.Context) (pack.U256, pack.U256, error) {
feeRate, err := gasEstimator.client.EstimateFeeLegacy(ctx, int64(0))
if err != nil {
return gasEstimator.fallbackGas, gasEstimator.fallbackGas, err
}
if feeRate <= 0.0 {
return gasEstimator.fallbackGas, gasEstimator.fallbackGas, fmt.Errorf("invalid fee rate: %v", feeRate)
}
satsPerByte := uint64(math.Ceil(feeRate * bchToSatoshis / kilobyteToByte))
return pack.NewU256FromUint64(satsPerByte), pack.NewU256FromUint64(satsPerByte), nil
}
================================================
FILE: chain/bitcoincash/gas_test.go
================================================
package bitcoincash_test
import (
"context"
"github.com/renproject/multichain/chain/bitcoincash"
"github.com/renproject/pack"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Gas", func() {
Context("when estimating bitcoincash network fee", func() {
It("should work", func() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
client := bitcoincash.NewClient(bitcoincash.DefaultClientOptions())
fallbackGas := uint64(123)
gasEstimator := bitcoincash.NewGasEstimator(client, pack.NewU256FromUint64(fallbackGas))
gasPrice, _, err := gasEstimator.EstimateGas(ctx)
if err != nil {
Expect(gasPrice).To(Equal(pack.NewU256FromUint64(fallbackGas)))
} else {
Expect(gasPrice.Int().Uint64()).To(BeNumerically(">", 0))
}
})
})
})
================================================
FILE: chain/bitcoincash/utxo.go
================================================
package bitcoincash
import (
"bytes"
"encoding/binary"
"fmt"
"math/big"
"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/renproject/multic
gitextract_3n3pcdpe/ ├── .github/ │ ├── CODEOWNERS │ └── workflows/ │ ├── build.yml │ └── test.yml ├── .gitignore ├── .gitmodules ├── Dockerfile ├── LICENSE ├── README.md ├── api/ │ ├── account/ │ │ └── account.go │ ├── address/ │ │ └── address.go │ ├── contract/ │ │ └── contract.go │ ├── gas/ │ │ └── gas.go │ └── utxo/ │ └── utxo.go ├── chain/ │ ├── arbitrum/ │ │ ├── address.go │ │ ├── address_test.go │ │ ├── client.go │ │ ├── encode.go │ │ ├── encode_test.go │ │ ├── gas.go │ │ └── tx.go │ ├── avalanche/ │ │ ├── address.go │ │ ├── address_test.go │ │ ├── client.go │ │ ├── encode.go │ │ ├── encode_test.go │ │ ├── gas.go │ │ └── tx.go │ ├── bitcoin/ │ │ ├── address.go │ │ ├── address_test.go │ │ ├── bitcoin.go │ │ ├── bitcoin_suite_test.go │ │ ├── bitcoin_test.go │ │ ├── gas.go │ │ ├── gas_test.go │ │ ├── utxo.go │ │ └── utxo_test.go │ ├── bitcoincash/ │ │ ├── address.go │ │ ├── address_test.go │ │ ├── bitcoincash.go │ │ ├── bitcoincash_suite_test.go │ │ ├── bitcoincash_test.go │ │ ├── gas.go │ │ ├── gas_test.go │ │ ├── utxo.go │ │ └── utxo_test.go │ ├── bsc/ │ │ ├── address.go │ │ ├── address_test.go │ │ ├── client.go │ │ ├── encode.go │ │ ├── encode_test.go │ │ ├── gas.go │ │ └── tx.go │ ├── cosmos/ │ │ ├── address.go │ │ ├── address_test.go │ │ ├── client.go │ │ ├── cosmos.go │ │ ├── cosmos_suite_test.go │ │ ├── cosmos_test.go │ │ ├── gas.go │ │ ├── gas_test.go │ │ └── tx.go │ ├── digibyte/ │ │ ├── address.go │ │ ├── address_test.go │ │ ├── digibyte.go │ │ ├── digibyte_suite_test.go │ │ ├── digibyte_test.go │ │ ├── gas.go │ │ ├── gas_test.go │ │ ├── utxo.go │ │ └── utxo_test.go │ ├── dogecoin/ │ │ ├── address.go │ │ ├── address_test.go │ │ ├── dogecoin.go │ │ ├── dogecoin_suite_test.go │ │ ├── dogecoin_test.go │ │ ├── gas.go │ │ ├── gas_test.go │ │ ├── utxo.go │ │ └── utxo_test.go │ ├── ethereum/ │ │ ├── address.go │ │ ├── address_test.go │ │ ├── client.go │ │ ├── encode.go │ │ ├── encode_test.go │ │ ├── gas.go │ │ └── tx.go │ ├── evm/ │ │ ├── address.go │ │ ├── address_test.go │ │ ├── client.go │ │ ├── encode.go │ │ ├── encode_test.go │ │ ├── gas.go │ │ └── tx.go │ ├── fantom/ │ │ ├── address.go │ │ ├── address_test.go │ │ ├── client.go │ │ ├── encode.go │ │ ├── encode_test.go │ │ ├── gas.go │ │ └── tx.go │ ├── filecoin/ │ │ ├── account.go │ │ ├── account_test.go │ │ ├── address.go │ │ ├── address_test.go │ │ ├── client.go │ │ ├── client_test.go │ │ ├── filecoin.go │ │ ├── filecoin_suite_test.go │ │ ├── filecoin_test.go │ │ ├── gas.go │ │ └── gas_test.go │ ├── kava/ │ │ ├── address.go │ │ ├── address_test.go │ │ ├── client.go │ │ ├── encode.go │ │ ├── encode_test.go │ │ ├── gas.go │ │ └── tx.go │ ├── moonbeam/ │ │ ├── address.go │ │ ├── address_test.go │ │ ├── client.go │ │ ├── encode.go │ │ ├── encode_test.go │ │ ├── gas.go │ │ └── tx.go │ ├── optimism/ │ │ ├── address.go │ │ ├── address_test.go │ │ ├── client.go │ │ ├── encode.go │ │ ├── encode_test.go │ │ ├── gas.go │ │ └── tx.go │ ├── polygon/ │ │ ├── address.go │ │ ├── address_test.go │ │ ├── client.go │ │ ├── encode.go │ │ ├── encode_test.go │ │ ├── gas.go │ │ └── tx.go │ ├── solana/ │ │ ├── address.go │ │ ├── rpc.go │ │ ├── solana.go │ │ ├── solana_ffi.go │ │ ├── solana_ffi_test.go │ │ ├── solana_suite_test.go │ │ ├── solana_test.go │ │ └── solanarpc.go │ ├── substrate/ │ │ ├── address.go │ │ └── address_test.go │ ├── terra/ │ │ ├── address.go │ │ ├── address_test.go │ │ ├── terra.go │ │ ├── terra_suite_test.go │ │ └── terra_test.go │ └── zcash/ │ ├── address.go │ ├── address_test.go │ ├── gas.go │ ├── gas_test.go │ ├── utxo.go │ ├── utxo_test.go │ ├── zcash.go │ ├── zcash_suite_test.go │ └── zcash_test.go ├── go.mod ├── go.sum ├── infra/ │ ├── acala/ │ │ ├── Dockerfile │ │ └── run.sh │ ├── avalanche/ │ │ ├── Dockerfile │ │ └── run.sh │ ├── binance/ │ │ ├── Dockerfile │ │ ├── Dockerfile-riolta │ │ └── run.sh │ ├── bitcoin/ │ │ ├── Dockerfile │ │ ├── bitcoin.conf │ │ ├── keygen.go │ │ └── run.sh │ ├── bitcoincash/ │ │ ├── Dockerfile │ │ ├── bitcoin.conf │ │ └── run.sh │ ├── digibyte/ │ │ ├── Dockerfile │ │ ├── README.md │ │ ├── keygen.go │ │ └── run.sh │ ├── docker-compose.yaml │ ├── dogecoin/ │ │ ├── Dockerfile │ │ ├── dogecoin.conf │ │ ├── keygen.go │ │ └── run.sh │ ├── ethereum/ │ │ ├── Dockerfile │ │ ├── hardhat.config.js │ │ ├── package.json │ │ └── run.sh │ ├── fantom/ │ │ └── Dockerfile │ ├── filecoin/ │ │ ├── Dockerfile │ │ ├── miner.key │ │ ├── run.sh │ │ └── user.key │ ├── goerli/ │ │ ├── Dockerfile │ │ ├── hardhat.config.js │ │ ├── package.json │ │ └── run.sh │ ├── polygon/ │ │ ├── Dockerfile │ │ ├── genesis.json │ │ ├── json-keystore │ │ ├── nodekey │ │ ├── password.txt │ │ ├── run.sh │ │ └── static-nodes.json │ ├── terra/ │ │ ├── Dockerfile │ │ └── run.sh │ └── zcash/ │ ├── Dockerfile │ ├── run.sh │ └── zcash.conf ├── multichain.go ├── multichain_suite_test.go ├── multichain_test.go └── test.sh
SYMBOL INDEX (550 symbols across 68 files)
FILE: api/account/account.go
type Tx (line 17) | type Tx interface
type TxBuilder (line 59) | type TxBuilder interface
type Client (line 65) | type Client interface
FILE: api/address/address.go
type Address (line 9) | type Address
method SizeHint (line 13) | func (addr Address) SizeHint() int {
method Marshal (line 19) | func (addr Address) Marshal(buf []byte, rem int) ([]byte, int, error) {
method Unmarshal (line 25) | func (addr *Address) Unmarshal(buf []byte, rem int) ([]byte, int, erro...
type RawAddress (line 30) | type RawAddress
method SizeHint (line 34) | func (addr RawAddress) SizeHint() int {
method Marshal (line 40) | func (addr RawAddress) Marshal(buf []byte, rem int) ([]byte, int, erro...
method Unmarshal (line 46) | func (addr *RawAddress) Unmarshal(buf []byte, rem int) ([]byte, int, e...
type Encoder (line 52) | type Encoder interface
type Decoder (line 58) | type Decoder interface
type EncodeDecoder (line 64) | type EncodeDecoder interface
FILE: api/contract/contract.go
type CallData (line 15) | type CallData
method SizeHint (line 19) | func (data CallData) SizeHint() int {
method Marshal (line 25) | func (data CallData) Marshal(buf []byte, rem int) ([]byte, int, error) {
method Unmarshal (line 31) | func (data *CallData) Unmarshal(buf []byte, rem int) ([]byte, int, err...
type Caller (line 38) | type Caller interface
FILE: api/gas/gas.go
type Estimator (line 17) | type Estimator interface
FILE: api/utxo/utxo.go
type Outpoint (line 14) | type Outpoint struct
type Output (line 21) | type Output struct
type Input (line 31) | type Input struct
type Recipient (line 39) | type Recipient struct
type Tx (line 46) | type Tx interface
type TxBuilder (line 76) | type TxBuilder interface
type Client (line 82) | type Client interface
FILE: chain/arbitrum/client.go
constant DefaultClientRPCURL (line 10) | DefaultClientRPCURL = "http://127.0.0.1:8547"
FILE: chain/avalanche/client.go
constant DefaultClientRPCURL (line 10) | DefaultClientRPCURL = "http://127.0.0.1:9650/ext/bc/C/rpc"
FILE: chain/bitcoin/address.go
type AddressEncodeDecoder (line 13) | type AddressEncodeDecoder struct
function NewAddressEncodeDecoder (line 20) | func NewAddressEncodeDecoder(params *chaincfg.Params) AddressEncodeDecod...
type AddressEncoder (line 29) | type AddressEncoder struct
method EncodeAddress (line 40) | func (encoder AddressEncoder) EncodeAddress(rawAddr address.RawAddress...
method encodeBase58 (line 51) | func (encoder AddressEncoder) encodeBase58(rawAddr address.RawAddress)...
method encodeBech32 (line 61) | func (encoder AddressEncoder) encodeBech32(rawAddr address.RawAddress)...
function NewAddressEncoder (line 35) | func NewAddressEncoder(params *chaincfg.Params) AddressEncoder {
type AddressDecoder (line 82) | type AddressDecoder struct
method DecodeAddress (line 93) | func (decoder AddressDecoder) DecodeAddress(addr address.Address) (add...
function NewAddressDecoder (line 88) | func NewAddressDecoder(params *chaincfg.Params) AddressDecoder {
FILE: chain/bitcoin/bitcoin.go
constant DefaultClientTimeout (line 25) | DefaultClientTimeout = time.Minute
constant DefaultClientTimeoutRetry (line 27) | DefaultClientTimeoutRetry = time.Second
constant DefaultClientHost (line 30) | DefaultClientHost = "http://0.0.0.0:18443"
constant DefaultClientUser (line 34) | DefaultClientUser = "user"
constant DefaultClientPassword (line 38) | DefaultClientPassword = "password"
type ClientOptions (line 42) | type ClientOptions struct
method WithHost (line 64) | func (opts ClientOptions) WithHost(host string) ClientOptions {
method WithUser (line 71) | func (opts ClientOptions) WithUser(user string) ClientOptions {
method WithPassword (line 78) | func (opts ClientOptions) WithPassword(password string) ClientOptions {
function DefaultClientOptions (line 53) | func DefaultClientOptions() ClientOptions {
type Client (line 85) | type Client interface
type client (line 97) | type client struct
method LatestBlock (line 113) | func (client *client) LatestBlock(ctx context.Context) (pack.U64, erro...
method Output (line 126) | func (client *client) Output(ctx context.Context, outpoint utxo.Outpoi...
method UnspentOutput (line 161) | func (client *client) UnspentOutput(ctx context.Context, outpoint utxo...
method SubmitTx (line 191) | func (client *client) SubmitTx(ctx context.Context, tx utxo.Tx) error {
method TxSenders (line 204) | func (client *client) TxSenders(ctx context.Context, id pack.Bytes) ([...
method UnspentOutputs (line 227) | func (client *client) UnspentOutputs(ctx context.Context, minConf, max...
method Confirmations (line 262) | func (client *client) Confirmations(ctx context.Context, txHash pack.B...
method EstimateSmartFee (line 286) | func (client *client) EstimateSmartFee(ctx context.Context, numBlocks ...
method EstimateFeeLegacy (line 300) | func (client *client) EstimateFeeLegacy(ctx context.Context, numBlocks...
method getRawTransaction (line 317) | func (client *client) getRawTransaction(ctx context.Context, txhash pa...
method send (line 327) | func (client *client) send(ctx context.Context, resp interface{}, meth...
function NewClient (line 103) | func NewClient(opts ClientOptions) Client {
function encodeRequest (line 358) | func encodeRequest(method string, params []interface{}) ([]byte, error) {
function decodeResponse (line 381) | func decodeResponse(resp interface{}, r io.Reader) error {
function retry (line 403) | func retry(ctx context.Context, dur time.Duration, f func() error) error {
FILE: chain/bitcoin/bitcoin_suite_test.go
function TestBitcoin (line 10) | func TestBitcoin(t *testing.T) {
FILE: chain/bitcoin/gas.go
constant btcToSatoshis (line 12) | btcToSatoshis = 1e8
constant kilobyteToByte (line 13) | kilobyteToByte = 1024
type GasEstimator (line 21) | type GasEstimator struct
method EstimateGas (line 45) | func (gasEstimator GasEstimator) EstimateGas(ctx context.Context) (pac...
function NewGasEstimator (line 29) | func NewGasEstimator(client Client, numBlocks int64, fallbackGas pack.U2...
FILE: chain/bitcoin/utxo.go
constant Version (line 19) | Version int32 = 2
type TxBuilder (line 23) | type TxBuilder struct
method BuildTx (line 42) | func (txBuilder TxBuilder) BuildTx(inputs []utxo.Input, recipients []u...
function NewTxBuilder (line 31) | func NewTxBuilder(params *chaincfg.Params) TxBuilder {
type Tx (line 78) | type Tx struct
method Hash (line 88) | func (tx *Tx) Hash() (pack.Bytes, error) {
method Inputs (line 94) | func (tx *Tx) Inputs() ([]utxo.Input, error) {
method Outputs (line 99) | func (tx *Tx) Outputs() ([]utxo.Output, error) {
method Sighashes (line 121) | func (tx *Tx) Sighashes() ([]pack.Bytes32, error) {
method Sign (line 161) | func (tx *Tx) Sign(signatures []pack.Bytes65, pubKey pack.Bytes) error {
method Serialize (line 213) | func (tx *Tx) Serialize() (pack.Bytes, error) {
FILE: chain/bitcoincash/address.go
type AddressEncodeDecoder (line 31) | type AddressEncodeDecoder struct
function NewAddressEncodeDecoder (line 38) | func NewAddressEncodeDecoder(params *chaincfg.Params) AddressEncodeDecod...
type AddressEncoder (line 47) | type AddressEncoder struct
method EncodeAddress (line 70) | func (encoder AddressEncoder) EncodeAddress(rawAddr address.RawAddress...
function NewAddressEncoder (line 53) | func NewAddressEncoder(params *chaincfg.Params) AddressEncoder {
type AddressDecoder (line 59) | type AddressDecoder struct
method DecodeAddress (line 97) | func (decoder AddressDecoder) DecodeAddress(addr address.Address) (add...
function NewAddressDecoder (line 65) | func NewAddressDecoder(params *chaincfg.Params) AddressDecoder {
function encodeLegacyAddress (line 140) | func encodeLegacyAddress(rawAddr address.RawAddress, params *chaincfg.Pa...
function decodeLegacyAddress (line 150) | func decodeLegacyAddress(addr address.Address, params *chaincfg.Params) ...
type Address (line 170) | type Address interface
type AddressLegacy (line 176) | type AddressLegacy struct
method BitcoinAddress (line 181) | func (addr AddressLegacy) BitcoinAddress() btcutil.Address {
type AddressPubKeyHash (line 187) | type AddressPubKeyHash struct
method String (line 213) | func (addr AddressPubKeyHash) String() string {
method EncodeAddress (line 220) | func (addr AddressPubKeyHash) EncodeAddress() string {
method ScriptAddress (line 231) | func (addr AddressPubKeyHash) ScriptAddress() []byte {
method IsForNet (line 237) | func (addr AddressPubKeyHash) IsForNet(params *chaincfg.Params) bool {
method BitcoinAddress (line 242) | func (addr AddressPubKeyHash) BitcoinAddress() btcutil.Address {
function NewAddressPubKeyHash (line 194) | func NewAddressPubKeyHash(pkh []byte, params *chaincfg.Params) (AddressP...
function NewAddressPubKey (line 201) | func NewAddressPubKey(pk []byte, params *chaincfg.Params) (AddressPubKey...
type AddressScriptHash (line 248) | type AddressScriptHash struct
method String (line 275) | func (addr AddressScriptHash) String() string {
method EncodeAddress (line 282) | func (addr AddressScriptHash) EncodeAddress() string {
method ScriptAddress (line 293) | func (addr AddressScriptHash) ScriptAddress() []byte {
method IsForNet (line 299) | func (addr AddressScriptHash) IsForNet(params *chaincfg.Params) bool {
method BitcoinAddress (line 304) | func (addr AddressScriptHash) BitcoinAddress() btcutil.Address {
function NewAddressScriptHash (line 255) | func NewAddressScriptHash(script []byte, params *chaincfg.Params) (Addre...
function NewAddressScriptHashFromHash (line 262) | func NewAddressScriptHashFromHash(scriptHash []byte, params *chaincfg.Pa...
function encodeAddress (line 310) | func encodeAddress(version byte, hash []byte, params *chaincfg.Params) (...
function addressFromRawBytes (line 323) | func addressFromRawBytes(addrBytes []byte, params *chaincfg.Params) (Add...
function EncodeToString (line 345) | func EncodeToString(data []byte) string {
function DecodeString (line 354) | func DecodeString(address string) []byte {
function AppendChecksum (line 365) | func AppendChecksum(prefix string, payload []byte) []byte {
function VerifyChecksum (line 385) | func VerifyChecksum(prefix string, payload []byte) bool {
function EncodePrefix (line 392) | func EncodePrefix(prefixString string) []byte {
function AddressPrefix (line 405) | func AddressPrefix(params *chaincfg.Params) string {
function PolyMod (line 439) | func PolyMod(v []byte) uint64 {
FILE: chain/bitcoincash/bitcoincash_suite_test.go
function TestBitcoinCash (line 10) | func TestBitcoinCash(t *testing.T) {
FILE: chain/bitcoincash/gas.go
constant bchToSatoshis (line 12) | bchToSatoshis = 1e8
constant kilobyteToByte (line 13) | kilobyteToByte = 1024
type GasEstimator (line 21) | type GasEstimator struct
method EstimateGas (line 42) | func (gasEstimator GasEstimator) EstimateGas(ctx context.Context) (pac...
function NewGasEstimator (line 28) | func NewGasEstimator(client Client, fallbackGas pack.U256) GasEstimator {
FILE: chain/bitcoincash/utxo.go
constant SighashForkID (line 21) | SighashForkID = txscript.SigHashType(0x40)
constant SighashMask (line 24) | SighashMask = txscript.SigHashType(0x1F)
constant Version (line 27) | Version int32 = 1
function DefaultClientOptions (line 35) | func DefaultClientOptions() ClientOptions {
type TxBuilder (line 48) | type TxBuilder struct
method BuildTx (line 73) | func (txBuilder TxBuilder) BuildTx(inputs []utxo.Input, recipients []u...
function NewTxBuilder (line 55) | func NewTxBuilder(params *chaincfg.Params) utxo.TxBuilder {
type Tx (line 113) | type Tx struct
method Hash (line 124) | func (tx *Tx) Hash() (pack.Bytes, error) {
method Inputs (line 131) | func (tx *Tx) Inputs() ([]utxo.Input, error) {
method Outputs (line 137) | func (tx *Tx) Outputs() ([]utxo.Output, error) {
method Sighashes (line 159) | func (tx *Tx) Sighashes() ([]pack.Bytes32, error) {
method Sign (line 186) | func (tx *Tx) Sign(signatures []pack.Bytes65, pubKey pack.Bytes) error {
method Serialize (line 220) | func (tx *Tx) Serialize() (pack.Bytes, error) {
function CalculateBip143Sighash (line 240) | func CalculateBip143Sighash(subScript []byte, sigHashes *txscript.TxSigH...
FILE: chain/bsc/client.go
constant DefaultClientRPCURL (line 10) | DefaultClientRPCURL = "http://127.0.0.1:8575/"
FILE: chain/cosmos/address.go
type Address (line 11) | type Address
method AccAddress (line 14) | func (addr Address) AccAddress() sdk.AccAddress {
method String (line 19) | func (addr Address) String() string {
type AddressEncodeDecoder (line 25) | type AddressEncodeDecoder struct
function NewAddressEncodeDecoder (line 31) | func NewAddressEncodeDecoder() AddressEncodeDecoder {
type AddressEncoder (line 39) | type AddressEncoder struct
method EncodeAddress (line 68) | func (encoder AddressEncoder) EncodeAddress(rawAddr address.RawAddress...
type AddressDecoder (line 43) | type AddressDecoder struct
method DecodeAddress (line 58) | func (decoder AddressDecoder) DecodeAddress(addr address.Address) (add...
function NewAddressDecoder (line 47) | func NewAddressDecoder() AddressDecoder {
function NewAddressEncoder (line 52) | func NewAddressEncoder() AddressEncoder {
FILE: chain/cosmos/client.go
constant DefaultClientTimeout (line 29) | DefaultClientTimeout = time.Minute
constant DefaultClientTimeoutRetry (line 31) | DefaultClientTimeoutRetry = time.Second
constant DefaultClientHost (line 34) | DefaultClientHost = pack.String("http://0.0.0.0:26657")
constant DefaultBroadcastMode (line 40) | DefaultBroadcastMode = pack.String("sync")
constant DefaultCoinDenom (line 42) | DefaultCoinDenom = pack.String("uluna")
type ClientOptions (line 46) | type ClientOptions struct
method WithTimeout (line 70) | func (opts ClientOptions) WithTimeout(timeout time.Duration) ClientOpt...
method WithTimeoutRetry (line 76) | func (opts ClientOptions) WithTimeoutRetry(timeoutRetry time.Duration)...
method WithHost (line 82) | func (opts ClientOptions) WithHost(host pack.String) ClientOptions {
method WithBroadcastMode (line 89) | func (opts ClientOptions) WithBroadcastMode(broadcastMode pack.String)...
method WithCoinDenom (line 95) | func (opts ClientOptions) WithCoinDenom(coinDenom pack.String) ClientO...
method WithChainID (line 101) | func (opts ClientOptions) WithChainID(chainid pack.String) ClientOptio...
function DefaultClientOptions (line 58) | func DefaultClientOptions() ClientOptions {
type Client (line 108) | type Client struct
method LatestBlock (line 140) | func (client *Client) LatestBlock(ctx context.Context) (pack.U64, erro...
method Tx (line 153) | func (client *Client) Tx(ctx context.Context, txHash pack.Bytes) (acco...
method SubmitTx (line 167) | func (client *Client) SubmitTx(ctx context.Context, tx account.Tx) err...
method AccountNonce (line 187) | func (client *Client) AccountNonce(ctx context.Context, addr address.A...
method AccountNumber (line 202) | func (client *Client) AccountNumber(ctx context.Context, addr address....
method AccountBalance (line 216) | func (client *Client) AccountBalance(ctx context.Context, addr address...
function NewClient (line 115) | func NewClient(opts ClientOptions, cdc codec.Codec, txConfig cosmClient....
type transport (line 236) | type transport struct
method RoundTrip (line 250) | func (t *transport) RoundTrip(req *http.Request) (*http.Response, erro...
function newTransport (line 243) | func newTransport(remote string, proxy http.RoundTripper) *transport {
FILE: chain/cosmos/cosmos_suite_test.go
function TestCosmos (line 10) | func TestCosmos(t *testing.T) {
FILE: chain/cosmos/gas.go
type GasEstimator (line 15) | type GasEstimator struct
method EstimateGas (line 30) | func (gasEstimator *GasEstimator) EstimateGas(ctx context.Context) (pa...
function NewGasEstimator (line 21) | func NewGasEstimator(gasPerByte pack.U256) gas.Estimator {
FILE: chain/cosmos/tx.go
constant DefaultChainID (line 30) | DefaultChainID = pack.String("testnet")
constant DefaultSignMode (line 32) | DefaultSignMode = 1
constant DefaultDecimalsDivisor (line 40) | DefaultDecimalsDivisor = 1
type TxBuilderOptions (line 44) | type TxBuilderOptions struct
method WithChainID (line 58) | func (opts TxBuilderOptions) WithChainID(chainID pack.String) TxBuilde...
method WithDecimalsDivisor (line 63) | func (opts TxBuilderOptions) WithDecimalsDivisor(decimalDivisor pack.U...
function DefaultTxBuilderOptions (line 50) | func DefaultTxBuilderOptions() TxBuilderOptions {
type txBuilder (line 68) | type txBuilder struct
method WithSignMode (line 88) | func (builder txBuilder) WithSignMode(signMode int32) txBuilder {
method BuildTx (line 96) | func (builder txBuilder) BuildTx(ctx context.Context, fromPubKey *id.P...
function NewTxBuilder (line 78) | func NewTxBuilder(options TxBuilderOptions, client *Client) account.TxBu...
type Coin (line 183) | type Coin struct
type Coins (line 189) | type Coins
method Coins (line 192) | func (coins Coins) Coins() types.Coins {
type MsgSend (line 206) | type MsgSend struct
method Msg (line 213) | func (msg MsgSend) Msg() types.Msg {
type Tx (line 222) | type Tx struct
method From (line 237) | func (t Tx) From() address.Address {
method To (line 250) | func (t Tx) To() address.Address {
method Value (line 264) | func (t Tx) Value() pack.U256 {
method Nonce (line 281) | func (t Tx) Nonce() pack.U256 {
method Payload (line 294) | func (t Tx) Payload() contract.CallData {
method Hash (line 306) | func (t Tx) Hash() pack.Bytes {
method Sighashes (line 316) | func (t Tx) Sighashes() ([]pack.Bytes32, error) {
method Sign (line 322) | func (t *Tx) Sign(signatures []pack.Bytes65, pubKey pack.Bytes) error {
method Serialize (line 338) | func (t Tx) Serialize() (pack.Bytes, error) {
function signatureFromBytes (line 353) | func signatureFromBytes(sigStr []byte) *btcec.Signature {
function serializeSig (line 362) | func serializeSig(sig *btcec.Signature) []byte {
FILE: chain/digibyte/digibyte.go
function init (line 12) | func init() {
constant DeploymentTestDummy (line 31) | DeploymentTestDummy = iota
constant DeploymentCSV (line 34) | DeploymentCSV
constant DeploymentSegwit (line 37) | DeploymentSegwit
constant DefinedDeployments (line 40) | DefinedDeployments
function newHashFromStr (line 111) | func newHashFromStr(hexStr string) *chainhash.Hash {
FILE: chain/digibyte/digibyte_suite_test.go
function TestDigiByte (line 10) | func TestDigiByte(t *testing.T) {
FILE: chain/digibyte/utxo.go
function DefaultClientOptions (line 33) | func DefaultClientOptions() ClientOptions {
FILE: chain/dogecoin/dogecoin.go
function init (line 7) | func init() {
FILE: chain/dogecoin/dogecoin_suite_test.go
function TestDogecoin (line 10) | func TestDogecoin(t *testing.T) {
FILE: chain/dogecoin/utxo.go
function DefaultClientOptions (line 30) | func DefaultClientOptions() ClientOptions {
FILE: chain/ethereum/client.go
constant DefaultClientRPCURL (line 10) | DefaultClientRPCURL = "http://127.0.0.1:8545/"
FILE: chain/ethereum/gas.go
constant FeeHistoryBlocks (line 14) | FeeHistoryBlocks = 10
constant FeeHistoryPercentile (line 16) | FeeHistoryPercentile = 5
constant FallbackMaxFeePerGas (line 18) | FallbackMaxFeePerGas = 20000000000
type GasOptions (line 33) | type GasOptions struct
type GasEstimator (line 44) | type GasEstimator struct
method EstimateGas (line 79) | func (gasEstimator *GasEstimator) EstimateGas(ctx context.Context) (pa...
method estimatePriorityFee (line 122) | func (gasEstimator *GasEstimator) estimatePriorityFee(ctx context.Cont...
function NewGasEstimator (line 52) | func NewGasEstimator(client *Client, opts GasOptions) *GasEstimator {
function NewDefaultGasEstimator (line 62) | func NewDefaultGasEstimator(client *Client) *GasEstimator {
FILE: chain/ethereum/tx.go
type TxBuilder (line 20) | type TxBuilder struct
method BuildTx (line 30) | func (txBuilder TxBuilder) BuildTx(ctx context.Context, fromPubKey *id...
function NewTxBuilder (line 25) | func NewTxBuilder(chainID *big.Int) TxBuilder {
FILE: chain/evm/address.go
type AddressEncodeDecoder (line 16) | type AddressEncodeDecoder struct
type AddressEncoder (line 22) | type AddressEncoder interface
type addressEncoder (line 26) | type addressEncoder struct
method EncodeAddress (line 61) | func (addressEncoder) EncodeAddress(rawAddr address.RawAddress) (addre...
function NewAddressEncodeDecoder (line 29) | func NewAddressEncodeDecoder() address.EncodeDecoder {
type AddressDecoder (line 37) | type AddressDecoder interface
type addressDecoder (line 41) | type addressDecoder struct
method DecodeAddress (line 53) | func (addressDecoder) DecodeAddress(encoded address.Address) (address....
function NewAddressDecoder (line 44) | func NewAddressDecoder() AddressDecoder {
function NewAddressEncoder (line 49) | func NewAddressEncoder() AddressEncoder {
type Address (line 68) | type Address
method SizeHint (line 90) | func (Address) SizeHint() int {
method Marshal (line 95) | func (addr Address) Marshal(buf []byte, rem int) ([]byte, int, error) {
method Unmarshal (line 104) | func (addr *Address) Unmarshal(buf []byte, rem int) ([]byte, int, erro...
method MarshalJSON (line 114) | func (addr Address) MarshalJSON() ([]byte, error) {
method UnmarshalJSON (line 120) | func (addr *Address) UnmarshalJSON(data []byte) error {
method String (line 134) | func (addr Address) String() string {
method Bytes (line 139) | func (addr Address) Bytes() pack.Bytes {
function NewAddressFromHex (line 72) | func NewAddressFromHex(str string) (Address, error) {
FILE: chain/evm/client.go
constant DefaultClientRPCURL (line 21) | DefaultClientRPCURL = "http://127.0.0.1:8545/"
type Client (line 25) | type Client struct
method LatestBlock (line 47) | func (client *Client) LatestBlock(ctx context.Context) (pack.U64, erro...
method Tx (line 57) | func (client *Client) Tx(ctx context.Context, txID pack.Bytes) (accoun...
method SubmitTx (line 116) | func (client *Client) SubmitTx(ctx context.Context, tx account.Tx) err...
method AccountNonce (line 131) | func (client *Client) AccountNonce(ctx context.Context, addr address.A...
method AccountBalance (line 145) | func (client *Client) AccountBalance(ctx context.Context, addr address...
method CallContract (line 159) | func (client *Client) CallContract(ctx context.Context, program addres...
function NewClient (line 31) | func NewClient(rpcURL string, chainID *big.Int) (*Client, error) {
FILE: chain/evm/encode.go
type Payload (line 14) | type Payload struct
function Encode (line 21) | func Encode(vals ...interface{}) []byte {
FILE: chain/evm/gas.go
type GasEstimator (line 12) | type GasEstimator struct
method EstimateGas (line 28) | func (gasEstimator *GasEstimator) EstimateGas(ctx context.Context) (pa...
function NewGasEstimator (line 19) | func NewGasEstimator(client *Client) *GasEstimator {
FILE: chain/evm/tx.go
type TxBuilder (line 20) | type TxBuilder struct
method BuildTx (line 30) | func (txBuilder TxBuilder) BuildTx(ctx context.Context, fromPubKey *id...
function NewTxBuilder (line 25) | func NewTxBuilder(chainID *big.Int) TxBuilder {
type Tx (line 49) | type Tx struct
method Hash (line 57) | func (tx Tx) Hash() pack.Bytes {
method From (line 63) | func (tx Tx) From() address.Address {
method To (line 74) | func (tx Tx) To() address.Address {
method Value (line 79) | func (tx Tx) Value() pack.U256 {
method Nonce (line 85) | func (tx Tx) Nonce() pack.U256 {
method Payload (line 92) | func (tx Tx) Payload() contract.CallData {
method Sighashes (line 98) | func (tx Tx) Sighashes() ([]pack.Bytes32, error) {
method Sign (line 105) | func (tx *Tx) Sign(signatures []pack.Bytes65, pubkey pack.Bytes) error {
method Serialize (line 116) | func (tx Tx) Serialize() (pack.Bytes, error) {
FILE: chain/fantom/client.go
constant DefaultClientRPCURL (line 10) | DefaultClientRPCURL = "http://127.0.0.1:18545/"
FILE: chain/filecoin/account.go
type TxBuilder (line 26) | type TxBuilder struct
method BuildTx (line 35) | func (txBuilder TxBuilder) BuildTx(ctx context.Context, fromPubKey *id...
function NewTxBuilder (line 30) | func NewTxBuilder() TxBuilder {
type Tx (line 65) | type Tx struct
method Hash (line 73) | func (tx Tx) Hash() pack.Bytes {
method From (line 92) | func (tx Tx) From() address.Address {
method To (line 99) | func (tx Tx) To() address.Address {
method Value (line 104) | func (tx Tx) Value() pack.U256 {
method Nonce (line 110) | func (tx Tx) Nonce() pack.U256 {
method Payload (line 117) | func (tx Tx) Payload() contract.CallData {
method Sighashes (line 123) | func (tx Tx) Sighashes() ([]pack.Bytes32, error) {
method Sign (line 130) | func (tx *Tx) Sign(signatures []pack.Bytes65, pubkey pack.Bytes) error {
method Serialize (line 140) | func (tx Tx) Serialize() (pack.Bytes, error) {
FILE: chain/filecoin/address.go
type AddressEncodeDecoder (line 11) | type AddressEncodeDecoder struct
type AddressEncoder (line 17) | type AddressEncoder struct
method EncodeAddress (line 32) | func (encoder AddressEncoder) EncodeAddress(raw address.RawAddress) (a...
type AddressDecoder (line 20) | type AddressDecoder struct
method DecodeAddress (line 45) | func (addrDecoder AddressDecoder) DecodeAddress(addr address.Address) ...
function NewAddressEncodeDecoder (line 23) | func NewAddressEncodeDecoder() AddressEncodeDecoder {
FILE: chain/filecoin/client.go
constant AuthorizationKey (line 23) | AuthorizationKey = "Authorization"
constant DefaultClientRPCURL (line 27) | DefaultClientRPCURL = "http://127.0.0.1:1234/rpc/v0"
constant DefaultClientAuthToken (line 32) | DefaultClientAuthToken = ""
type ClientOptions (line 36) | type ClientOptions struct
method WithRPCURL (line 54) | func (opts ClientOptions) WithRPCURL(rpcURL pack.String) ClientOptions {
method WithAuthToken (line 61) | func (opts ClientOptions) WithAuthToken(authToken pack.String) ClientO...
function DefaultClientOptions (line 45) | func DefaultClientOptions() ClientOptions {
type Client (line 68) | type Client struct
method LatestBlock (line 90) | func (client *Client) LatestBlock(ctx context.Context) (pack.U64, erro...
method Tx (line 104) | func (client *Client) Tx(ctx context.Context, txID pack.Bytes) (accoun...
method SubmitTx (line 151) | func (client *Client) SubmitTx(ctx context.Context, tx account.Tx) err...
method AccountNonce (line 179) | func (client *Client) AccountNonce(ctx context.Context, addr address.A...
method AccountBalance (line 194) | func (client *Client) AccountBalance(ctx context.Context, addr address...
function NewClient (line 75) | func NewClient(opts ClientOptions) (*Client, error) {
FILE: chain/filecoin/filecoin_suite_test.go
function TestFilecoin (line 10) | func TestFilecoin(t *testing.T) {
FILE: chain/filecoin/gas.go
type GasEstimator (line 19) | type GasEstimator struct
method EstimateGas (line 37) | func (gasEstimator *GasEstimator) EstimateGas(ctx context.Context) (pa...
function NewGasEstimator (line 27) | func NewGasEstimator(client *Client, gasLimit int64) *GasEstimator {
FILE: chain/filecoin/gas_test.go
function fetchAuthToken (line 41) | func fetchAuthToken() pack.String {
FILE: chain/kava/client.go
constant DefaultClientRPCURL (line 10) | DefaultClientRPCURL = "http://127.0.0.1:8575/"
FILE: chain/moonbeam/client.go
constant DefaultClientRPCURL (line 10) | DefaultClientRPCURL = "http://127.0.0.1:8575/"
FILE: chain/optimism/client.go
constant DefaultClientRPCURL (line 10) | DefaultClientRPCURL = "http://127.0.0.1:8575/"
FILE: chain/polygon/client.go
constant DefaultClientRPCURL (line 10) | DefaultClientRPCURL = "http://127.0.0.1:28545/"
FILE: chain/solana/address.go
type AddressDecoder (line 11) | type AddressDecoder struct
method DecodeAddress (line 41) | func (AddressDecoder) DecodeAddress(encoded address.Address) (address....
type AddressEncoder (line 14) | type AddressEncoder struct
method EncodeAddress (line 32) | func (AddressEncoder) EncodeAddress(rawAddress address.RawAddress) (ad...
type AddressEncodeDecoder (line 17) | type AddressEncodeDecoder struct
function NewAddressEncodeDecoder (line 23) | func NewAddressEncodeDecoder() AddressEncodeDecoder {
FILE: chain/solana/rpc.go
type Request (line 16) | type Request struct
type Response (line 26) | type Response struct
type Error (line 35) | type Error struct
function SendData (line 42) | func SendData(method string, data []byte, url string) (Response, error) {
function SendDataWithRetry (line 68) | func SendDataWithRetry(method string, data []byte, url string) (Response...
function SendRequest (line 94) | func SendRequest(request Request, url string) (*http.Response, error) {
function SendRawPost (line 108) | func SendRawPost(data []byte, url string) (*http.Response, error) {
function SendRequestWithRetry (line 123) | func SendRequestWithRetry(request Request, url string, timeoutInSecs int...
function newClient (line 141) | func newClient(timeout time.Duration) *http.Client {
FILE: chain/solana/solana.go
constant DefaultClientRPCURL (line 17) | DefaultClientRPCURL = "http://localhost:8899"
type ClientOptions (line 20) | type ClientOptions struct
method WithRPCURL (line 40) | func (opts ClientOptions) WithRPCURL(rpcURL pack.String) ClientOptions {
function DefaultClientOptions (line 27) | func DefaultClientOptions() ClientOptions {
type Client (line 46) | type Client struct
method GetAccountData (line 69) | func (client *Client) GetAccountData(account address.Address) (pack.By...
method CallContract (line 99) | func (client *Client) CallContract(
function NewClient (line 52) | func NewClient(opts ClientOptions) *Client {
function FindProgramAddress (line 58) | func FindProgramAddress(seeds []byte, program address.RawAddress) (addre...
FILE: chain/solana/solana_ffi.go
function UniquePubkey (line 11) | func UniquePubkey() address.Address {
function ProgramDerivedAddress (line 21) | func ProgramDerivedAddress(seeds pack.Bytes, program address.Address) ad...
FILE: chain/solana/solana_suite_test.go
function TestSolana (line 10) | func TestSolana(t *testing.T) {
FILE: chain/solana/solana_test.go
type GatewayRegistry (line 27) | type GatewayRegistry struct
FILE: chain/solana/solanarpc.go
type AccountContext (line 5) | type AccountContext struct
type AccountValue (line 10) | type AccountValue struct
type ResponseGetAccountInfo (line 20) | type ResponseGetAccountInfo struct
FILE: chain/substrate/address.go
type Address (line 12) | type Address
type AddressDecoder (line 16) | type AddressDecoder interface
type addressDecoder (line 20) | type addressDecoder struct
method DecodeAddress (line 32) | func (addressDecoder) DecodeAddress(encoded pack.String) (pack.Bytes, ...
function NewAddressDecoder (line 25) | func NewAddressDecoder() AddressDecoder {
FILE: chain/terra/terra.go
constant DefaultTerraDecimalsDivisor (line 17) | DefaultTerraDecimalsDivisor = 1e5
function init (line 45) | func init() {
function NewClient (line 55) | func NewClient(opts ClientOptions) *Client {
function NewTxBuilder (line 63) | func NewTxBuilder(opts TxBuilderOptions, client *Client) account.TxBuild...
type GasEstimator (line 67) | type GasEstimator struct
method EstimateGas (line 83) | func (gasEstimator GasEstimator) EstimateGas(ctx context.Context) (pac...
function NewHttpGasEstimator (line 74) | func NewHttpGasEstimator(url, key string, decimals int, fallbackGas pack...
FILE: chain/terra/terra_suite_test.go
function TestTerra (line 10) | func TestTerra(t *testing.T) {
FILE: chain/zcash/address.go
type AddressEncodeDecoder (line 17) | type AddressEncodeDecoder struct
type AddressEncoder (line 24) | type AddressEncoder struct
method EncodeAddress (line 56) | func (encoder AddressEncoder) EncodeAddress(rawAddr address.RawAddress...
type AddressDecoder (line 30) | type AddressDecoder struct
method DecodeAddress (line 88) | func (decoder AddressDecoder) DecodeAddress(addr address.Address) (add...
function NewAddressEncoder (line 36) | func NewAddressEncoder(params *Params) AddressEncoder {
function NewAddressDecoder (line 42) | func NewAddressDecoder(params *Params) AddressDecoder {
function NewAddressEncodeDecoder (line 48) | func NewAddressEncodeDecoder(params *Params) AddressEncodeDecoder {
function addressType (line 123) | func addressType(prefix []byte, params *Params) (uint8, error) {
type Address (line 134) | type Address interface
type AddressPubKeyHash (line 141) | type AddressPubKeyHash struct
method String (line 159) | func (addr AddressPubKeyHash) String() string {
method EncodeAddress (line 166) | func (addr AddressPubKeyHash) EncodeAddress() string {
method ScriptAddress (line 173) | func (addr AddressPubKeyHash) ScriptAddress() []byte {
method IsForNet (line 179) | func (addr AddressPubKeyHash) IsForNet(params *chaincfg.Params) bool {
method BitcoinAddress (line 184) | func (addr AddressPubKeyHash) BitcoinAddress() btcutil.Address {
function NewAddressPubKeyHash (line 148) | func NewAddressPubKeyHash(pkh []byte, params *Params) (AddressPubKeyHash...
type AddressScriptHash (line 190) | type AddressScriptHash struct
method String (line 215) | func (addr AddressScriptHash) String() string {
method BitcoinAddress (line 220) | func (addr AddressScriptHash) BitcoinAddress() btcutil.Address {
method EncodeAddress (line 227) | func (addr AddressScriptHash) EncodeAddress() string {
method ScriptAddress (line 234) | func (addr AddressScriptHash) ScriptAddress() []byte {
method IsForNet (line 240) | func (addr AddressScriptHash) IsForNet(params *chaincfg.Params) bool {
function NewAddressScriptHash (line 197) | func NewAddressScriptHash(script []byte, params *Params) (AddressScriptH...
function NewAddressScriptHashFromHash (line 204) | func NewAddressScriptHashFromHash(scriptHash []byte, params *Params) (Ad...
function addressFromRawBytes (line 246) | func addressFromRawBytes(addrBytes []byte, params *Params) (Address, err...
function encodeAddress (line 276) | func encodeAddress(hash, prefix []byte) string {
function checksum (line 286) | func checksum(input []byte) (cksum [4]byte) {
FILE: chain/zcash/gas.go
constant multiplier (line 12) | multiplier = 1e8
constant kilobyteToByte (line 13) | kilobyteToByte = 1024
type GasEstimator (line 21) | type GasEstimator struct
method EstimateGas (line 45) | func (gasEstimator GasEstimator) EstimateGas(ctx context.Context) (pac...
function NewGasEstimator (line 29) | func NewGasEstimator(client Client, numBlocks int64, fallbackGas pack.U2...
FILE: chain/zcash/utxo.go
constant Version (line 23) | Version int32 = 4
function DefaultClientOptions (line 31) | func DefaultClientOptions() ClientOptions {
type TxBuilder (line 43) | type TxBuilder struct
method BuildTx (line 69) | func (txBuilder TxBuilder) BuildTx(inputs []utxo.Input, recipients []u...
function NewTxBuilder (line 51) | func NewTxBuilder(params *Params, expiryHeight uint32) utxo.TxBuilder {
type Tx (line 108) | type Tx struct
method Hash (line 120) | func (tx *Tx) Hash() (pack.Bytes, error) {
method Inputs (line 130) | func (tx *Tx) Inputs() ([]utxo.Input, error) {
method Outputs (line 135) | func (tx *Tx) Outputs() ([]utxo.Output, error) {
method Sighashes (line 157) | func (tx *Tx) Sighashes() ([]pack.Bytes32, error) {
method Sign (line 187) | func (tx *Tx) Sign(signatures []pack.Bytes65, pubKey pack.Bytes) error {
method Serialize (line 220) | func (tx *Tx) Serialize() (pack.Bytes, error) {
function calculateSighash (line 321) | func calculateSighash(
function blake2b (line 486) | func blake2b(data, key []byte) (h chainhash.Hash, err error) {
function sighashKey (line 499) | func sighashKey(activationHeight uint32, network *Params) []byte {
function txSighashes (line 512) | func txSighashes(tx *wire.MsgTx) (h *txscript.TxSigHashes, err error) {
function calculateHashPrevOuts (line 536) | func calculateHashPrevOuts(tx *wire.MsgTx) (chainhash.Hash, error) {
function calculateHashSequence (line 560) | func calculateHashSequence(tx *wire.MsgTx) (chainhash.Hash, error) {
function calculateHashOutputs (line 576) | func calculateHashOutputs(tx *wire.MsgTx) (_ chainhash.Hash, err error) {
function writeTxOut (line 592) | func writeTxOut(w io.Writer, pver uint32, version int32, to *wire.TxOut)...
function writeTxIn (line 601) | func writeTxIn(w io.Writer, pver uint32, version int32, ti *wire.TxIn) e...
function writeOutPoint (line 617) | func writeOutPoint(w io.Writer, pver uint32, version int32, op *wire.Out...
function writeTxWitness (line 627) | func writeTxWitness(w io.Writer, pver uint32, version int32, wit [][]byt...
function writeVarInt (line 643) | func writeVarInt(w io.Writer, pver uint32, val uint64) error {
function writeVarBytes (line 672) | func writeVarBytes(w io.Writer, pver uint32, bytes []byte) error {
FILE: chain/zcash/zcash.go
constant sighashMask (line 8) | sighashMask = 0x1f
constant blake2BSighash (line 9) | blake2BSighash = "ZcashSigHash"
constant prevoutsHashPersonalization (line 10) | prevoutsHashPersonalization = "ZcashPrevoutHash"
constant sequenceHashPersonalization (line 11) | sequenceHashPersonalization = "ZcashSequencHash"
constant outputsHashPersonalization (line 12) | outputsHashPersonalization = "ZcashOutputsHash"
constant versionOverwinter (line 14) | versionOverwinter int32 = 3
constant versionOverwinterGroupID (line 15) | versionOverwinterGroupID uint32 = 0x3C48270
constant versionSapling (line 16) | versionSapling = 4
constant versionSaplingGroupID (line 17) | versionSaplingGroupID = 0x892f2085
type Params (line 21) | type Params struct
type ParamsUpgrade (line 31) | type ParamsUpgrade struct
FILE: chain/zcash/zcash_suite_test.go
function TestZcash (line 10) | func TestZcash(t *testing.T) {
FILE: infra/bitcoin/keygen.go
function main (line 12) | func main() {
FILE: infra/digibyte/keygen.go
function main (line 12) | func main() {
FILE: infra/dogecoin/keygen.go
function main (line 13) | func main() {
FILE: multichain.go
type Asset (line 96) | type Asset
method OriginChain (line 195) | func (asset Asset) OriginChain() Chain {
method ChainType (line 262) | func (asset Asset) ChainType() ChainType {
method Type (line 294) | func (asset Asset) Type() AssetType {
method SizeHint (line 324) | func (asset Asset) SizeHint() int {
method Marshal (line 329) | func (asset Asset) Marshal(buf []byte, rem int) ([]byte, int, error) {
method Unmarshal (line 334) | func (asset *Asset) Unmarshal(buf []byte, rem int) ([]byte, int, error) {
constant ArbETH (line 102) | ArbETH = Asset("ArbETH")
constant AVAX (line 103) | AVAX = Asset("AVAX")
constant BCH (line 104) | BCH = Asset("BCH")
constant BNB (line 105) | BNB = Asset("BNB")
constant BTC (line 106) | BTC = Asset("BTC")
constant CAT (line 107) | CAT = Asset("CAT")
constant DGB (line 108) | DGB = Asset("DGB")
constant DOGE (line 109) | DOGE = Asset("DOGE")
constant ETH (line 110) | ETH = Asset("ETH")
constant FIL (line 111) | FIL = Asset("FIL")
constant FTM (line 112) | FTM = Asset("FTM")
constant GETH (line 113) | GETH = Asset("gETH")
constant GLMR (line 114) | GLMR = Asset("GLMR")
constant KAVA (line 115) | KAVA = Asset("KAVA")
constant LUNA (line 116) | LUNA = Asset("LUNA")
constant MATIC (line 117) | MATIC = Asset("MATIC")
constant oETH (line 118) | oETH = Asset("oETH")
constant SOL (line 119) | SOL = Asset("SOL")
constant ZEC (line 120) | ZEC = Asset("ZEC")
constant USDC_Avalanche (line 122) | USDC_Avalanche = Asset("USDC_Avalanche")
constant USDT_Avalanche (line 123) | USDT_Avalanche = Asset("USDT_Avalanche")
constant BADGER (line 125) | BADGER = Asset("BADGER")
constant BUSD (line 126) | BUSD = Asset("BUSD")
constant CRV (line 127) | CRV = Asset("CRV")
constant DAI (line 128) | DAI = Asset("DAI")
constant EURT (line 129) | EURT = Asset("EURT")
constant FTT (line 130) | FTT = Asset("FTT")
constant ibBTC (line 131) | ibBTC = Asset("ibBTC")
constant KNC (line 132) | KNC = Asset("KNC")
constant LINK (line 133) | LINK = Asset("LINK")
constant MIM (line 134) | MIM = Asset("MIM")
constant REN (line 135) | REN = Asset("REN")
constant ROOK (line 136) | ROOK = Asset("ROOK")
constant SUSHI (line 137) | SUSHI = Asset("SUSHI")
constant UNI (line 138) | UNI = Asset("UNI")
constant USDC (line 139) | USDC = Asset("USDC")
constant USDT (line 140) | USDT = Asset("USDT")
constant DAI_Goerli (line 142) | DAI_Goerli = Asset("DAI_Goerli")
constant REN_Goerli (line 143) | REN_Goerli = Asset("REN_Goerli")
constant USDC_Goerli (line 144) | USDC_Goerli = Asset("USDC_Goerli")
constant USDT_Goerli (line 145) | USDT_Goerli = Asset("USDT_Goerli")
constant USDC_Polygon (line 147) | USDC_Polygon = Asset("USDC_Polygon")
constant USDT_Polygon (line 148) | USDT_Polygon = Asset("USDT_Polygon")
constant AMOCK1 (line 153) | AMOCK1 = Asset("AMOCK1")
constant AMOCK2 (line 154) | AMOCK2 = Asset("AMOCK2")
constant AMOCK3 (line 155) | AMOCK3 = Asset("AMOCK3")
constant UMOCK (line 156) | UMOCK = Asset("UMOCK")
type AssetType (line 161) | type AssetType
method SizeHint (line 177) | func (assetType AssetType) SizeHint() int {
method Marshal (line 183) | func (assetType AssetType) Marshal(buf []byte, rem int) ([]byte, int, ...
method Unmarshal (line 189) | func (assetType *AssetType) Unmarshal(buf []byte, rem int) ([]byte, in...
constant AssetTypeNative (line 167) | AssetTypeNative = AssetType("NativeAsset")
constant AssetTypeToken (line 172) | AssetTypeToken = AssetType("TokenAsset")
type Chain (line 339) | type Chain
method SizeHint (line 377) | func (chain Chain) SizeHint() int {
method Marshal (line 383) | func (chain Chain) Marshal(buf []byte, rem int) ([]byte, int, error) {
method Unmarshal (line 389) | func (chain *Chain) Unmarshal(buf []byte, rem int) ([]byte, int, error) {
method ChainType (line 395) | func (chain Chain) ChainType() ChainType {
method IsAccountBased (line 421) | func (chain Chain) IsAccountBased() bool {
method IsUTXOBased (line 427) | func (chain Chain) IsUTXOBased() bool {
method NativeAsset (line 433) | func (chain Chain) NativeAsset() Asset {
constant Arbitrum (line 345) | Arbitrum = Chain("Arbitrum")
constant Avalanche (line 346) | Avalanche = Chain("Avalanche")
constant BinanceSmartChain (line 347) | BinanceSmartChain = Chain("BinanceSmartChain")
constant Bitcoin (line 348) | Bitcoin = Chain("Bitcoin")
constant BitcoinCash (line 349) | BitcoinCash = Chain("BitcoinCash")
constant Catalog (line 350) | Catalog = Chain("Catalog")
constant DigiByte (line 351) | DigiByte = Chain("DigiByte")
constant Dogecoin (line 352) | Dogecoin = Chain("Dogecoin")
constant Ethereum (line 353) | Ethereum = Chain("Ethereum")
constant Fantom (line 354) | Fantom = Chain("Fantom")
constant Filecoin (line 355) | Filecoin = Chain("Filecoin")
constant Kava (line 356) | Kava = Chain("Kava")
constant Moonbeam (line 357) | Moonbeam = Chain("Moonbeam")
constant Optimism (line 358) | Optimism = Chain("Optimism")
constant Polygon (line 359) | Polygon = Chain("Polygon")
constant Solana (line 360) | Solana = Chain("Solana")
constant Terra (line 361) | Terra = Chain("Terra")
constant Zcash (line 362) | Zcash = Chain("Zcash")
constant Kovan (line 364) | Kovan = Chain("Kovan")
constant Goerli (line 365) | Goerli = Chain("Goerli")
constant AccountMocker1 (line 370) | AccountMocker1 = Chain("AccountMocker1")
constant AccountMocker2 (line 371) | AccountMocker2 = Chain("AccountMocker2")
constant UTXOMocker (line 372) | UTXOMocker = Chain("UTXOMocker")
type ChainType (line 490) | type ChainType
method SizeHint (line 504) | func (chainType ChainType) SizeHint() int {
method Marshal (line 510) | func (chainType ChainType) Marshal(buf []byte, rem int) ([]byte, int, ...
method Unmarshal (line 516) | func (chainType *ChainType) Unmarshal(buf []byte, rem int) ([]byte, in...
constant ChainTypeAccountBased (line 495) | ChainTypeAccountBased = ChainType("Account")
constant ChainTypeUTXOBased (line 499) | ChainTypeUTXOBased = ChainType("UTXO")
type Network (line 521) | type Network
method SizeHint (line 550) | func (net Network) SizeHint() int {
method Marshal (line 556) | func (net Network) Marshal(buf []byte, rem int) ([]byte, int, error) {
method Unmarshal (line 562) | func (net *Network) Unmarshal(buf []byte, rem int) ([]byte, int, error) {
constant NetworkLocalnet (line 530) | NetworkLocalnet = Network("localnet")
constant NetworkDevnet (line 536) | NetworkDevnet = Network("devnet")
constant NetworkTestnet (line 542) | NetworkTestnet = Network("testnet")
constant NetworkMainnet (line 545) | NetworkMainnet = Network("mainnet")
FILE: multichain_suite_test.go
function TestMultichain (line 10) | func TestMultichain(t *testing.T) {
FILE: multichain_test.go
function txHashToHex (line 1473) | func txHashToHex(txHash pack.Bytes) pack.String {
function fetchAuthToken (line 1485) | func fetchAuthToken() pack.String {
function getScript (line 1502) | func getScript(pubKey pack.Bytes) (pack.Bytes, error) {
function getPubKeyScript (line 1513) | func getPubKeyScript(pubKey pack.Bytes) (pack.Bytes, error) {
Condensed preview — 217 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (961K chars).
[
{
"path": ".github/CODEOWNERS",
"chars": 15,
"preview": "@jazg @tok-kkk\n"
},
{
"path": ".github/workflows/build.yml",
"chars": 1897,
"preview": "name: Docker Build\non:\n push:\n tags:\n - 'v*.*.*'\njobs:\n build:\n runs-on: ubuntu-latest\n env:\n FILEC"
},
{
"path": ".github/workflows/test.yml",
"chars": 47709,
"preview": "name: go\non: [pull_request]\njobs:\n test-solana:\n runs-on: ubuntu-latest\n env:\n FILECOIN_FFI_COMMIT: 79123893"
},
{
"path": ".gitignore",
"chars": 127,
"preview": "# Binaries and plugins\n*.exe\n*.exe~\n*.dll\n*.so\n*.dylib\n\n# Tests\n*.test\n\n# Outputs from tools\n*.out\n\n# IDE specific files"
},
{
"path": ".gitmodules",
"chars": 252,
"preview": "[submodule \"chain/filecoin/filecoin-ffi\"]\n\tpath = chain/filecoin/filecoin-ffi\n\turl = https://github.com/filecoin-project"
},
{
"path": "Dockerfile",
"chars": 1000,
"preview": "FROM golang\n\n# doing all updates and installs in a single step and removing the apt cache helps reduce the image size\nRU"
},
{
"path": "LICENSE",
"chars": 35148,
"preview": " GNU GENERAL PUBLIC LICENSE\n Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
},
{
"path": "README.md",
"chars": 10231,
"preview": "# `🔗 multichain`\n\n## Layout\n\n`/` declares the assets and chains that exist, but provides no chain-specific implementatio"
},
{
"path": "api/account/account.go",
"chars": 3401,
"preview": "// Package account defines the Account API. All chains that use an account-based\n// model should implement this API. The"
},
{
"path": "api/address/address.go",
"chars": 2338,
"preview": "// Package address defines the Address API. All chains must implement this API,\n// so that addresses can be encoded/deco"
},
{
"path": "api/contract/contract.go",
"chars": 1872,
"preview": "// Package contract defines the Contract API. All chains that have \"smart\n// contracts\" should implement this API. UTXO-"
},
{
"path": "api/gas/gas.go",
"chars": 1702,
"preview": "// Package gas defines the Gas API. All chains that support transactions (either\n// account-based or utxo-based) should "
},
{
"path": "api/utxo/utxo.go",
"chars": 4088,
"preview": "// Package utxo defines the UTXO API. All chains that use a utxo-based model\n// should implement this API. The UTXO API "
},
{
"path": "chain/arbitrum/address.go",
"chars": 864,
"preview": "package arbitrum\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\ntype (\n\t// AddressEncodeDecoder re-exports e"
},
{
"path": "chain/arbitrum/address_test.go",
"chars": 2565,
"preview": "package arbitrum_test\n\nimport (\n\t\"encoding/hex\"\n\t\"encoding/json\"\n\t\"testing/quick\"\n\n\t. \"github.com/onsi/ginkgo\"\n\t. \"githu"
},
{
"path": "chain/arbitrum/client.go",
"chars": 358,
"preview": "package arbitrum\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\nconst (\n\t// DefaultClientRPCURL is the RPC U"
},
{
"path": "chain/arbitrum/encode.go",
"chars": 196,
"preview": "package arbitrum\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\n// Payload re-exports evm.Payload.\ntype Payl"
},
{
"path": "chain/arbitrum/encode_test.go",
"chars": 7031,
"preview": "package arbitrum_test\n\nimport (\n\t\"encoding/hex\"\n\t\"fmt\"\n\t\"math\"\n\t\"testing/quick\"\n\n\t\"github.com/renproject/multichain/chai"
},
{
"path": "chain/arbitrum/gas.go",
"chars": 252,
"preview": "package arbitrum\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\n// GasEstimator re-exports evm.GasEstimator."
},
{
"path": "chain/arbitrum/tx.go",
"chars": 274,
"preview": "package arbitrum\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\ntype (\n\t// TxBuilder re-exports evm.TxBuilde"
},
{
"path": "chain/avalanche/address.go",
"chars": 865,
"preview": "package avalanche\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\ntype (\n\t// AddressEncodeDecoder re-exports "
},
{
"path": "chain/avalanche/address_test.go",
"chars": 2574,
"preview": "package avalanche_test\n\nimport (\n\t\"encoding/hex\"\n\t\"encoding/json\"\n\t\"testing/quick\"\n\n\t. \"github.com/onsi/ginkgo\"\n\t. \"gith"
},
{
"path": "chain/avalanche/client.go",
"chars": 373,
"preview": "package avalanche\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\nconst (\n\t// DefaultClientRPCURL is the RPC "
},
{
"path": "chain/avalanche/encode.go",
"chars": 197,
"preview": "package avalanche\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\n// Payload re-exports evm.Payload.\ntype Pay"
},
{
"path": "chain/avalanche/encode_test.go",
"chars": 7046,
"preview": "package avalanche_test\n\nimport (\n\t\"encoding/hex\"\n\t\"fmt\"\n\t\"math\"\n\t\"testing/quick\"\n\n\t\"github.com/renproject/multichain/cha"
},
{
"path": "chain/avalanche/gas.go",
"chars": 253,
"preview": "package avalanche\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\n// GasEstimator re-exports evm.GasEstimator"
},
{
"path": "chain/avalanche/tx.go",
"chars": 275,
"preview": "package avalanche\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\ntype (\n\t// TxBuilder re-exports evm.TxBuild"
},
{
"path": "chain/bitcoin/address.go",
"chars": 4081,
"preview": "package bitcoin\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/btcsuite/btcd/chaincfg\"\n\t\"github.com/btcsuite/btcutil\"\n\t\"github.com/btcsu"
},
{
"path": "chain/bitcoin/address_test.go",
"chars": 580,
"preview": "package bitcoin_test\n\nimport (\n\t\"github.com/btcsuite/btcd/chaincfg\"\n\t\"github.com/renproject/multichain/api/address\"\n\t\"gi"
},
{
"path": "chain/bitcoin/bitcoin.go",
"chars": 13620,
"preview": "package bitcoin\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"encoding/hex\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"log\"\n\t\"math/rand\"\n\t\"net/ht"
},
{
"path": "chain/bitcoin/bitcoin_suite_test.go",
"chars": 194,
"preview": "package bitcoin_test\n\nimport (\n\t\"testing\"\n\n\t. \"github.com/onsi/ginkgo\"\n\t. \"github.com/onsi/gomega\"\n)\n\nfunc TestBitcoin(t"
},
{
"path": "chain/bitcoin/bitcoin_test.go",
"chars": 6084,
"preview": "package bitcoin_test\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"os\"\n\t\"reflect\"\n\t\"time\"\n\n\t\"github.com/btcsuite/btcd/chaincfg\"\n\t\"github"
},
{
"path": "chain/bitcoin/gas.go",
"chars": 2039,
"preview": "package bitcoin\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"math\"\n\n\t\"github.com/renproject/pack\"\n)\n\nconst (\n\tbtcToSatoshis = 1e8\n\tkil"
},
{
"path": "chain/bitcoin/gas_test.go",
"chars": 1607,
"preview": "package bitcoin_test\n\nimport (\n\t\"context\"\n\n\t\"github.com/renproject/multichain/chain/bitcoin\"\n\t\"github.com/renproject/pac"
},
{
"path": "chain/bitcoin/utxo.go",
"chars": 6778,
"preview": "package bitcoin\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"math/big\"\n\n\t\"github.com/btcsuite/btcd/btcec\"\n\t\"github.com/btcsuite/btcd/chai"
},
{
"path": "chain/bitcoin/utxo_test.go",
"chars": 21,
"preview": "package bitcoin_test\n"
},
{
"path": "chain/bitcoincash/address.go",
"chars": 14920,
"preview": "package bitcoincash\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"strings\"\n\n\t\"github.com/btcsuite/btcd/chaincfg\"\n\t\"github.com/btcsuite/bt"
},
{
"path": "chain/bitcoincash/address_test.go",
"chars": 3162,
"preview": "package bitcoincash_test\n\nimport (\n\t\"fmt\"\n\t\"math/rand\"\n\n\t\"github.com/btcsuite/btcd/btcec\"\n\t\"github.com/btcsuite/btcd/cha"
},
{
"path": "chain/bitcoincash/bitcoincash.go",
"chars": 20,
"preview": "package bitcoincash\n"
},
{
"path": "chain/bitcoincash/bitcoincash_suite_test.go",
"chars": 207,
"preview": "package bitcoincash_test\n\nimport (\n\t\"testing\"\n\n\t. \"github.com/onsi/ginkgo\"\n\t. \"github.com/onsi/gomega\"\n)\n\nfunc TestBitco"
},
{
"path": "chain/bitcoincash/bitcoincash_test.go",
"chars": 5028,
"preview": "package bitcoincash_test\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"os\"\n\t\"reflect\"\n\t\"time\"\n\n\t\"github.com/btcsuite/btcd/chaincfg\"\n\t\"gi"
},
{
"path": "chain/bitcoincash/gas.go",
"chars": 1884,
"preview": "package bitcoincash\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"math\"\n\n\t\"github.com/renproject/pack\"\n)\n\nconst (\n\tbchToSatoshis = 1e8\n"
},
{
"path": "chain/bitcoincash/gas_test.go",
"chars": 817,
"preview": "package bitcoincash_test\n\nimport (\n\t\"context\"\n\n\t\"github.com/renproject/multichain/chain/bitcoincash\"\n\t\"github.com/renpro"
},
{
"path": "chain/bitcoincash/utxo.go",
"chars": 11178,
"preview": "package bitcoincash\n\nimport (\n\t\"bytes\"\n\t\"encoding/binary\"\n\t\"fmt\"\n\t\"math/big\"\n\n\t\"github.com/btcsuite/btcd/btcec\"\n\t\"github"
},
{
"path": "chain/bitcoincash/utxo_test.go",
"chars": 25,
"preview": "package bitcoincash_test\n"
},
{
"path": "chain/bsc/address.go",
"chars": 859,
"preview": "package bsc\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\ntype (\n\t// AddressEncodeDecoder re-exports evm.Ad"
},
{
"path": "chain/bsc/address_test.go",
"chars": 2520,
"preview": "package bsc_test\n\nimport (\n\t\"encoding/hex\"\n\t\"encoding/json\"\n\t\"testing/quick\"\n\n\t. \"github.com/onsi/ginkgo\"\n\t. \"github.com"
},
{
"path": "chain/bsc/client.go",
"chars": 349,
"preview": "package bsc\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\nconst (\n\t// DefaultClientRPCURL is the RPC URL us"
},
{
"path": "chain/bsc/encode.go",
"chars": 191,
"preview": "package bsc\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\n// Payload re-exports evm.Payload.\ntype Payload ="
},
{
"path": "chain/bsc/encode_test.go",
"chars": 6956,
"preview": "package bsc_test\n\nimport (\n\t\"encoding/hex\"\n\t\"fmt\"\n\t\"math\"\n\t\"testing/quick\"\n\n\t\"github.com/renproject/multichain/chain/bsc"
},
{
"path": "chain/bsc/gas.go",
"chars": 247,
"preview": "package bsc\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\n// GasEstimator re-exports evm.GasEstimator.\ntype"
},
{
"path": "chain/bsc/tx.go",
"chars": 269,
"preview": "package bsc\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\ntype (\n\t// TxBuilder re-exports evm.TxBuilder.\n\tT"
},
{
"path": "chain/cosmos/address.go",
"chars": 2145,
"preview": "package cosmos\n\nimport (\n\tsdk \"github.com/cosmos/cosmos-sdk/types\"\n\t\"github.com/renproject/multichain/api/address\"\n)\n\n//"
},
{
"path": "chain/cosmos/address_test.go",
"chars": 20,
"preview": "package cosmos_test\n"
},
{
"path": "chain/cosmos/client.go",
"chars": 8704,
"preview": "package cosmos\n\nimport (\n\t\"context\"\n\t\"encoding/hex\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"time\"\n\n\tcodecTypes \"github.com/cosmo"
},
{
"path": "chain/cosmos/cosmos.go",
"chars": 15,
"preview": "package cosmos\n"
},
{
"path": "chain/cosmos/cosmos_suite_test.go",
"chars": 191,
"preview": "package cosmos_test\n\nimport (\n\t\"testing\"\n\n\t. \"github.com/onsi/ginkgo\"\n\t. \"github.com/onsi/gomega\"\n)\n\nfunc TestCosmos(t *"
},
{
"path": "chain/cosmos/cosmos_test.go",
"chars": 20,
"preview": "package cosmos_test\n"
},
{
"path": "chain/cosmos/gas.go",
"chars": 1068,
"preview": "package cosmos\n\nimport (\n\t\"context\"\n\n\t\"github.com/renproject/multichain/api/gas\"\n\t\"github.com/renproject/pack\"\n)\n\n// A G"
},
{
"path": "chain/cosmos/gas_test.go",
"chars": 639,
"preview": "package cosmos_test\n\nimport (\n\t\"context\"\n\t\"testing/quick\"\n\n\t\"github.com/renproject/multichain/chain/cosmos\"\n\t\"github.com"
},
{
"path": "chain/cosmos/tx.go",
"chars": 10441,
"preview": "package cosmos\n\nimport (\n\t\"context\"\n\t\"crypto/sha256\"\n\t\"fmt\"\n\t\"math/big\"\n\n\t\"github.com/btcsuite/btcd/btcec\"\n\t\"github.com/"
},
{
"path": "chain/digibyte/address.go",
"chars": 521,
"preview": "package digibyte\n\nimport \"github.com/renproject/multichain/chain/bitcoin\"\n\n// AddressEncoder encapsulates the chain spec"
},
{
"path": "chain/digibyte/address_test.go",
"chars": 551,
"preview": "package digibyte_test\n\nimport (\n\t\"github.com/renproject/multichain/api/address\"\n\t\"github.com/renproject/multichain/chain"
},
{
"path": "chain/digibyte/digibyte.go",
"chars": 7301,
"preview": "package digibyte\n\nimport (\n\t\"math/big\"\n\t\"time\"\n\n\t\"github.com/btcsuite/btcd/chaincfg\"\n\t\"github.com/btcsuite/btcd/chaincfg"
},
{
"path": "chain/digibyte/digibyte_suite_test.go",
"chars": 197,
"preview": "package digibyte_test\n\nimport (\n\t\"testing\"\n\n\t. \"github.com/onsi/ginkgo\"\n\t. \"github.com/onsi/gomega\"\n)\n\nfunc TestDigiByte"
},
{
"path": "chain/digibyte/digibyte_test.go",
"chars": 5460,
"preview": "package digibyte_test\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"os\"\n\t\"reflect\"\n\t\"time\"\n\n\t\"github.com/btcsuite/btcutil\"\n\t\"github.com/"
},
{
"path": "chain/digibyte/gas.go",
"chars": 267,
"preview": "package digibyte\n\nimport \"github.com/renproject/multichain/chain/bitcoin\"\n\n// GasEstimator re-exports bitcoin.GasEstimat"
},
{
"path": "chain/digibyte/gas_test.go",
"chars": 22,
"preview": "package digibyte_test\n"
},
{
"path": "chain/digibyte/utxo.go",
"chars": 1093,
"preview": "package digibyte\n\nimport \"github.com/renproject/multichain/chain/bitcoin\"\n\ntype (\n\t// Tx represents a simple Bitcoin tra"
},
{
"path": "chain/digibyte/utxo_test.go",
"chars": 22,
"preview": "package digibyte_test\n"
},
{
"path": "chain/dogecoin/address.go",
"chars": 395,
"preview": "package dogecoin\n\nimport \"github.com/renproject/multichain/chain/bitcoin\"\n\ntype (\n\t// AddressEncoder re-exports bitcoin."
},
{
"path": "chain/dogecoin/address_test.go",
"chars": 742,
"preview": "package dogecoin_test\n\nimport (\n\t\"github.com/renproject/multichain\"\n\t\"github.com/renproject/multichain/chain/bitcoin\"\n\t\""
},
{
"path": "chain/dogecoin/dogecoin.go",
"chars": 2511,
"preview": "package dogecoin\n\nimport (\n\t\"github.com/btcsuite/btcd/chaincfg\"\n)\n\nfunc init() {\n\tif err := chaincfg.Register(&MainNetPa"
},
{
"path": "chain/dogecoin/dogecoin_suite_test.go",
"chars": 197,
"preview": "package dogecoin_test\n\nimport (\n\t\"testing\"\n\n\t. \"github.com/onsi/ginkgo\"\n\t. \"github.com/onsi/gomega\"\n)\n\nfunc TestDogecoin"
},
{
"path": "chain/dogecoin/dogecoin_test.go",
"chars": 4983,
"preview": "package dogecoin_test\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"os\"\n\t\"reflect\"\n\t\"time\"\n\n\t\"github.com/btcsuite/btcutil\"\n\t\"github.com/"
},
{
"path": "chain/dogecoin/gas.go",
"chars": 267,
"preview": "package dogecoin\n\nimport \"github.com/renproject/multichain/chain/bitcoin\"\n\n// GasEstimator re-exports bitcoin.GasEstimat"
},
{
"path": "chain/dogecoin/gas_test.go",
"chars": 1615,
"preview": "package dogecoin_test\n\nimport (\n\t\"context\"\n\n\t\"github.com/renproject/multichain/chain/dogecoin\"\n\t\"github.com/renproject/p"
},
{
"path": "chain/dogecoin/utxo.go",
"chars": 882,
"preview": "package dogecoin\n\nimport \"github.com/renproject/multichain/chain/bitcoin\"\n\ntype (\n\t// Tx re-exports bitcoin.Tx.\n\tTx = bi"
},
{
"path": "chain/dogecoin/utxo_test.go",
"chars": 22,
"preview": "package dogecoin_test\n"
},
{
"path": "chain/ethereum/address.go",
"chars": 864,
"preview": "package ethereum\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\ntype (\n\t// AddressEncodeDecoder re-exports e"
},
{
"path": "chain/ethereum/address_test.go",
"chars": 2565,
"preview": "package ethereum_test\n\nimport (\n\t\"encoding/hex\"\n\t\"encoding/json\"\n\t\"testing/quick\"\n\n\t. \"github.com/onsi/ginkgo\"\n\t. \"githu"
},
{
"path": "chain/ethereum/client.go",
"chars": 359,
"preview": "package ethereum\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\nconst (\n\t// DefaultClientRPCURL is the RPC U"
},
{
"path": "chain/ethereum/encode.go",
"chars": 196,
"preview": "package ethereum\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\n// Payload re-exports evm.Payload.\ntype Payl"
},
{
"path": "chain/ethereum/encode_test.go",
"chars": 7031,
"preview": "package ethereum_test\n\nimport (\n\t\"encoding/hex\"\n\t\"fmt\"\n\t\"math\"\n\t\"testing/quick\"\n\n\t\"github.com/renproject/multichain/chai"
},
{
"path": "chain/ethereum/gas.go",
"chars": 6184,
"preview": "package ethereum\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"math/big\"\n\t\"sort\"\n\n\t\"github.com/renproject/pack\"\n)\n\nconst (\n\t// FeeHistor"
},
{
"path": "chain/ethereum/tx.go",
"chars": 1496,
"preview": "package ethereum\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"math/big\"\n\n\t\"github.com/ethereum/go-ethereum/common\"\n\t\"github.com/ethereu"
},
{
"path": "chain/evm/address.go",
"chars": 3970,
"preview": "package evm\n\nimport (\n\t\"encoding/hex\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"strings\"\n\n\t\"github.com/ethereum/go-ethereum/common\"\n\t\"gi"
},
{
"path": "chain/evm/address_test.go",
"chars": 2561,
"preview": "package evm_test\n\nimport (\n\t\"encoding/hex\"\n\t\"encoding/json\"\n\t\"testing/quick\"\n\n\t\"github.com/renproject/multichain/chain/e"
},
{
"path": "chain/evm/client.go",
"chars": 5471,
"preview": "package evm\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"math/big\"\n\n\t\"github.com/ethereum/go-ethereum\"\n\t\"github.com/ethereum/go-ethereu"
},
{
"path": "chain/evm/encode.go",
"chars": 2342,
"preview": "package evm\n\nimport (\n\t\"fmt\"\n\t\"math/big\"\n\n\t\"github.com/ethereum/go-ethereum/accounts/abi\"\n\t\"github.com/renproject/pack\"\n"
},
{
"path": "chain/evm/encode_test.go",
"chars": 8489,
"preview": "package evm_test\n\nimport (\n\t\"encoding/hex\"\n\t\"fmt\"\n\t\"math\"\n\t\"testing/quick\"\n\n\t\"github.com/renproject/multichain/chain/eth"
},
{
"path": "chain/evm/gas.go",
"chars": 1162,
"preview": "package evm\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/renproject/pack\"\n)\n\n// A GasEstimator returns the gas price and th"
},
{
"path": "chain/evm/tx.go",
"chars": 3784,
"preview": "package evm\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"math/big\"\n\n\t\"github.com/ethereum/go-ethereum/common\"\n\t\"github.com/ethereum/go-"
},
{
"path": "chain/fantom/address.go",
"chars": 862,
"preview": "package fantom\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\ntype (\n\t// AddressEncodeDecoder re-exports evm"
},
{
"path": "chain/fantom/address_test.go",
"chars": 2547,
"preview": "package fantom_test\n\nimport (\n\t\"encoding/hex\"\n\t\"encoding/json\"\n\t\"testing/quick\"\n\n\t. \"github.com/onsi/ginkgo\"\n\t. \"github."
},
{
"path": "chain/fantom/client.go",
"chars": 356,
"preview": "package fantom\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\nconst (\n\t// DefaultClientRPCURL is the RPC URL"
},
{
"path": "chain/fantom/encode.go",
"chars": 194,
"preview": "package fantom\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\n// Payload re-exports evm.Payload.\ntype Payloa"
},
{
"path": "chain/fantom/encode_test.go",
"chars": 7001,
"preview": "package fantom_test\n\nimport (\n\t\"encoding/hex\"\n\t\"fmt\"\n\t\"math\"\n\t\"testing/quick\"\n\n\t\"github.com/renproject/multichain/chain/"
},
{
"path": "chain/fantom/gas.go",
"chars": 250,
"preview": "package fantom\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\n// GasEstimator re-exports evm.GasEstimator.\nt"
},
{
"path": "chain/fantom/tx.go",
"chars": 272,
"preview": "package fantom\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\ntype (\n\t// TxBuilder re-exports evm.TxBuilder."
},
{
"path": "chain/filecoin/account.go",
"chars": 4812,
"preview": "package filecoin\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"crypto/ecdsa\"\n\t\"fmt\"\n\n\tethcrypto \"github.com/ethereum/go-ethereum/crypt"
},
{
"path": "chain/filecoin/account_test.go",
"chars": 22,
"preview": "package filecoin_test\n"
},
{
"path": "chain/filecoin/address.go",
"chars": 1710,
"preview": "package filecoin\n\nimport (\n\t\"fmt\"\n\n\tfiladdress \"github.com/filecoin-project/go-address\"\n\t\"github.com/renproject/multicha"
},
{
"path": "chain/filecoin/address_test.go",
"chars": 3429,
"preview": "package filecoin_test\n\nimport (\n\t\"math/rand\"\n\t\"testing/quick\"\n\t\"time\"\n\n\tfiladdress \"github.com/filecoin-project/go-addre"
},
{
"path": "chain/filecoin/client.go",
"chars": 7066,
"preview": "package filecoin\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"net/http\"\n\n\tfiladdress \"github.com/filecoin-project/go-address\"\n\t\"github."
},
{
"path": "chain/filecoin/client_test.go",
"chars": 22,
"preview": "package filecoin_test\n"
},
{
"path": "chain/filecoin/filecoin.go",
"chars": 17,
"preview": "package filecoin\n"
},
{
"path": "chain/filecoin/filecoin_suite_test.go",
"chars": 197,
"preview": "package filecoin_test\n\nimport (\n\t\"testing\"\n\n\t. \"github.com/onsi/ginkgo\"\n\t. \"github.com/onsi/gomega\"\n)\n\nfunc TestFilecoin"
},
{
"path": "chain/filecoin/filecoin_test.go",
"chars": 4241,
"preview": "package filecoin_test\n\nimport (\n\t\"context\"\n\t\"encoding/hex\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"os\"\n\t\"time\"\n\n\tfiladdress \"github.co"
},
{
"path": "chain/filecoin/gas.go",
"chars": 2559,
"preview": "package filecoin\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"math/big\"\n\n\tfiladdress \"github.com/filecoin-project/go-address\"\n\t\"github."
},
{
"path": "chain/filecoin/gas_test.go",
"chars": 1501,
"preview": "package filecoin_test\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"fmt\"\n\t\"os/exec\"\n\t\"strings\"\n\n\t\"github.com/renproject/multichain/cha"
},
{
"path": "chain/kava/address.go",
"chars": 860,
"preview": "package kava\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\ntype (\n\t// AddressEncodeDecoder re-exports evm.A"
},
{
"path": "chain/kava/address_test.go",
"chars": 2530,
"preview": "package kava_test\n\nimport (\n\t\"encoding/hex\"\n\t\"encoding/json\"\n\t\"testing/quick\"\n\n\t\"github.com/renproject/multichain/chain/"
},
{
"path": "chain/kava/client.go",
"chars": 350,
"preview": "package kava\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\nconst (\n\t// DefaultClientRPCURL is the RPC URL u"
},
{
"path": "chain/kava/encode.go",
"chars": 192,
"preview": "package kava\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\n// Payload re-exports evm.Payload.\ntype Payload "
},
{
"path": "chain/kava/encode_test.go",
"chars": 6970,
"preview": "package kava_test\n\nimport (\n\t\"encoding/hex\"\n\t\"fmt\"\n\t\"math\"\n\t\"testing/quick\"\n\n\t\"github.com/renproject/multichain/chain/ka"
},
{
"path": "chain/kava/gas.go",
"chars": 248,
"preview": "package kava\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\n// GasEstimator re-exports evm.GasEstimator.\ntyp"
},
{
"path": "chain/kava/tx.go",
"chars": 270,
"preview": "package kava\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\ntype (\n\t// TxBuilder re-exports evm.TxBuilder.\n\t"
},
{
"path": "chain/moonbeam/address.go",
"chars": 864,
"preview": "package moonbeam\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\ntype (\n\t// AddressEncodeDecoder re-exports e"
},
{
"path": "chain/moonbeam/address_test.go",
"chars": 2566,
"preview": "package moonbeam_test\n\nimport (\n\t\"encoding/hex\"\n\t\"encoding/json\"\n\t\"testing/quick\"\n\n\t\"github.com/renproject/multichain/ch"
},
{
"path": "chain/moonbeam/client.go",
"chars": 354,
"preview": "package moonbeam\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\nconst (\n\t// DefaultClientRPCURL is the RPC U"
},
{
"path": "chain/moonbeam/encode.go",
"chars": 196,
"preview": "package moonbeam\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\n// Payload re-exports evm.Payload.\ntype Payl"
},
{
"path": "chain/moonbeam/encode_test.go",
"chars": 7030,
"preview": "package moonbeam_test\n\nimport (\n\t\"encoding/hex\"\n\t\"fmt\"\n\t\"math\"\n\t\"testing/quick\"\n\n\t\"github.com/renproject/multichain/chai"
},
{
"path": "chain/moonbeam/gas.go",
"chars": 252,
"preview": "package moonbeam\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\n// GasEstimator re-exports evm.GasEstimator."
},
{
"path": "chain/moonbeam/tx.go",
"chars": 274,
"preview": "package moonbeam\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\ntype (\n\t// TxBuilder re-exports evm.TxBuilde"
},
{
"path": "chain/optimism/address.go",
"chars": 864,
"preview": "package optimism\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\ntype (\n\t// AddressEncodeDecoder re-exports e"
},
{
"path": "chain/optimism/address_test.go",
"chars": 2534,
"preview": "package optimism_test\n\nimport (\n\t\"encoding/hex\"\n\t\"encoding/json\"\n\t\"testing/quick\"\n\n\t\"github.com/renproject/multichain/ch"
},
{
"path": "chain/optimism/client.go",
"chars": 354,
"preview": "package optimism\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\nconst (\n\t// DefaultClientRPCURL is the RPC U"
},
{
"path": "chain/optimism/encode.go",
"chars": 196,
"preview": "package optimism\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\n// Payload re-exports evm.Payload.\ntype Payl"
},
{
"path": "chain/optimism/encode_test.go",
"chars": 6974,
"preview": "package optimism_test\n\nimport (\n\t\"encoding/hex\"\n\t\"fmt\"\n\t\"math\"\n\t\"testing/quick\"\n\n\t\"github.com/renproject/multichain/chai"
},
{
"path": "chain/optimism/gas.go",
"chars": 252,
"preview": "package optimism\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\n// GasEstimator re-exports evm.GasEstimator."
},
{
"path": "chain/optimism/tx.go",
"chars": 274,
"preview": "package optimism\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\ntype (\n\t// TxBuilder re-exports evm.TxBuilde"
},
{
"path": "chain/polygon/address.go",
"chars": 863,
"preview": "package polygon\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\ntype (\n\t// AddressEncodeDecoder re-exports ev"
},
{
"path": "chain/polygon/address_test.go",
"chars": 2556,
"preview": "package polygon_test\n\nimport (\n\t\"encoding/hex\"\n\t\"encoding/json\"\n\t\"testing/quick\"\n\n\t. \"github.com/onsi/ginkgo\"\n\t. \"github"
},
{
"path": "chain/polygon/client.go",
"chars": 358,
"preview": "package polygon\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\nconst (\n\t// DefaultClientRPCURL is the RPC UR"
},
{
"path": "chain/polygon/encode.go",
"chars": 195,
"preview": "package polygon\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\n// Payload re-exports evm.Payload.\ntype Paylo"
},
{
"path": "chain/polygon/encode_test.go",
"chars": 7016,
"preview": "package polygon_test\n\nimport (\n\t\"encoding/hex\"\n\t\"fmt\"\n\t\"math\"\n\t\"testing/quick\"\n\n\t\"github.com/renproject/multichain/chain"
},
{
"path": "chain/polygon/gas.go",
"chars": 251,
"preview": "package polygon\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\n// GasEstimator re-exports evm.GasEstimator.\n"
},
{
"path": "chain/polygon/tx.go",
"chars": 273,
"preview": "package polygon\n\nimport (\n\t\"github.com/renproject/multichain/chain/evm\"\n)\n\ntype (\n\t// TxBuilder re-exports evm.TxBuilder"
},
{
"path": "chain/solana/address.go",
"chars": 1504,
"preview": "package solana\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/btcsuite/btcutil/base58\"\n\t\"github.com/renproject/multichain/api/address\"\n)"
},
{
"path": "chain/solana/rpc.go",
"chars": 4546,
"preview": "package solana\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"net\"\n\t\"net/http\"\n\t\"strings\"\n\t\"time\"\n)\n\n// Request defines a "
},
{
"path": "chain/solana/solana.go",
"chars": 4714,
"preview": "package solana\n\nimport (\n\t\"context\"\n\t\"encoding/base64\"\n\t\"encoding/json\"\n\t\"fmt\"\n\n\t\"github.com/btcsuite/btcutil/base58\"\n\t\""
},
{
"path": "chain/solana/solana_ffi.go",
"chars": 948,
"preview": "package solana\n\nimport (\n\t\"github.com/renproject/multichain/api/address\"\n\t\"github.com/renproject/pack\"\n\t\"github.com/renp"
},
{
"path": "chain/solana/solana_ffi_test.go",
"chars": 1860,
"preview": "package solana_test\n\nimport (\n\t\"github.com/ethereum/go-ethereum/crypto\"\n\t\"github.com/renproject/multichain/api/address\"\n"
},
{
"path": "chain/solana/solana_suite_test.go",
"chars": 191,
"preview": "package solana_test\n\nimport (\n\t\"testing\"\n\n\t. \"github.com/onsi/ginkgo\"\n\t. \"github.com/onsi/gomega\"\n)\n\nfunc TestSolana(t *"
},
{
"path": "chain/solana/solana_test.go",
"chars": 5485,
"preview": "package solana_test\n\nimport (\n\t\"context\"\n\t\"encoding/binary\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/ethereum/go-ethereum/crypto\"\n\t\"g"
},
{
"path": "chain/solana/solanarpc.go",
"chars": 716,
"preview": "package solana\n\n// AccountContext is the JSON-interface of the account's context representing\n// what slot the account's"
},
{
"path": "chain/substrate/address.go",
"chars": 1260,
"preview": "package substrate\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/btcsuite/btcutil/base58\"\n\t\"github.com/renproject/pack\"\n)\n\n// An Address"
},
{
"path": "chain/substrate/address_test.go",
"chars": 23,
"preview": "package substrate_test\n"
},
{
"path": "chain/terra/address.go",
"chars": 804,
"preview": "package terra\n\nimport \"github.com/renproject/multichain/chain/cosmos\"\n\ntype (\n\t// Address re-exports cosmos-compatible a"
},
{
"path": "chain/terra/address_test.go",
"chars": 1453,
"preview": "package terra_test\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/renproject/multichain\"\n\t\"github.com/renproject/multichain/chain/terra\""
},
{
"path": "chain/terra/terra.go",
"chars": 3377,
"preview": "package terra\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"strconv\"\n\n\t\"github.com/cosmos/cosmos-sdk/types\""
},
{
"path": "chain/terra/terra_suite_test.go",
"chars": 188,
"preview": "package terra_test\n\nimport (\n\t\"testing\"\n\n\t. \"github.com/onsi/ginkgo\"\n\t. \"github.com/onsi/gomega\"\n)\n\nfunc TestTerra(t *te"
},
{
"path": "chain/terra/terra_test.go",
"chars": 4228,
"preview": "package terra_test\n\nimport (\n\t\"context\"\n\t\"encoding/hex\"\n\t\"os\"\n\t\"time\"\n\n\t\"github.com/renproject/id\"\n\t\"github.com/renproje"
},
{
"path": "chain/zcash/address.go",
"chars": 9439,
"preview": "package zcash\n\nimport (\n\t\"bytes\"\n\t\"crypto/sha256\"\n\t\"fmt\"\n\n\t\"github.com/btcsuite/btcd/chaincfg\"\n\t\"github.com/btcsuite/btc"
},
{
"path": "chain/zcash/address_test.go",
"chars": 3449,
"preview": "package zcash_test\n\nimport (\n\t\"bytes\"\n\t\"math/rand\"\n\n\t. \"github.com/onsi/ginkgo\"\n\t. \"github.com/onsi/gomega\"\n\n\t\"github.co"
},
{
"path": "chain/zcash/gas.go",
"chars": 2035,
"preview": "package zcash\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"math\"\n\n\t\"github.com/renproject/pack\"\n)\n\nconst (\n\tmultiplier = 1e8\n\tkilob"
},
{
"path": "chain/zcash/gas_test.go",
"chars": 1591,
"preview": "package zcash_test\n\nimport (\n\t\"context\"\n\n\t\"github.com/renproject/multichain/chain/zcash\"\n\t\"github.com/renproject/pack\"\n\n"
},
{
"path": "chain/zcash/utxo.go",
"chars": 20344,
"preview": "package zcash\n\nimport (\n\t\"bytes\"\n\t\"encoding/binary\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"math/big\"\n\n\tblake2 \"github.com/dchest/blake2b"
},
{
"path": "chain/zcash/utxo_test.go",
"chars": 19,
"preview": "package zcash_test\n"
},
{
"path": "chain/zcash/zcash.go",
"chars": 2486,
"preview": "package zcash\n\nimport (\n\t\"github.com/btcsuite/btcd/chaincfg\"\n)\n\nconst (\n\tsighashMask = 0x1f\n\tblake2BSigh"
},
{
"path": "chain/zcash/zcash_suite_test.go",
"chars": 188,
"preview": "package zcash_test\n\nimport (\n\t\"testing\"\n\n\t. \"github.com/onsi/ginkgo\"\n\t. \"github.com/onsi/gomega\"\n)\n\nfunc TestZcash(t *te"
},
{
"path": "chain/zcash/zcash_test.go",
"chars": 5066,
"preview": "package zcash_test\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"os\"\n\t\"reflect\"\n\t\"time\"\n\n\t\"github.com/btcsuite/btcutil\"\n\t\"github.com/ren"
},
{
"path": "go.mod",
"chars": 1453,
"preview": "module github.com/renproject/multichain\n\ngo 1.16\n\nrequire (\n\tgithub.com/btcsuite/btcd v0.22.1\n\tgithub.com/btcsuite/btcd/"
},
{
"path": "go.sum",
"chars": 271549,
"preview": "cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=\ncloud.google.com/go v0.31.0/go.mod h1"
},
{
"path": "infra/acala/Dockerfile",
"chars": 897,
"preview": "FROM ubuntu:xenial\n\nRUN apt-get update && apt-get install --yes --fix-missing software-properties-common curl git clang\n"
},
{
"path": "infra/acala/run.sh",
"chars": 103,
"preview": "#!/bin/bash\nADDRESS=$1\n\n# Start\ncd /app\nmake run\nsleep 10\n\n# Print setup\necho \"ACALA_ADDRESS=$ADDRESS\"\n"
},
{
"path": "infra/avalanche/Dockerfile",
"chars": 663,
"preview": "FROM ubuntu:bionic\n\nRUN apt update -y\nRUN apt-get install -y wget curl build-essential\n\n# INSTALL GO AND RUST\nRUN wget -"
},
{
"path": "infra/avalanche/run.sh",
"chars": 2914,
"preview": "#!/bin/bash\n\nAVAX_USERNAME=$1\nAVAX_PASSWORD=$2\nAVAX_PK=$3\nAVAX_ADDRESS=$4\nC_AVAX_PK=$5\nC_AVAX_HEX_ADDRESS=$6\nC_AVAX_BECH"
},
{
"path": "infra/binance/Dockerfile",
"chars": 304,
"preview": "FROM ubuntu:xenial\n\nRUN apt-get update --fix-missing\nRUN apt-get install --yes curl\n\nRUN curl -sL https://deb.nodesource"
},
{
"path": "infra/binance/Dockerfile-riolta",
"chars": 745,
"preview": "# Build Geth in a stock Go builder container\nFROM golang:1.14-alpine as builder\n\nRUN apk add --no-cache make gcc musl-de"
},
{
"path": "infra/binance/run.sh",
"chars": 242,
"preview": "#!/bin/bash\nMNEMONIC=$1\nADDRESS=$2\n\nganache-cli \\\n -h 0.0.0.0 \\\n -a 105 \\\n -k muirGlacier \\\n -i 420"
},
{
"path": "infra/bitcoin/Dockerfile",
"chars": 612,
"preview": "FROM ubuntu:bionic\n\nRUN apt-get update && apt-get install --yes software-properties-common\nRUN apt-get install --yes cur"
},
{
"path": "infra/bitcoin/bitcoin.conf",
"chars": 119,
"preview": "daemon=1\nregtest=1\nrpcuser=user\nrpcpassword=password\nrpcallowip=0.0.0.0/0\nserver=1\ntxindex=1\n\n[regtest]\nrpcbind=0.0.0.0"
},
{
"path": "infra/bitcoin/keygen.go",
"chars": 581,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/btcsuite/btcd/btcec\"\n\t\"github.com/btcsuite/btcd/chaincfg\"\n\t\"github.com/btcsu"
},
{
"path": "infra/bitcoin/run.sh",
"chars": 808,
"preview": "#!/bin/bash\nADDRESS=$1\nPRIV_KEY=$2\n\n# Start\n/app/bin/bitcoind -regtest -daemon\nsleep 20\n\n# Print setup\necho \"BITCOIN_ADD"
},
{
"path": "infra/bitcoincash/Dockerfile",
"chars": 446,
"preview": "FROM ubuntu:bionic\n\n# Install bitcoind-abc.\nRUN apt-get update && apt-get install --yes software-properties-common && \\\n"
},
{
"path": "infra/bitcoincash/bitcoin.conf",
"chars": 117,
"preview": "daemon=1\nregtest=1\nrpcuser=user\nrpcpassword=password\nrpcallowip=0.0.0.0/0\nserver=1\ntxindex=1\n\n[regtest]\nrpcport=19443"
},
{
"path": "infra/bitcoincash/run.sh",
"chars": 346,
"preview": "#!/bin/bash\nADDRESS=$1\n\n# Start\nbitcoind\nsleep 10\n\n# Print setup\necho \"BITCOINCASH_ADDRESS=$ADDRESS\"\n\n# Import the addre"
},
{
"path": "infra/digibyte/Dockerfile",
"chars": 1782,
"preview": "FROM ubuntu:xenial\n\nARG VERSION=7.17.2\nARG ARCH=x86_64\nARG RPCUSERNAME=user\nARG RPCPASSWORD=password\nARG ROOTDATADIR=/ap"
},
{
"path": "infra/digibyte/README.md",
"chars": 384,
"preview": "# README\n\n## Generate a keypair (privatekey + address)\n```bash\n$ go run keygen.go\nDIGIBYTE_PK=eagPs6RBxmTQyjni3K7vqPNBwj"
},
{
"path": "infra/digibyte/keygen.go",
"chars": 597,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/btcsuite/btcd/btcec\"\n\t\"github.com/btcsuite/btcutil\"\n\t\"github.com/renproject/"
},
{
"path": "infra/digibyte/run.sh",
"chars": 341,
"preview": "#!/bin/bash\nADDRESS=$1\n\n# Start\ndigibyted\nsleep 10\n\n# Print setup\necho \"DIGIBYTE_ADDRESS=$ADDRESS\"\n\n# Import the address"
},
{
"path": "infra/docker-compose.yaml",
"chars": 2854,
"preview": "version: \"2\"\nservices:\n #\n # Acala\n #\n acala:\n build:\n context: ./acala\n ports:\n - \"0.0.0.0:9933:993"
},
{
"path": "infra/dogecoin/Dockerfile",
"chars": 482,
"preview": "FROM ubuntu:xenial\n\nRUN apt-get update --fix-missing && apt-get install --yes software-properties-common wget\n\nRUN wget "
},
{
"path": "infra/dogecoin/dogecoin.conf",
"chars": 119,
"preview": "daemon=1\nregtest=1\nrpcuser=user\nrpcpassword=password\nrpcallowip=0.0.0.0/0\nserver=1\ntxindex=1\n\n[regtest]\nrpcbind=0.0.0.0"
},
{
"path": "infra/dogecoin/keygen.go",
"chars": 598,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/btcsuite/btcd/btcec\"\n\t\"github.com/btcsuite/btcutil\"\n\n\t\"github.com/renproject"
},
{
"path": "infra/dogecoin/run.sh",
"chars": 504,
"preview": "#!/bin/bash\nADDRESS=$1\n\n# Start\n/app/bin/dogecoind -conf=/root/.dogecoin/dogecoin.conf # -server -rpcbind=0.0.0.0 -rpcal"
},
{
"path": "infra/ethereum/Dockerfile",
"chars": 174,
"preview": "FROM node:16-alpine\n\nWORKDIR /root/app\n\nCOPY package.json .\nRUN npm install\n\nCOPY hardhat.config.js .\nCOPY run.sh .\nRUN "
},
{
"path": "infra/ethereum/hardhat.config.js",
"chars": 499,
"preview": "/**\n * @type import('hardhat/config').HardhatUserConfig\n */\nmodule.exports = {\n solidity: \"0.7.3\",\n defaultNetwork: \"h"
},
{
"path": "infra/ethereum/package.json",
"chars": 84,
"preview": "{\n \"name\": \"hardhat-project\",\n \"devDependencies\": {\n \"hardhat\": \"^2.5.0\"\n }\n}\n"
},
{
"path": "infra/ethereum/run.sh",
"chars": 55,
"preview": "#!/bin/sh\n\nnpx hardhat --config hardhat.config.js node\n"
},
{
"path": "infra/fantom/Dockerfile",
"chars": 658,
"preview": "FROM ubuntu:bionic\n\n# Install dependencies\nRUN apt-get update -y\nRUN apt-get install -y build-essential git wget\n\n# Inst"
},
{
"path": "infra/filecoin/Dockerfile",
"chars": 869,
"preview": "FROM ubuntu:bionic\n\nRUN apt update -y\nRUN apt install -y mesa-opencl-icd ocl-icd-opencl-dev gcc git bzr jq pkg-config cu"
},
{
"path": "infra/filecoin/miner.key",
"chars": 161,
"preview": "7b2254797065223a22736563703235366b31222c22507269766174654b6579223a223168436f364f617442746f58636d304f6565665849473873374e"
},
{
"path": "infra/filecoin/run.sh",
"chars": 1513,
"preview": "#!/bin/bash\n\ncd /app/\n\nexport LOTUS_SKIP_GENESIS_CHECK=_yes_\n\n./lotus daemon --lotus-make-genesis=dev.gen --genesis-temp"
},
{
"path": "infra/filecoin/user.key",
"chars": 161,
"preview": "7b2254797065223a22736563703235366b31222c22507269766174654b6579223a22756d6a634e436a487a5438455757485849754a4c4b5874503543"
},
{
"path": "infra/goerli/Dockerfile",
"chars": 171,
"preview": "FROM node:alpine\n\nWORKDIR /root/app\n\nCOPY package.json .\nRUN npm install\n\nCOPY hardhat.config.js .\nCOPY run.sh .\nRUN chm"
},
{
"path": "infra/goerli/hardhat.config.js",
"chars": 458,
"preview": "/**\n * @type import('hardhat/config').HardhatUserConfig\n */\nmodule.exports = {\n solidity: \"0.7.3\",\n defaultNetwork: \"h"
},
{
"path": "infra/goerli/package.json",
"chars": 84,
"preview": "{\n \"name\": \"hardhat-project\",\n \"devDependencies\": {\n \"hardhat\": \"^2.5.0\"\n }\n}\n"
}
]
// ... and 17 more files (download for full content)
About this extraction
This page contains the full source code of the renproject/multichain GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 217 files (876.5 KB), approximately 327.9k tokens, and a symbol index with 550 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.