Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

litecoin segwit prefix #641

Closed
AdamSEY opened this issue Feb 20, 2018 · 7 comments
Closed

litecoin segwit prefix #641

AdamSEY opened this issue Feb 20, 2018 · 7 comments

Comments

@AdamSEY
Copy link

AdamSEY commented Feb 20, 2018

Hi, I'm trying to implement Segwit with litecoin

   $p2wpkh = new ScriptHashAddress(WitnessProgram::V0($masterkey->derivePath("m/0/1")->getPublicKey()->getPubKeyHash())->getScript()->getScriptHash());
        
            $new_address = $p2wpkh->getAddress();

Response : 2Mt3WdMBvujypE8urmzGYnkXhw67MG22UrA

Now after importing this address to litecoin-core , sending some litecoin to that address and calling listtransaction I see transactions with the same amount to address start with Q

example: Qd1w2zEb3BBqCasjeZTe8N2EcdYmfzMih2

is that an expected behavior? I think we should add Segwit prefix to litecoin network

@AdamSEY
Copy link
Author

AdamSEY commented Feb 20, 2018

Take a look at this discussion here: litecoin-project/litecoin#312

@afk11
Copy link
Member

afk11 commented Feb 20, 2018

Sure, yep you're right. That's the P2SH prefix, I actually have a PR to fix that somewhere, maybe I'll get that merged for 0.0.35.

@AdamSEY
Copy link
Author

AdamSEY commented Feb 22, 2018

Thank you, hope you merge it soon.

@afk11
Copy link
Member

afk11 commented Mar 18, 2018

tagged in 0.0.34.4, and 0.0.35!

@afk11 afk11 closed this as completed Mar 18, 2018
@AdamSEY
Copy link
Author

AdamSEY commented Mar 20, 2018

Hi again, Sorry but I'm still getting the old P2SH format
2Mt3WdMBvujypE8urmzGYnkXhw67MG22UrA

Here's my code:

       $masterKey = HierarchicalKeyFactory::fromExtended($publicKey);
        $addressPath = $masterKey->derivePath("m/$changeAddress/" . $newIndex);
      $p2pkh = new PayToPubKeyHashAddress($addressPath->getPublicKey()->getPubKeyHash());
            $redeemScript = new P2shScript($p2pkh->getScriptPubKey());
            echo $redeemScript->getAddress()->getAddress();

            $p2wpkh = new ScriptHashAddress(WitnessProgram::V0($addressPath->getPublicKey()->getPubKeyHash())->getScript()->getScriptHash());
            echo  $p2wpkh->getAddress();

Both are returning addresses starts with '2'.

@afk11
Copy link
Member

afk11 commented Mar 21, 2018

Create a copy of the litecoin network, then pass it into $pwspkh->getAddress()

$network = NetworkFactory::litecoin()
echo $p2wpkh->getAddress($network);

@AdamSEY
Copy link
Author

AdamSEY commented Mar 22, 2018

Sorry, I forgot to attach this code:

  Bitcoin::setNetwork(NetworkFactory::litecoinTestnet());

I'm already setting the network globally. still getting the same result: Address starts with '2' instead of 'q'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants