I have waves full node on my server.
Using REST API I've generated a few addresses(like POST /addresses). With REST API I can get encoded seed for each of this address, for example
GET /addresses/seed/<address>
{
"address" : "address",
"seed" : "seed_value"
}
But to send money from those addresses I need a corresponding private key. So how can i get it?
Ok, as it turned out in this thread - https://forum.wavesplatform.com/t/question-about-addresses-endpoint/7752, each address is generated using the same seed with prepended bytesarray (for example: for a first address - [0x00, 0x00, 0x00, 0x00]).
Bytesarray is incremented after each address creation.
So, instead of using seed from addresses/seed/<address>
, had to use seed from wallet/seed
This one works in python(using pywaves)
import axolotl_curve25519 as curve
import base58
import hashlib
import sha3
import pyblake2
import struct
import pywaves
def hashChain(noncedSecret):
b = pyblake2.blake2b(noncedSecret, digest_size=32).digest()
return sha3.keccak_256(b).digest()
seed = "value from /wallet/seed"
nonce = struct.pack(">L", 40)
seedHash = hashChain(nonce + base58.b58decode(seed))
accountSeedHash = hashlib.sha256(seedHash).digest()
private_key = base58.b58encode(curve.generatePrivateKey(accountSeedHash))
address = pywaves.Address(privateKey=private_key)
P.S. I'm pretty sure that don't understand how address' seed must be interpreted/used "in the right way", but I didn't find any documentation related to this. If someone know how to use it - I will be really appreciated.