BlockPo / BlockPo-to-Tradelayer

Incubation Repo for the TradeLayer protocol, 0.2.0
http://www.tradelayer.org
Other
8 stars 8 forks source link

Send To Many #455

Closed patrickdugan closed 2 years ago

patrickdugan commented 3 years ago

In the current tx defintions, the vIn 0 is always considered the "Sender" of a tx and the vOut 1 is considered the Reference Address, with the OP_Return output coming last.

The Send To Many tx type will allow a user to pay a series of amounts to reference adderesses 1 - n where 1 = vOut 1 and N = vOut x - 1 where X is the vOut # of the Op_Return.

The payload would look like (plaintext/uncompressed):

"tl"; txid (this will be an integer we assign to this new tx type); propertyid; amount1; amount 2, amount 3 etc. up to 4.

The tl marker is 2 bytes, the tx integer could be 2 bytes, the property id is 4 bytes, and each amount integer is going to be 8 bytes. We have about 32 bytes to work with, so making room for exactly 4 sends. However if the tx integer is not a short integer, maybe we can modify it to be 2 bytes for this tx.

Of course it's pathetic that we can't batch sends (e.g. for exchange or Layer 2 withdrawals) beyond 4 outputs, because of short-sighted OP_Return limits, at least in the Bitcoin version it will be another 5 sends for a total of 9.

One day we'll get the threshold raised on LTC and then BTC, it's just better math for the efficiency of blockchain usage.

This feature will need a tx RPC to use and also a raw payload RPC for use with raw transaction building.

This is assigned to Sinetek but formally to Blockpo.

sinetek commented 3 years ago

What's the reason for the OP_Return limit of 4 sends?

sinetek commented 3 years ago

What's the reason for the OP_Return limit of 4 sends?

Yes, because we're packing everything in a 32-byte field.

sinetek commented 3 years ago

Something like this??

+std::vector<unsigned char> CreatePayload_ManySend(
+               uint32_t propertyId,
+               std::vector<uint64_t> amounts)
+{
+    std::vector<unsigned char> payload;
+
+    uint64_t messageType = 0;  /// XXX
+    uint64_t messageVer = 0;   /// XXX
+
+    std::vector<uint8_t> vecMessageType = CompressInteger(messageType);
+    std::vector<uint8_t> vecMessageVer = CompressInteger(messageVer);
+    std::vector<uint8_t> vecPropertyId = CompressInteger((uint64_t)propertyId);
+
+    /*
+     * We can now check if there is sufficient room for the amounts..
+     */
+    if (amounts.size() > 4) {
+       throw ;
+    }
+
+    payload.insert(payload.end(), vecMessageVer.begin(), vecMessageVer.end());
+    payload.insert(payload.end(), vecMessageType.begin(), vecMessageType.end());
+    payload.insert(payload.end(), vecPropertyId.begin(), vecPropertyId.end());
+
+    for (auto amount: amounts) {
+        std::vector<uint8_t> vecAmount = CompressInteger(amount);
+        payload.insert(payload.end(), vecAmount.begin(), vecAmount.end());
+    }
+
+    return payload;
+}
patrickdugan commented 3 years ago

Correct.

On Thu, Apr 29, 2021 at 1:08 PM Philippe Michaud-Boudreault < @.***> wrote:

Something like this??

+std::vector CreatePayload_ManySend(

  • uint32_t propertyId,
  • std::vector amounts) +{
  • std::vector payload;
  • uint64_t messageType = 0; /// XXX
  • uint64_t messageVer = 0; /// XXX
  • std::vector vecMessageType = CompressInteger(messageType);
  • std::vector vecMessageVer = CompressInteger(messageVer);
  • std::vector vecPropertyId = CompressInteger((uint64_t)propertyId);
  • /*
    • We can now check if there is sufficient room for the amounts..
  • */
  • if (amounts.size() > 4) {
  • throw ;
  • }
  • payload.insert(payload.end(), vecMessageVer.begin(), vecMessageVer.end());
  • payload.insert(payload.end(), vecMessageType.begin(), vecMessageType.end());
  • payload.insert(payload.end(), vecPropertyId.begin(), vecPropertyId.end());
  • for (auto amount: amounts) {
  • std::vector vecAmount = CompressInteger(amount);
  • payload.insert(payload.end(), vecAmount.begin(), vecAmount.end());
  • }
  • return payload; +}

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/BlockPo/BlockPo-to-Tradelayer/issues/455#issuecomment-829437736, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAS2CBL524HZCYBT6L7PXVLTLGG7NANCNFSM43XZT3UA .

sinetek commented 3 years ago

Which number do we wish to allocate to CreatePayload_ManySend?

sinetek commented 3 years ago

https://github.com/BlockPo/BlockPo-to-Tradelayer/pull/460

patrickdugan commented 2 years ago

@sinetek Which tx number did you pick for this?