Application for manage wallet sessions and execute wallet request, like:
- Get account address
- Generate new mnemonic wallet
- Validate mnemonic seed phrase
- Sign data by private key by internal mnemonic account
This application is an environment for checking requests and transferring them for processing to the plugin, which makes cryptographic work for a specific blockchain.
HdWallet-api application is a second part of hdwallet applications bundle. Another third part of bundle - target blockchain plugin.
- API documentation bc-wallet-common-hdwallet-controller/docs/api/hdwallet_proto.md
- Golang proto generated code bc-wallet-common-hdwallet-controller/pkg/grpc/hdwallet
- Protobuf descriptions bc-wallet-common-hdwallet-controller/pkg/proto/hdwallet_api
- Hashicorp Vault as service provider of secrets management and as provider of encrypt/decrypt sensitive information flow
- Plugin with implementation Hierarchical Deterministic Wallet for target blockchain.
Example for tron blockchain:
Auth token: bc-wallet-tron-hdwallet-api
vault token create -display-name bc-wallet-tron-hdwallet-api
Buckets:
- crypto-bundle/bc-wallet-common/transit
- VAULT_COMMON_TRANSIT_KEY
- crypto-bundle/bc-wallet-tron-hdwallet/common
- VAULT_APP_ENCRYPTION_KEY
Application required two encryption keys:
-
Common for whole crypto-bundle project transit key - crypto-bundle-bc-wallet-common-transit-key. Value with transit key name will be loaded from
VAULT_COMMON_TRANSIT_KEY
Vault variable, which stored in common bucket - crypto-bundle/bc-wallet-common/transit. -
Target encryption key for hdwallet-controller and hdwallet-api - crypto-bundle-bc-wallet-tron-hdwallet Value with transit key name will be loaded from
VAULT_APP_ENCRYPTION_KEY
Vault variable, which stored in common bucket - crypto-bundle/bc-wallet-tron-hdwallet/common.
Implementation of HdWallet plugin must contains next exported functions:
NewPoolUnit func(walletUUID string, mnemonicDecryptedData string) (interface{}, error)
GenerateMnemonic func() (string, error)
ValidateMnemonic func(mnemonic string) bool
GetChainID() int
SetChainID(chainID int) error
GetSupportedChainIDsInfo() string
GetHdWalletCoinType() int
SetHdWalletCoinType(coinType int) error
GetSupportedCoinTypesInfo() string
GetPluginName func() string
GetPluginReleaseTag func() string
GetPluginCommitID func() string
GetPluginShortCommitID func() string
GetPluginBuildNumber func() string
GetPluginBuildDateTS func() string
Function NewPoolUnit must return implementation for interface
import (
pbCommon "github.com/crypto-bundle/bc-wallet-common-hdwallet-controller/pkg/grpc/common"
"google.golang.org/protobuf/types/known/anypb"
)
type WalletPoolUnitService interface {
UnloadWallet() error
GetWalletUUID() string
LoadAccount(ctx context.Context,
accountParameters *anypb.Any,
) (accountAddress *string, err error)
GetAccountAddress(ctx context.Context,
accountParameters *anypb.Any,
) (accountAddress *string, err error)
GetMultipleAccounts(ctx context.Context,
multipleAccountsParameters *anypb.Any,
) (accountCount uint, accountsList []*pbCommon.AccountIdentity, err error)
SignData(ctx context.Context,
accountParameters *anypb.Any,
dataForSign []byte,
) (accountAddress *string, signedData []byte, err error)
}
Examples of plugin implementations:
Repository of hdwallet-controller - bc-wallet-common-hdwallet-controller
Application must work in pair with instance bc-wallet-common-hdwallet-controller. For example in case of Tron blockchain: Instance of bc-wallet-common-hdwallet-controller - bc-wallet-tron-hdwallet-controller must work with instance of bc-wallet-common-hdwallet-api - bc-wallet-tron-hdwallet-api.
Communication between hdwallet-controller and hdwallet-api works via gRPC unix-file socket connection.
You can control socket file path by change HDWALLET_UNIX_SOCKET_PATH
environment variable.
Also, you can set target blockchain of hdwallet-controller and hdwallet-api via PROCESSING_NETWORK
env variable.
Full example of env variables you can see in env-api-example.env file.
Currently, support only kubernetes deployment flow via Helm
Application must be deployed as part of bc-wallet-<BLOCKCHAIN_NAME>-hdwallet bundle. Application must be started as single container in Kubernetes Pod with shared volume.
You can see example of HELM-chart deployment application in next repositories:
- bc-wallet-tron-hdwallet-api/deploy/helm/hdwallet
- bc-wallet-ethereum-hdwallet-api/deploy/helm/hdwallet
bc-wallet-common-hdwallet-api is licensed under the MIT NON-AI License.