How to transfer native assets to sample-BitcoinWallet

+1 vote
I've got the sample-BitcoinWallet code from your repository working with multichain protocol after changes made to the handshaking.

The wallet is able to receive native currency and all transfers are smooth and working as expected. To make this useful for the community and everyone around (I'm planning to opensource), what changes do I need to make so that the wallet is also able to receive native assets and display it as well. Any documentation available on this?

Thanks
asked Sep 1, 2018 by jeshocarmel

1 Answer

0 votes
You can read data regarding the native assets in UTXOs using the documentation here:

https://www.multichain.com/developers/native-assets/

Of course, you also need to ensure that the wallet builds transactions that are valid in terms of native assets, by balancing the asset quantities across inputs and outputs.
answered Sep 3, 2018 by MultiChain
I've made the changes to my wallet and I'm able to get the outputs which are embedded in the OP_DROP metadata.

However the Per-output asset metadata currently sends the asset along with first 16 bytes of asset’s first issuance txid . Is there any way I could get the name of the asset without RPC?
Unfortunately there is currently no provision in the peer-to-peer protocol for getting the asset name based on the first 16 bytes of the txid. However if the lightweight wallet is given the issuance transaction (in which the asset name is set) from an untrusted source, it can independently confirm that this is the true asset name. To do this it would calcualte the transaction's hash and compare the first 16 bytes against those which appear in the UTXO's OP_DROP metadata.
Thanks for the info. One more question.

 When I send a native asset from my spv wallet, am I also required to include the asset info in the input and outputs of my transaction message ? Is it to be included in the OP_DROP metadata?
There's no need to add any special metadata in the input, but yes you do need to include the asset info in the outputs using OP_DROPs. Without this, the asset quantities won't balance between the outputs spent by the transaction, and the outputs created by it.
Thanks for the info. Is there any possibility to limit the maximum qty that can be transferred in a single transaction of native assets?
In MultiChain 2.0 (alphas) this can be achieved with Smart Filters. See this example: https://github.com/MultiChain/smart-filter-examples/blob/master/transaction-filters/limit-asset-transfer.js
...