diff --git a/hd-wallet/specification.md b/hd-wallet/specification.md new file mode 100644 index 00000000..04f27a0c --- /dev/null +++ b/hd-wallet/specification.md @@ -0,0 +1,25 @@ +# HD Wallet integration specification + +## Motivation + +Hierarchical deterministic wallets are a common practice in blockchains like Bitcoin and Cardano. +The idea behind that is to derive multiple keys (private and public) and addresses from a master key. +The advantage in contrast to individual addresses is that these keys/addresses are linked together through the master key. +Thus it is possible to maintain privacy due to changing public addresses frequently. +Otherwise one could track users through various transactions. + +Therefore it must be possible for users to use this concept via an easy-to-use API within this library. + +## Implementation + +- HDWallet Class + - Wrapper for Account - Deriving new Accounts with one Mnemonic + - Scanning strategy -> 20 consecutive empty addresses + - First Interface Approach [HDWalletInterface.java](src/main/java/com/bloxbean/cardano/hdwallet/HDWalletInterface.java) +- Transaction Building - extend QuickTxBuilder to use HDWallet + - Getting UTXOs to pay certain amount + - Getting Signers for the respective UTXOs spend in the transaction + - Build and Sign Transactions from HDWallet +- Minting Assets to a specific address +- Coin Selection Strategies + - Support common UTXO SelectionStrategys (Biggest, sequential, ...) \ No newline at end of file diff --git a/hd-wallet/src/main/java/com/bloxbean/cardano/hdwallet/HDWalletInterface.java b/hd-wallet/src/main/java/com/bloxbean/cardano/hdwallet/HDWalletInterface.java new file mode 100644 index 00000000..4a863606 --- /dev/null +++ b/hd-wallet/src/main/java/com/bloxbean/cardano/hdwallet/HDWalletInterface.java @@ -0,0 +1,56 @@ +package com.bloxbean.cardano.hdwallet; + +import com.bloxbean.cardano.client.account.Account; +import com.bloxbean.cardano.client.api.model.Amount; + +import java.util.List; + +public interface HDWalletInterface { + + private String mnemonic = ""; + +// public HDWalletInterface(Network network, String mnemonic); +// public HDWalletInterface(Network network); + + // sum up all amounts within this wallet + // scanning strategy is as described in specification.md + public List getWalletBalance(); + + /** + * Returns the account for the given index + * @param index + * @return + */ + public Account getAccount(int index); + + /** + * Creates a new Account for the first empty index. + * @return + */ + public Account newAccount(); + + /** + * Returns the stake address + * @return + */ + public String getStakeAddress(); + + /** + * returns the master private key + * @return + */ + public byte[] getMasterPrivateKey(); + + /** + * Returns the master public key + * @return + */ + public String getMasterPublicKey(); + + /** + * returns the master adress from where other addresses can be derived + * @return + */ + public String getMasterAddress(); // prio 2 + +}