Skip to content

Commit da1770f

Browse files
committed
rust: get_unspent_outputs: add is_segwit
1 parent cc2881a commit da1770f

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

subprojects/gdk_rust/gdk_common/src/model.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,7 @@ pub struct UnspentOutput {
693693
pub pt_idx: u32,
694694
pub satoshi: u64,
695695
pub subaccount: u32,
696+
pub is_segwit: bool,
696697
pub txhash: String,
697698
/// `true` iff belongs to internal chain, i.e. is change
698699
pub is_internal: bool,
@@ -836,7 +837,7 @@ mod test {
836837

837838
#[test]
838839
fn test_unspent() {
839-
let json_str = r#"{"btc": [{"address_type": "p2wsh", "block_height": 1806588, "pointer": 3509, "pt_idx": 1, "satoshi": 3650144, "subaccount": 0, "txhash": "08711d45d4867d7834b133a425da065b252eb6a9b206d57e2bbb226a344c5d13", "is_internal": false, "confidential": false, "user_path": [2147483692, 2147483649, 2147483648, 0, 1], "prevout_script": "51"}, {"address_type": "p2wsh", "block_height": 1835681, "pointer": 3510, "pt_idx": 0, "satoshi": 5589415, "subaccount": 0, "txhash": "fbd00e5b9e8152c04214c72c791a78a65fdbab68b5c6164ff0d8b22a006c5221", "is_internal": false, "confidential": false, "user_path": [2147483692, 2147483649, 2147483648, 0, 2], "prevout_script": "51"}, {"address_type": "p2wsh", "block_height": 1835821, "pointer": 3511, "pt_idx": 0, "satoshi": 568158, "subaccount": 0, "txhash": "e5b358fb8366960130b97794062718d7f4fbe721bf274f47493a19326099b811", "is_internal": false, "confidential": false, "user_path": [2147483692, 2147483649, 2147483648, 0, 3], "prevout_script": "51"}]}"#;
840+
let json_str = r#"{"btc": [{"address_type": "p2wsh", "block_height": 1806588, "pointer": 3509, "pt_idx": 1, "satoshi": 3650144, "subaccount": 0, "txhash": "08711d45d4867d7834b133a425da065b252eb6a9b206d57e2bbb226a344c5d13", "is_internal": false, "confidential": false, "user_path": [2147483692, 2147483649, 2147483648, 0, 1], "prevout_script": "51", "is_segwit": true}, {"address_type": "p2wsh", "block_height": 1835681, "pointer": 3510, "pt_idx": 0, "satoshi": 5589415, "subaccount": 0, "txhash": "fbd00e5b9e8152c04214c72c791a78a65fdbab68b5c6164ff0d8b22a006c5221", "is_internal": false, "confidential": false, "user_path": [2147483692, 2147483649, 2147483648, 0, 2], "prevout_script": "51", "is_segwit": true}, {"address_type": "p2wsh", "block_height": 1835821, "pointer": 3511, "pt_idx": 0, "satoshi": 568158, "subaccount": 0, "txhash": "e5b358fb8366960130b97794062718d7f4fbe721bf274f47493a19326099b811", "is_internal": false, "confidential": false, "user_path": [2147483692, 2147483649, 2147483648, 0, 3], "prevout_script": "51", "is_segwit": true}]}"#;
840841
let json: GetUnspentOutputs = serde_json::from_str(json_str).unwrap();
841842
println!("{:#?}", json);
842843
}

subprojects/gdk_rust/gdk_electrum/src/account.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ impl Account {
379379
txhash: txid.to_hex(),
380380
satoshi: satoshi,
381381
subaccount: self.account_num,
382+
is_segwit: self.script_type.is_segwit(),
382383
is_internal: is_internal,
383384
confidential: tx.output_is_confidential(vout),
384385
scriptpubkey: tx.output_script(vout),

0 commit comments

Comments
 (0)