Skip to content

Commit a69c16d

Browse files
authored
Merge pull request #25 from Duddino/fix-rpc
Fix rpc tx deserialization
2 parents a8d6de7 + acc2106 commit a69c16d

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src-tauri/src/address_index/sql_lite.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ impl Database for SqlLite {
6262
"INSERT OR IGNORE INTO transactions (txid, address) VALUES (?1, ?2);",
6363
params![txid, &address],
6464
)?;
65+
6566
for vin in &tx.vin {
6667
connection.execute(
6768
"INSERT OR IGNORE INTO vin (txid, n, spender_txid) VALUES (?1, ?2, ?3)",
@@ -149,6 +150,17 @@ mod test {
149150
.await?,
150151
Some("txid2".to_owned())
151152
);
153+
154+
assert_eq!(
155+
sql_lite
156+
.get_txid_from_vin(&Vin {
157+
txid: "spenttxid2".to_owned(),
158+
n: 1
159+
})
160+
.await?,
161+
Some("txid2".to_owned())
162+
);
163+
152164
assert_eq!(
153165
sql_lite
154166
.get_txid_from_vin(&Vin {

src-tauri/src/address_index/types.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub struct Vin {
3131
#[serde(default)]
3232
pub txid: String,
3333
#[serde(default)]
34+
#[serde(rename = "vout")]
3435
pub n: u32,
3536
}
3637

@@ -84,6 +85,10 @@ pub mod test {
8485
txid: "spenttxid".to_owned(),
8586
n: 1,
8687
},
88+
Vin {
89+
txid: "spenttxid2".to_owned(),
90+
n: 1,
91+
},
8792
Vin {
8893
txid: "spenttxid2".to_owned(),
8994
n: 5,
@@ -111,11 +116,11 @@ pub mod test {
111116
"txid": "123",
112117
"vin": [{
113118
"txid": "584",
114-
"n": 3
119+
"vout": 3
115120
},
116121
{
117122
"txid": "485",
118-
"n": 0
123+
"vout": 0
119124
},
120125
{
121126
"coinbase": "anoenar",

0 commit comments

Comments
 (0)