Issue locking unspent Output

+2 votes

Hi

I'm trying to lock an unspent output using the following request:

{
    "method":"preparelockunspentfrom",
    "params":[
        "{{address}}",
        0
    ],
    "id":1,
    "chain_name":"{{chain-name}}"
}

The response I'm getting is: 

{
    "result": null,
    "error": {
        "code": -709,
        "message": "Private key for from-address is not found in this wallet"
    },
    "id": 1
}

 

This is correct as I'm keeping the private keys elsewhere, so I'm confused as to how I can build a raw transaction without putting the key into the wallet, or is it I can't lock an output without the private key?

Thx

 

asked Jul 8, 2017 by marty

1 Answer

+1 vote

If all you want to do is lock an existing output, then use lockunspent. If you indeed want to prepare an output with a specific quantity, and then lock it, then you would use preparelockunspentfrom, but as you say it can't work with external private keys. For that you'll need to use more manual steps like this (assuming you want to prepare an empty output):

createrawsendfrom address {"address":0}

[then sign the returned raw transaction externally, or use signrawtransaction with the external private key]

sendrawtransaction signed-raw-tx

lockunspent false [{"txid":"txid-just-returned","vout":0}]

In the last command we know the vout=0 because we built the transaction ourselves in createrawsendfrom. For more information on using external private keys we recommend following this tutorial: http://www.multichain.com/developers/external-key-management/

answered Jul 8, 2017 by MultiChain
...