Repository: ergoplatform/sigma-rust (language: rust)

Issue:
Ensure JSON from explorer API is parsed properly
### Motivation
Node and explorer use slightly different names for the same fields. For example `id` vs `boxId` for box ids, `transactionId` vs `txId` for transaction id in box, which are handled as aliases in serde.

### Fix
Find all field names that have the same meaning but different names in explorer vs node API. Use serde alias to handle different names for the same field. See [example](https://github.com/ergoplatform/sigma-rust/blob/json-error-transactionid/ergo-lib/src/chain/json.rs#L74)
One way to find the differences is to compare `openapi.yml`.
Node: https://github.com/ergoplatform/ergo/blob/develop/src/main/resources/api/openapi.yaml
Explorer: https://api.ergoplatform.com/docs/openapi


Discussion / hints:
I've been looking at Explorer and I see that the API is currently v1. The names for this version appear to be consistent with the node and I will double-check them. It's v0 that has the different names. Should we support v0 too?
> I've been looking at Explorer and I see that the API is currently v1. The names for this version appear to be consistent with the node and I will double-check them. It's v0 that has the different names. Should we support v0 too?

Good question! I believe v0 is still in use and we need to support it. 

BTW, I added more "help wanted" labels. 
Got it, thanks for that and the labels.

Fix patch:
diff --git a/ergo-lib/src/chain/ergo_box.rs b/ergo-lib/src/chain/ergo_box.rs
index 95b6437cc..d3b75f019 100644
--- a/ergo-lib/src/chain/ergo_box.rs
+++ b/ergo-lib/src/chain/ergo_box.rs
@@ -61,7 +61,7 @@ use std::convert::TryInto;
 #[cfg_attr(feature = "json", serde(try_from = "json::ergo_box::ErgoBoxFromJson"))]
 #[derive(PartialEq, Eq, Debug, Clone)]
 pub struct ErgoBox {
-    #[cfg_attr(feature = "json", serde(rename = "boxId"))]
+    #[cfg_attr(feature = "json", serde(rename = "boxId", alias = "id"))]
     box_id: BoxId,
     /// amount of money associated with the box
     #[cfg_attr(feature = "json", serde(rename = "value"))]
@@ -81,7 +81,7 @@ pub struct ErgoBox {
     #[cfg_attr(feature = "json", serde(rename = "creationHeight"))]
     pub creation_height: u32,
     /// id of transaction which created the box
-    #[cfg_attr(feature = "json", serde(rename = "transactionId"))]
+    #[cfg_attr(feature = "json", serde(rename = "transactionId", alias = "txId"))]
     pub transaction_id: TxId,
     /// number of box (from 0 to total number of boxes the transaction with transactionId created - 1)
     #[cfg_attr(feature = "json", serde(rename = "index"))]
diff --git a/ergo-lib/src/chain/transaction/data_input.rs b/ergo-lib/src/chain/transaction/data_input.rs
index b576f6812..ec2a92a76 100644
--- a/ergo-lib/src/chain/transaction/data_input.rs
+++ b/ergo-lib/src/chain/transaction/data_input.rs
@@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize};
 #[cfg_attr(feature = "json", derive(Serialize, Deserialize))]
 pub struct DataInput {
     /// id of the box to add into context (should be in UTXO)
-    #[cfg_attr(feature = "json", serde(rename = "boxId"))]
+    #[cfg_attr(feature = "json", serde(rename = "boxId", alias = "id"))]
     pub box_id: BoxId,
 }
 
diff --git a/ergo-lib/src/chain/transaction/input.rs b/ergo-lib/src/chain/transaction/input.rs
index cde1910f3..4cd89871d 100644
--- a/ergo-lib/src/chain/transaction/input.rs
+++ b/ergo-lib/src/chain/transaction/input.rs
@@ -72,7 +72,7 @@ impl<T: ErgoBoxId> From<T> for UnsignedInput {
 #[cfg_attr(feature = "json", derive(Serialize, Deserialize))]
 pub struct Input {
     /// id of the box to spent
-    #[cfg_attr(feature = "json", serde(rename = "boxId"))]
+    #[cfg_attr(feature = "json", serde(rename = "boxId", alias = "id"))]
     pub box_id: BoxId,
     /// proof of spending correctness
     #[cfg_attr(feature = "json", serde(rename = "spendingProof",))]


Test patch: