BlockPo/BlockPo-to-Tradelayer

Send To Many

patrickdugan opened this issue · 7 comments

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.

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

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

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

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;
+}

Which number do we wish to allocate to CreatePayload_ManySend?

@sinetek Which tx number did you pick for this?