Open flufy3d opened 4 years ago
The public key (identity key) returned by the getPublicKey function should not be used for on-chain transactions. The Identity key can be used for such things as message encryption (ECIES), but if you are trying to send a payment to the user, you should not use getPublicKey.
You should not rely on the concept of an "address" in order to send a payment. In the future, people may choose to use different scripts aside from the P2PKH templates we've seen in the past. That is why Paymail deals with "outputs" (which can be any script that the recipient may choose) rather than just a simple address. When you are building your transaction, you should use the getOutputFor function that will give you a transaction output acceptable to the receiver of the transaction. Just take the output script and drop it into your transaction builder of choice (I like TxForge
, or just plain bsv@beta
), and you should be good to go!
Finally, if you are creating transactions, I strongly encourage you to look into delivering them P2P rather than broadcasting them. This will ensure that you are all set for the scalable future.
pls add api to get the public address related to paymail not just pubkey