mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-23 07:15:35 +01:00
FIX: wont import WIF with uncompressed public key for segwit wallet
This commit is contained in:
parent
f6b0822a43
commit
8e9015e2fb
1 changed files with 4 additions and 0 deletions
|
@ -26,6 +26,10 @@ export class SegwitP2SHWallet extends LegacyWallet {
|
||||||
try {
|
try {
|
||||||
let keyPair = bitcoin.ECPair.fromWIF(this.secret);
|
let keyPair = bitcoin.ECPair.fromWIF(this.secret);
|
||||||
let pubKey = keyPair.getPublicKeyBuffer();
|
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 witnessScript = bitcoin.script.witnessPubKeyHash.output.encode(bitcoin.crypto.hash160(pubKey));
|
||||||
let scriptPubKey = bitcoin.script.scriptHash.output.encode(bitcoin.crypto.hash160(witnessScript));
|
let scriptPubKey = bitcoin.script.scriptHash.output.encode(bitcoin.crypto.hash160(witnessScript));
|
||||||
address = bitcoin.address.fromOutputScript(scriptPubKey);
|
address = bitcoin.address.fromOutputScript(scriptPubKey);
|
||||||
|
|
Loading…
Add table
Reference in a new issue