oxen-io / oxen-core

Oxen core repository, containing oxend and oxen cli wallets
https://oxen.io
Other
317 stars 120 forks source link

Fix serialization issues #1720

Closed jagerman closed 2 months ago

jagerman commented 2 months ago

This builds on top of #1716 -- only the last three commits are relevant to this PR.

This fixes an issue in 1716 where serialization of transactions was resulting in:

{
  "status": "OK",
  "txs": [
    {
      "": {
        "extra": [],
        "output_unlock_times": [],
        "type": 8,
        "unlock_time": 0,
        "version": 4,
        "vin": [],
        "vout": []
      },
      "blink": false,
      "block_height": 13058,
      "block_timestamp": 1725637630,
      "burned": 0,
      "fee": 0,
      "output_indices": [],
      "prunable_hash": "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
      "size": 22,
      "tx_hash": "8bd48f8e59c186e61e8df756d9d2a0d79662634a221d9b1242cd1adfcaba74b1"
    }
  ]
}

instead of:

{
  "status": "OK",
  "txs": [
    {
      "blink": false,
      "block_height": 13058,
      "block_timestamp": 1725637630,
      "burned": 0,
      "fee": 0,
      "output_indices": [],
      "output_unlock_times": [],
      "prunable_hash": "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
      "size": 22,
      "tx_hash": "8bd48f8e59c186e61e8df756d9d2a0d79662634a221d9b1242cd1adfcaba74b1",
      "type": 8,
      "unlock_time": 0,
      "version": 4,
      "vin": [],
      "vout": []
    }
  ]
}

caused by the change in a21209385425c66cd7ae8f188f7f5b43005cd29d (reverted here). That change, however, was because we had quite a few improper serialization implementations that were not properly beginning an object for serialization. (This can often go unnoticed begin begin_object() is a no-op for binary serialization, but is crucial for json serialization).

To fix this, this PR:

jagerman commented 2 months ago

Closing; now included in #1716