0 value transaction

+1 vote
Hi, can I send transactions with 0 value and no assets as a form of messaging?

I tried to create such a transaction:

createrawtransaction '[{"txid":"dff5d4f237d38f9fc61f21b306186463b8d4ced58c0b5e109070dbb2cda95284","vout":0}]' '{"1GsPTng4yMsLQ3thF71jrYCUaxdZVDKvScgPdg":0,"12DmW3z4iHj4uCEMmeZLkQmTkrbmwQAzbto2f7":0}'

then append the message:

appendrawmetadata 01000000018452a9cdb2db7090105e0b8cd5ced4b863641806b3211fc69f8fd337f2d4f5df0000000000ffffffff0200000000000000001976a9147569637dc6eaceeabd35db9b8f07ef6d7627530688ac00000000000000001976a914090711c967626febefbf7c8ff3fdcced4f08a9f488ac00000000 344d56516737565172344539484b544e7a6e62715a4a4848316f37706369626e56374d716472

which resulted in the following transaction:

{
    "txid" : "27f4d6a0d109e43811971caba936324ac54d2ab972fd5a2db6d745c4482cf416",
    "version" : 1,
    "locktime" : 0,
    "vin" : [
        {
            "txid" : "dff5d4f237d38f9fc61f21b306186463b8d4ced58c0b5e109070dbb2cda95284",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "",
                "hex" : ""
            },
            "sequence" : 4294967295
        }
    ],
    "vout" : [
        {
            "value" : 0.00000000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 7569637dc6eaceeabd35db9b8f07ef6d76275306 OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "76a9147569637dc6eaceeabd35db9b8f07ef6d7627530688ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "1GsPTng4yMsLQ3thF71jrYCUaxdZVDKvScgPdg"
                ]
            },
            "assets" : [
            ],
            "permissions" : [
            ]
        },
        {
            "value" : 0.00000000,
            "n" : 1,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 090711c967626febefbf7c8ff3fdcced4f08a9f4 OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "76a914090711c967626febefbf7c8ff3fdcced4f08a9f488ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "12DmW3z4iHj4uCEMmeZLkQmTkrbmwQAzbto2f7"
                ]
            },
            "assets" : [
            ],
            "permissions" : [
            ]
        },
        {
            "value" : 0.00000000,
            "n" : 2,
            "scriptPubKey" : {
                "asm" : "OP_RETURN 344d56516737565172344539484b544e7a6e62715a4a4848316f37706369626e56374d716472",
                "hex" : "6a26344d56516737565172344539484b544e7a6e62715a4a4848316f37706369626e56374d716472",
                "type" : "nulldata"
            },
            "assets" : [
            ],
            "permissions" : [
            ]
        }
    ],
    "data" : [
        "344d56516737565172344539484b544e7a6e62715a4a4848316f37706369626e56374d716472"
    ]
}

which is cool, but when I tried to sign it I received the following response:

{
    "hex" : "01000000018452a9cdb2db7090105e0b8cd5ced4b863641806b3211fc69f8fd337f2d4f5df0000000000ffffffff0300000000000000001976a9147569637dc6eaceeabd35db9b8f07ef6d7627530688ac00000000000000001976a914090711c967626febefbf7c8ff3fdcced4f08a9f488ac0000000000000000286a26344d56516737565172344539484b544e7a6e62715a4a4848316f37706369626e56374d71647200000000",
    "complete" : false
}

Multichain marked the txn as incomplete and when I tried to publish the txn I received the error:

error: {"code":-26,"message":"64: Tx with metadata should have at least one SIGHASH_ALL output"}

Can you help me how to do this? Thanks a lot
asked Nov 16, 2015 by wmiki

2 Answers

0 votes
Does your node have the private key for the address in the transaction output you are spending? If not, that looks like the most simple explanation. It should definitely be possible to send transactions with no value, and metadata only.
answered Nov 16, 2015 by MultiChain
Thanks for your answer! No, actually those addresses are on another nodes. How can you have their private keys on the sending node?
Why not just use the node on which the corresponding private key is held? It's also possible to export/import private keys between nodes using dumpprivkey and importprivkey.
Let's assume that one party (buyer) wants to send a message to the other party (seller) about the transaction he's created. The two parties are on different nodes and the private keys cannot be shared between them.
What's your advice for this scenario?
Start by using preparelockunspent on the sender to create a transaction output containing zero assets, and then use the returned txid/vout as the input for createrawtransaction. FYI shortly there will be an easier way to send transactions with metadata.
Thanks it works like a charm if I start with preparelockunspent command! I appreciate your support! Thanks a lot
0 votes

You may be interested that alpha 12 adds new sendwithmetadata and sendwithmetadatafrom APIs that make all this a lot easier. You can use 0 for the amount parameter to embed metadata with no value.

answered Nov 26, 2015 by MultiChain
...