javascript function for prepareunlockspentfrom

+1 vote
i am trying to write a javascript function for prepareunlockspentfrom

it is giving me undefined object instead of giving txid and vout as a output.

I am using npm bitcoin package for nodejs.
//////FUNCTION

function preparelockunspentfrom(hex,assettype,assetqty)
{
    var myArray=[];
    var key = assettype;
    var obj = {};
    obj[key] = assetqty;
    myArray.push(hex);
    myArray.push(obj);

    console.log(myArray);
    client.cmd('preparelockunspentfrom',myArray,function(err,assets)
    {
        console.log(assets);
    });

}

preparelockunspentfrom("1Ebr8ExKnGQWhNukYwBqztMafZ1LvQZdCWQiHW","asset1",2);

////Output

root@kali:~/Desktop# nodejs blockchain.js
[ '1Ebr8ExKnGQWhNukYwBqztMafZ1LvQZdCWQiHW', { asset1: 2 } ]
undefined
asked Mar 10, 2016 by anonymous

1 Answer

0 votes

We're not experts in the npm bitcoin package, but looking at the JSON request output, I think the problem is that the asset name needs to be in quote marks, as a string.

In general you can use multichain-cli to test an API call and see the request which it outlines on the console, and then compare that format to what is being sent by whatever library you're using.

answered Mar 10, 2016 by MultiChain
...