From bf32a209d09f4bfda274a0ca7efebceab83560b9 Mon Sep 17 00:00:00 2001 From: canonbrother Date: Fri, 21 Jun 2024 17:05:03 +0800 Subject: [PATCH 1/4] clone block --- json/src/blockchain.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/json/src/blockchain.rs b/json/src/blockchain.rs index 52ea831..1cb79d3 100644 --- a/json/src/blockchain.rs +++ b/json/src/blockchain.rs @@ -31,7 +31,7 @@ pub struct BlockchainInfo { warnings: String, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, Clone)] #[serde(rename_all = "camelCase")] pub struct Block { pub hash: BlockHash, From 460d55fb4b1ed3dc2e50411cf564ba84a26cea78 Mon Sep 17 00:00:00 2001 From: canonbrother Date: Fri, 21 Jun 2024 17:14:10 +0800 Subject: [PATCH 2/4] clone tx --- json/src/blockchain.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/json/src/blockchain.rs b/json/src/blockchain.rs index 1cb79d3..9e12494 100644 --- a/json/src/blockchain.rs +++ b/json/src/blockchain.rs @@ -79,7 +79,7 @@ pub struct BlockHeader { nextblockhash: String, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, Clone)] #[serde(rename_all = "camelCase")] pub struct Transaction { pub txid: Txid, @@ -94,28 +94,28 @@ pub struct Transaction { pub hex: String, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, Clone)] #[serde(rename_all = "camelCase")] pub struct ScriptSig { asm: String, pub hex: Option, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, Clone)] #[serde(untagged)] pub enum Vin { Coinbase(VinCoinbase), Standard(VinStandard), } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, Clone)] #[serde(rename_all = "camelCase")] pub struct VinCoinbase { pub coinbase: String, pub sequence: i64, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, Clone)] #[serde(rename_all = "camelCase")] pub struct VinStandard { pub txid: Txid, @@ -125,7 +125,7 @@ pub struct VinStandard { pub sequence: i64, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, Clone)] #[serde(rename_all = "camelCase")] pub struct Vout { pub value: f64, @@ -157,7 +157,7 @@ pub struct TxOutSetInfo { total_amount: i64, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Serialize, Deserialize, Clone)] #[serde(rename_all = "camelCase")] pub struct ScriptPubKey { pub asm: String, From 91a8370ad22639c10e201c0d0184549ae051c6a0 Mon Sep 17 00:00:00 2001 From: canonbrother Date: Mon, 24 Jun 2024 16:03:45 +0800 Subject: [PATCH 3/4] Vout typing --- json/src/blockchain.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/json/src/blockchain.rs b/json/src/blockchain.rs index 9e12494..6e1a3d1 100644 --- a/json/src/blockchain.rs +++ b/json/src/blockchain.rs @@ -129,9 +129,9 @@ pub struct VinStandard { #[serde(rename_all = "camelCase")] pub struct Vout { pub value: f64, - pub n: u64, + pub n: usize, pub script_pub_key: ScriptPubKey, - pub token_id: Option, + pub token_id: Option, } #[derive(Debug, Serialize, Deserialize)] From 332a5c6d0098a008c2354962bfa2d936a128e289 Mon Sep 17 00:00:00 2001 From: canonbrother Date: Mon, 24 Jun 2024 16:07:57 +0800 Subject: [PATCH 4/4] VinStandard typing --- json/src/blockchain.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/json/src/blockchain.rs b/json/src/blockchain.rs index 6e1a3d1..bdbd84e 100644 --- a/json/src/blockchain.rs +++ b/json/src/blockchain.rs @@ -119,7 +119,7 @@ pub struct VinCoinbase { #[serde(rename_all = "camelCase")] pub struct VinStandard { pub txid: Txid, - pub vout: u64, + pub vout: usize, pub script_sig: ScriptSig, pub txinwitness: Option>, pub sequence: i64,