Bit-Wasp/bitcoin-lib-php

Generating change address from publicKey Bip44, Bip43

AdamSEY opened this issue · 0 comments

I would like to generate change address from public key
that's my code:


$masterPriv = 'xprv9s21ZrQH143K2p33tm4NEgsJwb2sc2WQ6VHauuaMXqSnYfcQ66Q1WUTg8543XpSKZA3pKkfT9XrWT9yTCipj7rurAEkAKLrDnv2rQ4P7jic';
       $masterPub = 'xpub661MyMwAqRbcFJ7WznbNbpp3VcsN1VEFTiDBiHyy6AymRTwYddiG4Gn9yLoTFunHYrwwAEh4jA8XTeyVCwiWwkE4aNJzU8A5QvujoEy1bpN';
        $masterkey2 = HierarchicalKeyFactory::fromExtended($masterPriv);
        $public =  $masterkey2->derivePath("m/44'/0'/0'")->toExtendedPublicKey();
        $test =  HierarchicalKeyFactory::fromExtended($public);
        $address2 = $test->derivePath("m/0/0")->getPublicKey()->getAddress()->getAddress();


is changing 0 to 1 in the last line will return me "change address"?