How to get address type(format). Need to calculate vsize and fee Help me please. I need to calculate vsize and multiply it by the function result  estimatesmartfee.
To calculate vsize, I implement a formula like this https://jlopp.github.io/bitcoin-transaction-size-calculator/
byt i cannot getting address type from Bitcoin API.
Please tell me how to get the address type by API for implementing this formula?
P2PKH: Starts with &quot;1&quot;. Commonly known as &quot;Legacy Address&quot;. They have a known vbyte size. Size to spend is predictable.
P2SH: Starts with &quot;3&quot;. You would know if you made a P2SH address, since they're almost always involved with n-of-m multisig. Vary in size depending on how many parties are involved in the multisig. Size to spend is unknown unless the wallet you're spending from knows how to spend it or you created the transaction manually.
P2WPKH in P2SH: Starts with &quot;3&quot;. Commonly known as &quot;Segwit Address&quot;. Quickly becoming, if not already, the most common address type. They have a known vbyte size. Size to spend is predictable.
P2WSH in P2SH: Starts with &quot;3&quot;. Likewise with P2SH, you'd know if you made this type of address as it's involved in n-of-m multisig. Vary in size depending on how many parties are involved in the multisig. Size to spend is known unless the wallet you're spending from knows how to spend it or you created the transaction mnually.
P2WPKH: Starts with &quot;bc1q&quot;. Commonly known as &quot;Native Segwit Address&quot;. They have a known vbyte size. Size to spend is predictable.
P2WSH: Just like P2SH but starting with &quot;bc1q&quot; and much longer than a P2WPKH address.
P2TR: No idea what this is unfortunately. Looks like it stands for &quot;Pay 2 Taproot&quot;. But I admit that I don't know much about Taproot, and I don't think this has been implemented on mainnet yet.


Please tell me how to get the address type by API for implementing this formula?

I don't know what API you're referring to, but if you are running a Bitcoin Node you can run the command bitcoin-cli getaddressinfo &quot;YOUR_ADDRESS_HERE&quot; to get information about a particular address. Note that for addresses starting with &quot;3&quot;, you will not be able to determine if it is P2WPKH in P2SH vs. P2SH, as they are indistinguishable from each other until spent. They will both have &quot;isscript&quot;: true. For &quot;bc1q&quot; addresses, they will both have &quot;iswitness&quot;: true and P2WSH will also have &quot;isscript&quot;: true.