-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#213 rough sketch of needed functionality as a discussion basis
- Loading branch information
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, ...) |
56 changes: 56 additions & 0 deletions
56
hd-wallet/src/main/java/com/bloxbean/cardano/hdwallet/HDWalletInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Amount> 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 | ||
|
||
} |