2

I am creating a project and would like to be able to give new addresses for each transaction to simplify tracking of payments. I need a method to create a new payment address similar to the below question but in Java.

How can i generate new wallet address using cardano-wallet cli and cardano wallet api after created my wallet?

Currently I am using Blockfrost Api Java SDK and cardano-client-lib but neither are able to create a new payment address from what I can tell.

I would like to avoid needing to run Cardano-cli and JNI (no experience) if possible.

2
  • @samuelleathers put in time and effort to answer your question. If you want to keep getting good answers, don't forget to vote an answer up when you accept it. :-)
    – gRebel
    Commented Jan 23, 2022 at 0:04
  • A better question might have been, "How can I create a new payment address using the Blockfrost Java API"
    – gRebel
    Commented Jan 23, 2022 at 0:10

2 Answers 2

1

A payment address is just the hash of the payment pubkey (and optionally the stake pubkey if that addresses funds will delegate) with some prefixed bytes that indicate what type of address it is. The payment secret keys can either be randomly generated (such as how cardano-cli address key-gen works), or can be derived from a wallet root private key (which usually has an associated mnemonic to generate the root private key).

If your app doesn't need to use a full wallet, you can generate random bytes, convert that to a pubkey, get the payment key hash and assemble an address.

If your app does use a wallet, you would generate keys under the derivation path: 1852H/1815H/0H/0/$i using cardano-addresses, and then the rest of the steps are exactly the same, but using the bytes derived rather than randomly generated.

If you go the random generation route, please ensure you have many backups of every secret key you generate, otherwise if the keys are lost, those funds are completely unspendable!

2
  • Between this answer and github.com/uniVocity/cardano-tutorials/blob/master/…. I get the process from a high level using cardano-address but what happens during the hashing process and can this be easily easily implemented if I have the root pub key and the derivation path?
    – g0atm1lk
    Commented Jan 12, 2022 at 11:43
  • You need the account pub key. Any derivations followed by H are hardened and need the private key to derive. Commented Jan 17, 2022 at 2:38
1

You could use Blockfrost API to create a new address. Please refer here.

2
  • Thanks for the reply. That would be perfect if it was implemented in the Java SDK. However it still might be a better alternative than running a node like I was thinking of doing.
    – g0atm1lk
    Commented Jan 12, 2022 at 10:54
  • Blockfrost has a Java SDK too github.com/blockfrost/blockfrost-java Commented Jan 15, 2022 at 6:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.