Bitcoin Forum
June 15, 2025, 12:06:57 PM *
News: Latest Bitcoin Core release: 29.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Script Types in Electrum and Their Role in Sender-Side Silent Payments (BIP352)  (Read 80 times)
MorenoBtc (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
March 28, 2025, 03:30:18 PM
 #1

Hi everyone,

As part of a university project, I’m working on adding sender-side Silent Payment (BIP352) support to Electrum, and I’d like to confirm some wallet behavior details to ensure a robust implementation.

Silent Payments require the sender’s inputs to be of certain script types, namely:

   - P2PKH
   - P2WPKH
   - P2SH-P2WPKH
   - P2TR

These are necessary because the recipient derives a shared secret from the sender’s public key, which isn't easily feasible with more complex or non-standard scripts.

To simplify integration, I’m trying to confirm the following:
  • 1. When creating a standard Electrum wallet, is the script type (e.g. P2WPKH or P2PKH) fixed for the life of the wallet?
    Can I assume all UTXOs in such a wallet will always be of the same script type? That would allow Silent Payment eligibility to be determined at the wallet level, rather than checking each input individually.
  • 2. If a user creates an imported wallet (e.g. by adding multiple private keys), can that wallet end up containing spendable UTXOs of mixed script types?
    For example, importing one key for a P2PKH UTXO and another for a P2WPKH UTXO — will Electrum treat both as spendable in the same wallet instance?
  • 3. Which script types does Electrum generally support spending from? And does it vary based on the Wallet Type (standard, 2fa...)


Thanks in advance!

Cheers!
nc50lc
Legendary
*
Offline Offline

Activity: 2814
Merit: 7305


Self-proclaimed Genius


View Profile
March 29, 2025, 03:44:03 AM
Merited by pooya87 (4)
 #2

To simplify integration, I’m trying to confirm the following:
  • 1. When creating a standard Electrum wallet, is the script type (e.g. P2WPKH or P2PKH) fixed for the life of the wallet?
    Can I assume all UTXOs in such a wallet will always be of the same script type? That would allow Silent Payment eligibility to be determined at the wallet level, rather than checking each input individually.
  • 2. If a user creates an imported wallet (e.g. by adding multiple private keys), can that wallet end up containing spendable UTXOs of mixed script types?
    For example, importing one key for a P2PKH UTXO and another for a P2WPKH UTXO — will Electrum treat both as spendable in the same wallet instance?
  • 3. Which script types does Electrum generally support spending from? And does it vary based on the Wallet Type (standard, 2fa...)
  • 1. Yes, when the wallet is created by Electrum, its seed phrase defines the script type that the wallet should derive from the seed (check "seed version system"),
    It'll not create other script types within the same wallet.

  • 2. Yes, private key(s) can be prefixed with the user's preferred script type. All associated UTXO will be available in the 'Coins' tab to spend.

  • 3. It can generate transaction (PSBT) with input of any script type including TapRoot but it doesn't natively support TapRoot script yet, it has to be signed elsewhere.
    Also P2PK is limited to its "Sweep" feature.
    For now, it fully supports P2PKH, P2SH (old 2FA/MultiSig), P2WPKH (default), P2WSH (2FA/MultiSig)scripts;
    It's worth mentioning that newly created wallets without using commands are limited to SegWit and imported BIP39 seed can be restored with any script types.

MorenoBtc (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
March 29, 2025, 04:14:33 PM
 #3

Thanks, I checked out Electrum Seedphrase Docs already before, but I found it somewhat ambiguous.
For example, it says the type "standard" is used for P2PKH and Multisig P2SH wallets and The type "segwit" is used for P2WPKH and P2WSH wallets. So the version number doesn't determine the script type unambiguously?

I created a (standard) wallet for testing purposes and when I click on wallet/information, it displays:

  • Wallet type: standard
  • Script type: p2wpkh

During creation process, I was never asked to choose a script type. So when selecting "standard Wallet", will the script type always be p2wpkh? And within the 'Coins' tab, or calling 'listunspent()' will it display uTxo's with p2wpkh-outputs only? That would simplify the implementation, at least for standard wallets.

Thanks!
Forsyth Jones
Legendary
*
Offline Offline

Activity: 1568
Merit: 1448


I love Bitcoin!


View Profile WWW
March 30, 2025, 07:10:31 PM
 #4

Thanks, I checked out Electrum Seedphrase Docs already before, but I found it somewhat ambiguous.
For example, it says the type "standard" is used for P2PKH and Multisig P2SH wallets and The type "segwit" is used for P2WPKH and P2WSH wallets. So the version number doesn't determine the script type unambiguously?

I created a (standard) wallet for testing purposes and when I click on wallet/information, it displays:

  • Wallet type: standard
  • Script type: p2wpkh

During creation process, I was never asked to choose a script type. So when selecting "standard Wallet", will the script type always be p2wpkh? And within the 'Coins' tab, or calling 'listunspent()' will it display uTxo's with p2wpkh-outputs only? That would simplify the implementation, at least for standard wallets.

Thanks!
When creating an Electrum wallet, a wallet with a 'p2wpkh' script is created by default, which is of the native segwit type.

Electrum will never mix script/address types, regardless of whether it's a standard (p2pkh) or native segwit (p2wpkh) wallet (unless it's of the imported type, where the user can import any singlekey type script through the prefix). This is guaranteed by the electrum seed version, which includes versioning in the seed itself. The same goes for UTXOs that appear in the "coins" tab or via listunspent(). You will only see UTXOs of the script type belonging to the wallet, e.g. p2wpkh.

Each version number (e.g. 0x100 = Segwit, p2wpkh and p2wsh types) is directly associated with a specific script type.

The term standard is just to label single-sig wallets (non-multisig single signature), but the script type of the addresses generated in the wallet depends on the version number of the seed which will result in a specific script type for each wallet separately when importing/creating a seed in electrum.

Summary:

Standard wallet = wallet with addresses derived from a seed, independent of the script/seed version used. A wallet that generates addresses deterministically(HD Wallet).

Imported wallet: can import private keys using the prefix followed by the private key to derive the desired script type:

Code:
p2pkh: generates legacy addresses
p2wpkh-p2sh: generates segwit-compatible address
p2wpkh: generates native segwit address.

nc50lc
Legendary
*
Offline Offline

Activity: 2814
Merit: 7305


Self-proclaimed Genius


View Profile
March 31, 2025, 05:15:32 AM
 #5

-snip- but I found it somewhat ambiguous.
For example, it says the type "standard" is used for P2PKH and Multisig P2SH wallets and The type "segwit" is used for P2WPKH and P2WSH wallets. So the version number doesn't determine the script type unambiguously?
That's because the seed used in Single-sig and MultiSig wallets are of the same type,
So if the seed version is for Segwit, it can be used to create both Standard SegWit wallet and MultiSig SegWit wallet.
However, Electrum doesn't allow the creation of both P2WSH and P2WPKH scripts within the same wallet, each has to be created separately.
So, a Single-Sig wallet can only contain single sig script representation of the version number and a separate MultiSig wallet will contain only MultiSig scripts representation of the version number.

During creation process, I was never asked to choose a script type. So when selecting "standard Wallet", will the script type always be p2wpkh? And within the 'Coins' tab, or calling 'listunspent()' will it display uTxo's with p2wpkh-outputs only? That would simplify the implementation, at least for standard wallets.
In that particular test standard wallet, yes.
For the script type option during wallet creation, they've removed it since release version 4.1.0 and defaults to SegWit
But power-users can still create legacy wallets using commands (mentioned in my note) so it's still necessary to support P2PKH.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!