electrum: Why will not the shipment be received from the same wallet to your P2SH address?

There is something I did not understand about the different address formats. In summary: I create a master key, I import it through xprv-Key in Electrum, I generate P2SH and P2WSH-Adresses, I send coins but they do not appear.

  1. I created an extended key in the testnet with Bitwasp: tprv8ZgxMBicQKsPd1Euv7Q428UserpbDf6mxhRtjevgfPcL4XwU8aNAXqMp6QAQjPU5bCeskWBUtqZYS1UHRYQuYzrcZFppbsS2JgWjUz.

  2. I have imported this key in Electrum also running on testnet.

  3. Clicking on "Receive" tells me the following address: n28hWyXh8VPBCV6seKty19dW5ZNbqapB58
  4. I have sent some testnet coins to this address, which became visible in Electrum very fast.

  5. Using the BitWasp library, I wrote the following code (inspired by the proper sample code:

                                $ network = Bitcoin :: setNetwork (NetworkFactory :: bitcoinTestnet ());

$ random = new Random ();
$ hdFactory = new HierarchicalKeyFactory ();

$ master = $ hdFactory-> fromExtended ("tprv8ZgxMBicQKsPd1Euv7Q428UserpbDf6mxhRtjevgfPcL4 & # 39; & # 39;


$ addrReader = new AddressCreator ();
$ publicKey = $ master-> getPublicKey ();
$ helper = new P2pkhScriptDataFactory ();
$ scriptData = $ helper-> convertKey ($ publicKey);
$ script = $ scriptData-> getScriptPubKey ();

echo "key hash types  n";
$ p2pkh = $ scriptData-> getAddress ($ addrReader);
echo "* p2pkh address: {$ p2pkh-> getAddress ()}  n";

echo " nscript hash types:  n";

$ redeemScript = new P2shScript ($ p2pkh-> getScriptPubKey ());
$ p2shAddr = $ redeemScript-> getAddress ();
echo "* p2sh: {$ p2shAddr-> getAddress ()}  n";
$ p2wshScript = new WitnessScript ($ p2pkh-> getScriptPubKey ());
$ p2wshAddr = $ p2wshScript-> getAddress ();
echo "* p2wsh: {$ p2wshAddr-> getAddress ()}  n";
$ p2shP2wshScript = new P2shScript (new WitnessScript ($ p2pkh-> getScriptPubKey ()));
$ p2shP2wshAddr = $ p2shP2wshScript-> getAddress ();
echo "* p2sh | p2wsh: {$ p2shP2wshAddr-> getAddress ()}  n";

It gives me the following output:

WIF: cUhtBXtsVhSikXiD46B5dKsCTjKqZGTWEADxSMNknP1V6VZfm1zR
key hash types
* Address p2pkh: mjCptm7yxr3c7DpA6i17ude5ZkiHQMz7Rr

types of script hash:
* p2sh: 2MsjH4FEdpcwmwaTtbW3HFnx8aw1DCfN74G
* p2wsh: tb1qnwsk39m5yw4m3h36ddvw9euvl0vxl7vg8mrmyj777pwl74crkassxgg7l2
* p2sh | p2wsh: 2NFS1fXMuAJuJWaGAwMi7puE86n5XnbLEPo
  1. Why is the Reception Address in Electrum so different from the ones I generated with the Bitwasp Library? None of the addresses generated is similar to the address of Electrum
  2. Sending coins to the Electrum address will show the coins received
  3. Sending coins to P2shScript-Address for example (2MsjH4FEdpcwmwaTtbW3HFnx8aw1DCfN74G) will never appear in the Electrum-Wallet, even if they are based on the same private key
    I have also tried sending coins to the p2wsh address (tb1qnwsk39m5yw4m3h36ddvw9euvl0vxl7vg8mrmyj777pwl74crkassxgg7l2), which also never receives any currency that was sent to.

Where is my error?