getFee() method does not work

Continuing the discussion from Receiving the recipient Bitcoin address:

Hi @Armen_Chakhalyan, can you give more information about the code you’re trying to write, and what error you’re getting?

yes Can

var messages = new Messages();
var getdata = messages.GetData(message.inventory);

peer.on('tx', function(tx) {


The error you’re getting should explain this, but I’ll repeat it here for the record:
you can’t calculate a transaction’s fee without information about prior outputs. Specifically, a transaction does not contain information about amounts for the inputs. What you’re trying to do is not possible without a transaction database. You might benefit from a higher-level API such as insight-api or bitcore-node (in development)

You can call getFee when you’re building the Transaction yourself. In the future, we’re planning to add methods to Transaction that allow you to update it with information about prior outputs.

thank You very much Manuel. I have got following error.
throw new errors.Transaction.Input.MissingPreviousOutput();
No previous output information.
at Error.NodeError (/root/testBitcore/node_modules/bitcore/lib/errors/index.js:20:41)
I have use getFee() in previouse vertion Bitcore, they wos got fee.

and I have a another problem, саn You explain why to come following error?

throw new Error('The script type needs to be PayToPublicKeyHash or PayToScri
Error: The script type needs to be PayToPublicKeyHash or PayToScriptHash
at Script.toAddress (/root/testBitcore/node_modules/bitcore/lib/script/script.js:723:9)

That error is thrown when you want to show the address for a script which has no address associated. Only PayToPublicKeyHash or PayToScriptHash scripts can be associated to addresses, other custom scripts may not result in an address. For more info read about bitcoin addresses:

Thank you Manuel, is there any workaround to avoid this error?