Slate: validate the declared version when deserializing

VersionedSlate and VersionedBinSlate are untagged and try V5 first, so
without a version check a V4 slate parses as V5. Only visible without a
payment proof; with one the V4 and V5 proof shapes differ enough for
serde to pick the right variant by chance.

Reject a mismatched version in the V4 and V5 deserializers, for both the
JSON and binary encodings, and set the declared version from the
conversion so it always matches the structure emitted. Add V4/V5 round
trip tests over both encodings, with and without a proof.

The V3 API examples showed V4 slates declaring version 5; they now
declare 4.
This commit is contained in:
jwinterm
2026-07-26 13:51:36 -04:00
parent 1f035e3ab8
commit 5397cef9b0
8 changed files with 118 additions and 28 deletions
+2 -2
View File
@@ -144,7 +144,7 @@ pub trait ForeignRpc {
}
],
"sta": "S1",
"ver": "5:2"
"ver": "4:2"
},
null,
null
@@ -179,7 +179,7 @@ pub trait ForeignRpc {
}
],
"sta": "S2",
"ver": "5:2"
"ver": "4:2"
}
}
}
+3 -3
View File
@@ -511,7 +511,7 @@ pub trait OwnerRpc {
}
],
"sta": "S1",
"ver": "5:2"
"ver": "4:2"
}
}
}
@@ -589,7 +589,7 @@ pub trait OwnerRpc {
}
],
"sta": "I1",
"ver": "5:2"
"ver": "4:2"
}
}
}
@@ -960,7 +960,7 @@ pub trait OwnerRpc {
"id": "0436430c-2b02-624c-2032-570501212b00",
"sigs": [],
"sta": "S3",
"ver": "5:3"
"ver": "4:3"
}
}
}