## Send payment and message at the same time

1

I am using NBitcoin to write some code. I want to send some bitcoin to an address AND include a message with it. The message could say who the payment came from or why it was sent. According to the demos, a txOut can have a destination or a message but not both. Both are stored in the ScriptPubKey.

Edit. Someone suggested I could use two Outputs, one for the payment and one for the message, but that doesn't seem to suggest there is a link between the two.

What do you mean with "message"? Are you talking about an OP_RETURN? – Murch – 2019-10-22T15:08:14.117

I mean this https://programmingblockchain.gitbook.io/programmingblockchain/bitcoin_transfer/spend_your_coin#message-on-the-blockchain a note relating to that payment.

– ThirdPrize – 2019-10-22T18:28:41.223

Okay, I had a look and what you linked appears to refer to an OP_RETURN, so I added the tag. What you state is correct, you can either send an amount to an address in an output, or send an OP_RETURN. You would need to create two outputs, one to send the bitcoins, one to create the OP_RETURN. Was that your question? Could you please edit your question post to clarify what your question is? – Murch – 2019-10-22T21:26:51.557

1Warning: Make sure to include the amount in a different output than the message. Do not include the amount you wish to send in the OP_RETURN output or you'll burn all the BTC in that output. – Jose Fonseca – 2019-10-23T02:19:42.237

Edited. So there is no way of including a comment in an payment? That's a bit naff. – ThirdPrize – 2019-10-23T09:45:04.557

0

That's correct, you'd need to create two separate outputs. OP_RETURN and payment outputs are two different output types that cannot be combined. I don't know what you're trying to do, but generally, it should be unnecessary to provide a comment with a payment. All the payment related communication would already have been done out of band with the recipient finally providing an invoice address. Given the payer sending the payment to that invoice address, the payment is clearly associated with the invoice.

Note that any bitcoins included in the OP_RETURN output are burned and become unspendable. (H/T Jose Fonseca)

My idea was for an on chain tipping system. I want to send your public address 0.00001 btc for this cool answer. I also want some way of you tracing it back to me and/or me telling you which answer it was i'm tipping for. It's only polite. And, it seems, impossible. – ThirdPrize – 2019-10-23T16:18:42.803

@ThirdPrize It's not impossible at all. You can simply use OP_RETURN as indicated, but it is generally unnecessary. Addresses should not be reused so the recipient should give you a unique address. If you send bitcoins, they know it was you. A third option is to sign a message using the private key corresponding to the address you are sending from (if it is just one address). Then send that to the person you want to prove the payment to (via email, etc).

– Jonathan Cross – 2019-10-23T16:47:10.573

Yeah, I agree with Jonathan. The message could just be posted off-chain and each post could have a separate address. Also, note that 1,000 sats are less than one magnitude greater than the cost of spending 1,000 sats. Transaction fees are likely cost-prohibitive for on-chain tipping (at least on Bitcoin). – Murch – 2019-10-23T21:39:13.810