Skip to content

Commit

Permalink
#213 rough sketch of needed functionality as a discussion basis
Browse files Browse the repository at this point in the history
  • Loading branch information
Kammerlo committed Jan 16, 2024
1 parent b27589d commit 20a116d
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
25 changes: 25 additions & 0 deletions hd-wallet/specification.md
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, ...)
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

}

0 comments on commit 20a116d

Please sign in to comment.