Read the key's first character: 5 is an uncompressed Bitcoin key (51 characters), K or L a compressed one (52), and 64 hexadecimal characters a raw key that doesn't say which. Then sweep it into a wallet you already back up instead of importing it.
On a computer, Sparrow (Tools > Sweep Private Key) sweeps one address type at a time and Electrum (Wallet > Private keys > Sweep) one per prefix you paste; on a phone, BlueWallet's Import wallet checks all four types for you. Bitcoin Core 30 and later have no importprivkey: you wrap the key in combo() and tr() descriptors and load them with importdescriptors. MetaMask cannot import a Bitcoin private key at all.
If the balance shows zero, check first whether the wallet is showing a different address of the same key. A compressed key controls four addresses, one each starting with 1, 3, bc1q and bc1p, and the same number written as an uncompressed key belongs to a fifth, another address starting with 1.
| Starts with | Length | What it is | What to do |
|---|---|---|---|
| 5 | 51 | Bitcoin private key in WIF, uncompressed | One legacy address (1...). Sparrow, Electrum (no SegWit prefix), BlueWallet and Bitcoin Core's combo() take it; the ChainGate SDK does not (section 8). |
| K or L | 52 | Bitcoin private key in WIF, compressed | Four addresses: 1..., 3..., bc1q... and bc1p.... Pick the script type that holds the coins. |
| 0 to 9 and a to f (or A to F) only | 64 | Raw private key (hex) | No compression flag. BlueWallet tries both forms; other wallets need WIF (section 8). |
| 6P | 58 | BIP38 key, encrypted with a passphrase | Sparrow and BlueWallet ask for the passphrase and decrypt it. |
| S | 30 (22 on early Casascius coins) | Mini private key from a physical coin | One legacy address, uncompressed. Electrum accepts it. |
| p2pkh:, p2wpkh-p2sh: or p2wpkh: | 51 or 52 after the prefix | Electrum export: the key plus its address type | Electrum reads the prefix. Elsewhere, remove it and choose that type by hand. |
| c or 9 | 52 or 51 | Testnet key | Testnet coins have no value. |
| T, or 6u to 6w | 52 or 51 | Litecoin key | Use a Litecoin wallet, or importprivkey in Litecoin Core. |
| Q, or 6J to 6L | 52 or 51 | Dogecoin key | Use a Dogecoin wallet, or importprivkey in Dogecoin Core. |
| xprv (also yprv, zprv) | 111 | Extended private key: a whole HD wallet | Not a single key. Restore it as a wallet of the same script type to bring back the addresses it derived. |
1. One key, five addresses: what key number 1 shows
A Bitcoin address is built from the public half of the key and a script type, and one key fits several script types. The clearest example is the private key 1, the smallest number a key can be: everyone knows it, so it protects nothing. These are its five addresses, with what mempool.space showed for each on 28 November 2026:
| Address type | Address | Transactions | BTC received | Balance |
|---|---|---|---|---|
| Legacy, uncompressed key (P2PKH) | 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm | 1,475 | 7.84927386 | 0 |
| Legacy, compressed key (P2PKH) | 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH | 199 | 0.25034358 | 0 |
| Nested SegWit (P2SH-P2WPKH) | 3JvL6Ymt8MVWiCNHC7oWU6nLeHNJKLZGLN | 38 | 0.00063390 | 0 |
| Native SegWit (P2WPKH) | bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 | 247 | 0.04619200 | 0 |
| Taproot (P2TR) | bc1pmfr3p9j00pfxjh0zmgp99y8zftmd3s5pmedqhyptwy6lm87hf5sspknck9 | 21 | 0.02293657 | 0 |
Each address has its own history and balance, and the same key spends all five. Paste its compressed form into Electrum without a prefix and you see the 199 transactions of 1BgGZ9tc…, while the 247 transactions of bc1qw508… stay out of view.
Coins sent to a published key don't stay. Each of the last 12 payments to the bc1q address, the latest on 26 November 2026, and each of the last 12 to 1BgGZ9tc… was spent in the same block that confirmed it, so someone runs software that spends whatever reaches these addresses. A key typed into a website, a "private key to address" converter or a support chat can end up the same way. Don't send anything to these addresses, and work out your own key's addresses offline, with deriveaddresses in Bitcoin Core or the ChainGate SDK sample in section 8.
2. Sweep or import?
Sweeping sends the coins on the key's addresses to an address of your own wallet, and the key never joins the wallet. Most tools sweep one address type per transaction, so check every type the key has. Importing adds the key to a wallet, which then watches and spends from its addresses. Sweep unless the last case below describes you.
- Sweep when someone else could have seen the key.
- That covers a paper wallet printed by a website, a key sent by email or photographed, an export from a wallet you no longer control and a key someone gave you. Once swept, the key holds nothing, so a later leak costs nothing unless someone pays to its addresses again.
- Sweep when you want one backup.
- Electrum's FAQ says a wallet of imported keys "cannot be recovered from a seed", and Bitcoin Core's importdescriptors help says the call "requires a new wallet backup". Swept coins sit on addresses your recovery phrase already covers.
- Import only if the key is yours alone and the address has to stay.
- For example, it is printed on invoices or a donation page and payments still arrive. Then back up the key itself, offline, because your recovery phrase doesn't cover it.
A sweep is one ordinary transaction. With one coin and one output to a native SegWit address it comes to about 221 vB from an uncompressed legacy address, 189 vB from a compressed legacy one, 133 vB from nested SegWit, 110 vB from native SegWit and 99 vB from Taproot. Multiply by the rate on our Bitcoin fee tracker; each extra coin on the same address adds 180, 148, 91, 68 or 57.5 vB respectively.
3. Sparrow: sweep one script type at a time
Sparrow lets you step through the script types a key can have and sweep the one that holds the coins. It looks the coins up only when you press Create Transaction, and nothing is broadcast until you approve the transaction in the tab that opens. In Sparrow 2.5.7:
- Open the wallet that should receive the coins, connected to a public server or your own node.
- Choose Tools > Sweep Private Key and paste the key. The field takes WIF or a BIP38 key, and asks for the passphrase of a 6P key.
- Choose a Script Type. A compressed key offers Legacy (P2PKH), Nested Segwit (P2SH-P2WPKH), Native Segwit (P2WPKH) and Taproot (P2TR); an uncompressed key only Legacy. The Address field shows that type's address: if you know the address that received the coins, pick the type that matches it.
- Check Sweep to (an address of the open wallet, unless you type another), set the fee rate and press Create Transaction. If the address of that type holds nothing, Sparrow reports Insufficient funds with 0 sats: go back and try the next type. If it finds coins, it opens the signed sweep in a new tab, where you check the amount before you broadcast it. Connected to your own Bitcoin Core node, Sparrow asks for a date to scan from on each attempt.
Sparrow wants WIF, so convert a hex key first (section 8). If coins sit on more than one type, sweep each type in turn.
4. Electrum: sweep, or import with the right prefix
Electrum 4.8.4 reads the address type from a prefix written before the key, and a key without one counts as legacy; its own help puts it as "WIF keys are typed in Electrum, based on script type". The prefix applies to the sweep as much as to the import:
| Prefix | Address type | Key 1 (compressed) gives |
|---|---|---|
| None, or p2pkh: | Legacy (1...) | 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH |
| p2wpkh-p2sh: | Nested SegWit (3...) | 3JvL6Ymt8MVWiCNHC7oWU6nLeHNJKLZGLN |
| p2wpkh: | Native SegWit (bc1q...) | bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 |
To sweep, choose Wallet > Private keys > Sweep, paste the key, keep the destination address from your wallet and press Sweep. A key without a prefix sweeps only its legacy address and any pay-to-public-key outputs, so put the matching prefix in front of it, or, for a key that starts with K or L, paste it on three lines, once without a prefix, once with p2wpkh-p2sh: and once with p2wpkh:, to check all three types in one sweep. "No inputs found." means none of those addresses holds coins. Otherwise Electrum opens a New Transaction window: set the fee there, then press Preview to inspect the transaction or OK to sign and broadcast it.
Importing needs a wallet of its own, because Electrum cannot add a key to a wallet that has a seed: File > New/Restore, a new name, then Import Bitcoin addresses or private keys, with the same prefixes.
Electrum's code sets the limits. The SegWit prefixes reject an uncompressed key with "only compressed public keys can be used in segwit scripts". No Taproot prefix exists, so coins on a bc1p address need Sparrow, BlueWallet or Bitcoin Core, and hex keys are refused. A mini key from a Casascius coin works; Electrum's sweep checks both its uncompressed and compressed addresses.
5. Bitcoin Core 30 and later: importdescriptors
Bitcoin Core made descriptor wallets the default in version 23.0 (April 2022). Version 30.0, released on 10 October 2025, stopped loading legacy wallets and removed importprivkey, dumpprivkey, importaddress, importmulti and importwallet. Instructions that begin with importprivkey, including the RPC reference still online at developer.bitcoin.org, describe a wallet type current releases cannot open, and version 32.1 added no shortcut for a single key.
So the key goes inside descriptors. combo(KEY) stands for the key's pay-to-public-key outputs (an early format with no address), its legacy address and, when the key is compressed, its nested and native SegWit addresses; tr(KEY) stands for its Taproot address. For a key that starts with 5, use combo() alone: Bitcoin Core refuses tr() with an uncompressed key ("tr(): Uncompressed keys are not allowed"), and combo() already covers that key's only address. Import into a separate blank wallet, the kind whose "private keys and addresses can be imported using descriptors at a later time", as Bitcoin Core's Create Wallet dialog puts it. Type the commands one at a time: after each -stdin command, paste its line, press Enter, then Ctrl-D (Ctrl-Z and Enter on Windows).
# 1. A blank wallet for the key
bitcoin-cli createwallet "imported" false true
# 2. Checksums. -stdin reads the next line as the argument (finish with Ctrl-D),
# which keeps the key out of your shell history
bitcoin-cli -stdin getdescriptorinfo
combo(YOUR_WIF)
bitcoin-cli -stdin getdescriptorinfo
tr(YOUR_WIF)
# 3. Import both and rescan the whole chain (see the timestamp note below)
bitcoin-cli -rpcwallet=imported -stdin importdescriptors
[{"desc":"combo(YOUR_WIF)#CHECKSUM1","timestamp":0},{"desc":"tr(YOUR_WIF)#CHECKSUM2","timestamp":0}]
# 4. Send everything to your main wallet (FEE_RATE in sat/vB)
bitcoin-cli -rpcwallet=imported sendall '["YOUR_ADDRESS"]' null "unset" FEE_RATE
# 5. Unload the wallet and keep it from loading at startup: its file still holds the key
bitcoin-cli unloadwallet imported false- In the GUI, File > Create Wallet with Advanced Options > Make Blank Wallet does the same as step 1, and Window > Console runs the other commands once you pick the new wallet in its Wallet: selector. There, leave out bitcoin-cli and -stdin, and put each descriptor or JSON argument in single quotes, as in getdescriptorinfo 'combo(YOUR_WIF)', because the console reads parentheses and commas as part of its own syntax.
- If you encrypt the wallet, unlock it before importing and again before sendall, since the unlock expires. bitcoin-cli -rpcwallet=imported -stdinwalletpassphrase walletpassphrase 600 reads the passphrase from the keyboard, so it stays out of your shell history too.
- importdescriptors insists on checksums. Use the checksum field of each getdescriptorinfo result: the descriptor field shows the public version, which has a different checksum.
- The timestamp is the Unix time to rescan from. 0 scans the whole chain: slower, but it cannot miss old coins, so use it unless you know when the key first received bitcoin. A later time finds only payments made after it (1500000000 is 14 July 2017, too late for most keys that start with 5), and "now" skips the scan, so coins received before the import don't show up. The help warns that the call "can take over an hour" with an early timestamp and runs much faster on a node started with -blockfilterindex=1. A pruned node cannot rescan blocks it has deleted.
- The blank wallet has no addresses of its own, so getnewaddress answers "Error: This wallet has no available keys". That is expected, and sendall moves everything out without needing a change address.
- FEE_RATE is in sat/vB: take it from our Bitcoin fee tracker, and for a key someone else may have seen, pay for the next block.
- The wallet file still holds the key, unencrypted unless you encrypted the wallet, so step 5 unloads it and keeps it from loading at startup (in the GUI, File > Close Wallet).
bitcoin-cli's help recommends -stdin "for sensitive information". In the GUI's Window > Console the commands stay in its history until you close it.
Run getdescriptorinfo, deriveaddresses and importdescriptors only on your own node: a descriptor with the WIF in it is the key itself, and sending it to a public RPC endpoint hands over the coins. Only the public descriptor may go to someone else's node. To see the key's addresses before importing anything, run bitcoin-cli -stdin deriveaddresses and give it combo(YOUR_WIF)#CHECKSUM1 on the next line. It lists the legacy, native SegWit and nested SegWit addresses without touching a wallet, and tr(YOUR_WIF)#CHECKSUM2 gives the Taproot one.
To see what the key holds right now, with no wallet and no rescan (this also works on a pruned node), give scantxoutset the descriptor field of each getdescriptorinfo result, which contains only the public key, after the word start: bitcoin-cli scantxoutset start '["combo(PUBLIC_KEY)#CHECKSUM","tr(XONLY_KEY)#CHECKSUM"]'. It lists every unspent coin and the total; for our RPC endpoints guide it took 26 seconds on PublicNode's server, and your own node's time depends on its hardware.
If your node runs Bitcoin Knots, version 29.3 and later sweep a key in one step: File > Sweep private key in the GUI, or the sweepprivkeys RPC, which checks the key's pay-to-public-key, legacy, nested SegWit, native SegWit and Taproot outputs.
Litecoin Core 0.21.5.8, Dogecoin Core 1.14.9 and Bitcoin Cash Node 29.2.0 still have importprivkey: pass the key in that chain's format, a label, and true to rescan.
6. BlueWallet: the import that checks every type for you
BlueWallet 8.0.2, the latest release on its GitHub, for iPhone and Android, does that checking for you. Choose Add Wallet > Import wallet and paste the key. For a compressed WIF (K or L) it checks whether the native SegWit, Taproot, nested SegWit and legacy addresses were ever used, then offers each one with a history; if none was used, it adds all four. An uncompressed WIF (5) becomes a legacy wallet. A 64-character hex key gets the same check plus the uncompressed legacy address, all five if none was used, and a 6P key brings up its BIP38 password prompt. The result is a hot wallet on your phone, so send the coins on to your main wallet afterwards.
7. Zero balance after importing: check these in order
- The wallet shows another address type. Compare the address the wallet shows with the one that received the coins. If they differ, import again with the right prefix or script type, or sweep in Sparrow and step through the types.
- The coins are on the other form of the key. Some older wallets and paper wallets used uncompressed keys. From a hex key, make both WIF forms and try both; Electrum and Sparrow follow the 5, K or L of the WIF.
- The wallet never rescanned, or started too late. That happens in Bitcoin Core with "now" as the timestamp, with a timestamp after the key's first payment, or when a rescan was interrupted. Run rescanblockchain from a block height before the first payment, or import again with 0.
- It is a testnet key. Keys starting with c or 9 are testnet keys, whose coins have no value. The address gives it away too: testnet addresses start with tb1, m, n or 2.
- The coins were spent. Open the address on a block explorer. An outgoing transaction you didn't make means someone else had the key, and nothing brings those coins back.
- It is the wrong key. Every address of an HD wallet has its own key, and a key exported for one receiving address doesn't spend the next one. If none of the key's addresses ever received anything, look for the key that belongs to the address with the coins.
8. Hex keys, other chains and the ChainGate SDK
A hex key is the bare 32-byte number: no network byte, no compression flag, no checksum. Bitcoin Core descriptors, Electrum and Sparrow all want WIF, which adds those three in Base58Check. Don't put the hex key in a descriptor: inside tr() Bitcoin Core reads 64 hex characters as a public key and shows a Taproot address that is not yours. The script below converts offline with Node.js 18 or later and nothing else. It reads the key from the keyboard, so the key stays out of your shell history, and prints both forms because the hex doesn't say which one your wallet used:
// hex-to-wif.mjs: run offline with `node hex-to-wif.mjs` (Node.js 18 or later), then paste the key.
// Prints both WIF forms, because a hex key does not say which one was used.
import { createHash } from 'node:crypto';
import { createInterface } from 'node:readline/promises';
const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
const ORDER = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n;
const sha256 = (b) => createHash('sha256').update(b).digest();
function base58check(payload) {
const data = Buffer.concat([payload, sha256(sha256(payload)).subarray(0, 4)]);
let n = BigInt('0x' + data.toString('hex'));
let out = '';
while (n > 0n) { out = ALPHABET[Number(n % 58n)] + out; n /= 58n; }
for (const byte of data) { if (byte !== 0) break; out = '1' + out; }
return out;
}
const rl = createInterface({ input: process.stdin, output: process.stdout });
const hex = (await rl.question('Hex private key: ')).trim().replace(/^0x/i, '');
rl.close();
if (!/^[0-9a-fA-F]{64}$/.test(hex)) throw new Error('Expected 64 hexadecimal characters');
const k = BigInt('0x' + hex);
if (k === 0n || k >= ORDER) throw new Error('Not a valid secp256k1 private key');
const version = '80'; // Bitcoin and Bitcoin Cash. Litecoin: 'b0', Dogecoin: '9e'
console.log('Compressed WIF: ', base58check(Buffer.from(version + hex + '01', 'hex')));
console.log('Uncompressed WIF:', base58check(Buffer.from(version + hex, 'hex')));Litecoin, Dogecoin and Bitcoin Cash use the same kind of key. Bitcoin Cash even shares Bitcoin's version byte, 128, so a Bitcoin WIF works unchanged in a Bitcoin Cash wallet, where key 1's legacy address 1BgGZ9tc… is written bitcoincash:qp63uahgrxged4z5jswyt5dn5v3lzsem6cy4spdc2h. Litecoin uses 176 and Dogecoin 158, so the same 32 bytes make a different WIF: T33ydQRK… on Litecoin, with the address LVuDpNCSSj6pQ7t9Pv6d6sUkLKoqDEVUnJ, and QNcdLVw8… on Dogecoin, with DFpN6QqFfUm3gKNaxN6tNcab1FArL9cZLE. In the script, change '80' to 'b0' or '9e'.
If you build with the ChainGate SDK, importWallet takes the key as hex or WIF, and address() returns its legacy, native SegWit and Taproot addresses without any network call. Version 1.3.1 always derives from the compressed public key and has no nested SegWit (3...) type, so it cannot reach coins on an uncompressed key's address or on a 3... address; for those, use combo() in Bitcoin Core. Save the sample as addresses.mjs, run npm install [email protected], then disconnect from the network, run node addresses.mjs and paste the key when asked: address() needs no connection.
// addresses.mjs: npm install [email protected], then run `node addresses.mjs` and paste the key.
import { createInterface } from 'node:readline/promises';
import { ChainGate, importWallet } from 'chaingate';
const rl = createInterface({ input: process.stdin, output: process.stdout });
const key = (await rl.question('Private key (hex or WIF): ')).trim();
rl.close();
if (key.startsWith('5')) console.warn('Uncompressed key: these are its compressed-key addresses; use combo() in Bitcoin Core.');
const cg = new ChainGate();
const wallet = importWallet({ privateKey: key });
const btc = cg.connect(cg.networks.bitcoin, wallet);
for (const addressType of ['legacy', 'segwit', 'taproot']) {
console.log(addressType, await btc.address({ addressType }));
}
// The same key on Litecoin (legacy L... address) and Dogecoin
console.log(await cg.connect(cg.networks.litecoin, wallet).address({ addressType: 'legacy' }));
console.log(await cg.connect(cg.networks.dogecoin, wallet).address());Frequently asked questions
What is a WIF private key?
Wallet Import Format: the 32-byte private key written in Base58Check, with a version byte in front (128 for Bitcoin), an optional 01 byte after the key that marks it as compressed, and a 4-byte checksum at the end. That is why a Bitcoin WIF has 51 characters and starts with 5, or 52 characters and starts with K or L, and why a mistyped character is almost always rejected instead of opening the wrong wallet.
Can I import a Bitcoin private key into MetaMask?
No. MetaMask's Bitcoin support page says "Importing via private key is not yet supported for Bitcoin accounts"; its Bitcoin accounts come only from a 12 or 24-word recovery phrase, on the native SegWit path. Its Import an account screen does take a private key, but turns a hex key into a single Ethereum-style account: key 1 becomes 0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf there, and your bitcoin stays where it was. Sweep the coins to the bc1q address MetaMask shows instead.
Can I move a paper wallet key onto a Trezor?
Not as a key. Trezor's guide calls moving from a paper wallet "an advanced procedure" and says to sweep it with Electrum while the Trezor is connected, so the coins land on addresses from the Trezor's own seed. Electrum handles the key on your computer, so use a machine you trust and treat the paper key as spent afterwards.
Build with ChainGate
Put these ideas to work — ChainGate gives you wallets, transactions and managed RPC for Ethereum and 20+ other blockchains with one install.