|
1 | 1 | use crate::bitcoin::{ |
2 | | - Address, Amount, BlockHash, DescriptorId, HashableOutPoint, OutPoint, Script, Transaction, TxOut, Txid |
| 2 | + Address, Amount, BlockHash, DescriptorId, HashableOutPoint, OutPoint, Script, Transaction, |
| 3 | + TxOut, Txid, |
3 | 4 | }; |
4 | 5 | use crate::error::{CreateTxError, RequestBuilderError}; |
| 6 | +use crate::keys::DescriptorPublicKey; |
5 | 7 |
|
6 | 8 | use bdk_core::bitcoin::absolute::LockTime as BdkLockTime; |
7 | 9 | use bdk_core::spk_client::SyncItem; |
@@ -896,3 +898,61 @@ impl From<TxGraphChangeSet> for bdk_wallet::chain::tx_graph::ChangeSet<BdkConfir |
896 | 898 | } |
897 | 899 | } |
898 | 900 | } |
| 901 | + |
| 902 | +#[derive(Debug, uniffi::Record)] |
| 903 | +pub struct ChangeSet { |
| 904 | + pub descriptor: Option<Arc<DescriptorPublicKey>>, |
| 905 | + pub change_descriptor: Option<Arc<DescriptorPublicKey>>, |
| 906 | + pub network: Option<bdk_wallet::bitcoin::Network>, |
| 907 | + pub local_chain: LocalChainChangeSet, |
| 908 | + pub tx_graph: TxGraphChangeSet, |
| 909 | + pub indexer: IndexerChangeSet, |
| 910 | +} |
| 911 | + |
| 912 | +impl From<ChangeSet> for bdk_wallet::ChangeSet { |
| 913 | + fn from(value: ChangeSet) -> Self { |
| 914 | + let descriptor = value.descriptor.map(|d| { |
| 915 | + let str_repr = d.to_string(); |
| 916 | + str_repr.parse::<bdk_wallet::miniscript::Descriptor<bdk_wallet::miniscript::DescriptorPublicKey>>().unwrap() |
| 917 | + }); |
| 918 | + let change_descriptor = value.change_descriptor.map(|d| { |
| 919 | + let str_repr = d.to_string(); |
| 920 | + str_repr.parse::<bdk_wallet::miniscript::Descriptor<bdk_wallet::miniscript::DescriptorPublicKey>>().unwrap() |
| 921 | + }); |
| 922 | + let network = value.network; |
| 923 | + let local_chain = value.local_chain.into(); |
| 924 | + let tx_graph = value.tx_graph.into(); |
| 925 | + let indexer = value.indexer.into(); |
| 926 | + Self { |
| 927 | + descriptor, |
| 928 | + change_descriptor, |
| 929 | + network, |
| 930 | + local_chain, |
| 931 | + tx_graph, |
| 932 | + indexer, |
| 933 | + } |
| 934 | + } |
| 935 | +} |
| 936 | + |
| 937 | +impl From<bdk_wallet::ChangeSet> for ChangeSet { |
| 938 | + fn from(value: bdk_wallet::ChangeSet) -> Self { |
| 939 | + let descriptor = value |
| 940 | + .descriptor |
| 941 | + .map(|d| Arc::new(DescriptorPublicKey::from_string(d.to_string()).unwrap())); |
| 942 | + let change_descriptor = value |
| 943 | + .change_descriptor |
| 944 | + .map(|d| Arc::new(DescriptorPublicKey::from_string(d.to_string()).unwrap())); |
| 945 | + let network = value.network; |
| 946 | + let local_chain = value.local_chain.into(); |
| 947 | + let tx_graph = value.tx_graph.into(); |
| 948 | + let indexer = value.indexer.into(); |
| 949 | + Self { |
| 950 | + descriptor, |
| 951 | + change_descriptor, |
| 952 | + network, |
| 953 | + local_chain, |
| 954 | + tx_graph, |
| 955 | + indexer, |
| 956 | + } |
| 957 | + } |
| 958 | +} |
0 commit comments