publishing to a stream with an address not in the wallet

+2 votes

Hi Multichain folks,

I've been looking at the raw transactions API and I'm trying to publish to a stream using an address that is not in the wallet? 

Currently I'm using this method but happy to know if there are better ways out there:

A. I want to use 1ZCArdJL4DuUx9q6qbzUKK2xdSxbtmXJzzi3Lo to publish to the root stream. 1ZCArdJL4DuUx9q6qbzUKK2xdSxbtmXJzzi3Lo is NOT in the node wallet

B. I send an empty output from 1MmDPC4p7rpmzuSJBXQzLkHAdvVerk8diq7Ydh which is in the node wallet using:

createrawsendfrom 1MmDPC4p7rpmzuSJBXQzLkHAdvVerk8diq7Ydh '{"1ZCArdJL4DuUx9q6qbzUKK2xdSxbtmXJzzi3Lo":0}' '[]' sign

sendrawtransaction [trxn-hex]

C. Then I use the transaction ID and vout as inputs for 1ZCArdJL4DuUx9q6qbzUKK2xdSxbtmXJzzi3Lo to write to the stream:

createrawtransaction '[{"txid":"...","vout":0}]' '{}' '[{"for":"root","key":"some_key2","data":"7B226D65737361676522203A2022546869732069732061206D65737361676520696E206120626F74746C6521227D"}]' sign

signrawtransaction [trxn-hex] '[]' '["..."]'

sendrawtransaction [trxn-hex]

Is there a better way to do this?

asked Oct 25, 2017 by StevenChan

1 Answer

+2 votes

Your method is fine, but if you'll be doing this regularly from that address, you'll save effort by using importaddress to import that address into the node's wallet (without its private key). In that case you can use createrawsendfrom to build the stream publishing transaction in a single step.

FYI all of this is documented throughly on these pages:

https://www.multichain.com/developers/external-key-management/

https://www.multichain.com/developers/raw-transactions/

As a final comment, in any event step B can done in a single step by using the send keyword with createrawsendfrom.

answered Oct 25, 2017 by MultiChain
...