<oembed><type>rich</type><version>1.0</version><author_name>npub17ty4mumkv43w8wtt0xsz2jypck0gvw0j8xrcg6tpea25z2nh7meqf4qgyd</author_name><author_url>https://nostr.ae/npub17ty4mumkv43w8wtt0xsz2jypck0gvw0j8xrcg6tpea25z2nh7meqf4qgyd</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2012-11-28&#xA;📝 Original message:The current spec is ambiguous in the case of what to do if the invoice&#xA;contains one output of a fixed amount and one or more outputs of an&#xA;unspecified amount. Should the user be prompted once per output? That&#xA;seems suboptimal. Prompted once for a value that&#39;s then randomly&#xA;distributed between all open-value outputs? It seems this ability of&#xA;the protocol is somewhat more complex than it appears. The ability to&#xA;have open outputs is nice for tips though.&#xA;&#xA;You could consider moving pki_type and pki_data into a separate&#xA;message and making both fields required, then making the pki message&#xA;optional. Otherwise you can have pki_type set but no data or&#xA;vice-versa. It doesn&#39;t make much difference in the end, just slightly&#xA;improves the automatic sanity checks produced by the proto compiler.&#xA;&#xA;w.r.t SIGHASH_ANYONECANPAY. I think it&#39;s best not to use this&#xA;routinely as it relaxes the signature checks in ways that may open&#xA;non-obvious holes when combined with other features. I thought we&#xA;pretty much had consensus on recursively calculating fees including&#xA;dependents in the memory pool?&#xA;&#xA;Peter is correct that there are a few degrees of freedom in protobuf&#xA;serialization, though far fewer than with JSON. I&#39;d like to think&#xA;upstream would be open to resolving these ambiguities.&#xA;Re-serialization of an Invoice message in the Payment message is a&#xA;potential source of mistakes. There&#39;s no need to ever concatenate&#xA;these messages and alternative implementations that don&#39;t order&#xA;serialized fields by tag number are missing an important optimization,&#xA;so they could be fixed. The main issue is treatment of unknown fields.&#xA;If/when the Invoice message is extended with other fields that are&#xA;round-tripped through an old client, the data may get lost. JSON&#xA;doesn&#39;t help resolve that either, of course. There are a few&#xA;solutions:&#xA;&#xA;1) Change the type of the Invoice field in Payment to be &#34;bytes&#34; and&#xA;set it to be the hash of the originally received binary Invoice&#xA;message. Downside, requires merchants to track all outstanding&#xA;invoices.&#xA;2) Ask protobufs upstream to modify the spec/implementations so&#xA;ordering of unknown fields is specified. The Python implementation&#xA;could be extended to support them so Python implementors don&#39;t end up&#xA;with accidental message downgrades.&#xA;3) Language of the spec could be changed to explicitly state that the&#xA;received Invoice may not be binary-identical to the one that was sent,&#xA;in the case of a client that incorrectly downgrades the message. Thus&#xA;you&#39;d be expected to check what the Invoice was using merchant_data&#xA;which is opaque and could just be, eg, a database key on your own end.&#xA;4) Instead of submitting the entire Invoice back to the merchant, just&#xA;the merchant_data could be in the Payment message.&#xA;&#xA;Of the four options I prefer the last. What is the use case for&#xA;resubmitting the entire invoice anyway? Even if protobufs are improved&#xA;so handling of round-tripping new messages through old [Python]&#xA;clients is more rigorous, some implementors will probably convert the&#xA;protobuf objects into some internal forms for whatever reason (or&#xA;serialize them to a database, etc) and they&#39;re very likely to mess up&#xA;the handling of unknown fields when they do it.</html></oembed>