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

Add support for Segwit, BIP49 #152

Open
i-rme opened this issue Sep 4, 2017 · 4 comments
Open

Add support for Segwit, BIP49 #152

i-rme opened this issue Sep 4, 2017 · 4 comments

Comments

@i-rme
Copy link

i-rme commented Sep 4, 2017

Add support for Segwit, for example being able to import BIP49 private keys and generate the corresponding Segwit public address.

@jaonoctus
Copy link

+1

@popenkomaksim
Copy link

I believe that https://github.com/bip32JP/bip32JP.github.io/tree/master/segwit could be reviewed and reused.

  function generateNewKeyPair(){
      var NETWORK = bitcoin.networks.bitcoin;
      var wif = bitcoin.ECPair.makeRandom({network: NETWORK}).toWIF();
      //var wif = "KyjcD49goTAdFgYj38gnvpwMa1vzaHLoKfJcDFgGr3fikun5DiqL";
      var keyPair = bitcoin.ECPair.fromWIF(wif, NETWORK);
      var pubKey = keyPair.getPublicKeyBuffer();
      var pubKeyHash = bitcoin.crypto.hash160(pubKey);
      var redeemScript = bitcoin.script.witnessPubKeyHash.output.encode(pubKeyHash);
      var redeemScriptHash = bitcoin.crypto.hash160(redeemScript);
      var scriptPubKey = bitcoin.script.scriptHash.output.encode(redeemScriptHash);
      var newaddy = bitcoin.address.fromOutputScript(scriptPubKey, NETWORK);
      return {
          wifPrivateK: wif,
          swAddress: newaddy
      };
  }

Site https://segwitaddress.org/ use this kind of functionality.

@vv01f
Copy link

vv01f commented Nov 7, 2018

also bech32 encoding of existing keys – needs (compressed) pubkey – would be a fine addition while providing encoding for segwit

@nandubatchu
Copy link

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

6 participants
@vv01f @popenkomaksim @i-rme @jaonoctus @nandubatchu and others