FIX: wont import WIF with uncompressed public key for segwit wallet

This commit is contained in:
Overtorment 2019-05-28 21:27:21 +01:00
parent f6b0822a43
commit 8e9015e2fb

View file

@ -26,6 +26,10 @@ export class SegwitP2SHWallet extends LegacyWallet {
try {
let keyPair = bitcoin.ECPair.fromWIF(this.secret);
let pubKey = keyPair.getPublicKeyBuffer();
if (!keyPair.compressed) {
console.warn('only compressed public keys are good for segwit');
return false;
}
let witnessScript = bitcoin.script.witnessPubKeyHash.output.encode(bitcoin.crypto.hash160(pubKey));
let scriptPubKey = bitcoin.script.scriptHash.output.encode(bitcoin.crypto.hash160(witnessScript));
address = bitcoin.address.fromOutputScript(scriptPubKey);