corepc_client/client_sync/v17/
raw_transactions.rs1#[macro_export]
14macro_rules! impl_client_v17__combine_psbt {
15 () => {
16 impl Client {
17 pub fn combine_psbt(&self, txs: &[bitcoin::Psbt]) -> Result<CombinePsbt> {
18 let txs = txs.iter().map(|psbt| format!("{}", psbt)).collect::<Vec<String>>();
19 self.call("combinepsbt", &[txs.into()])
20 }
21 }
22 };
23}
24
25#[macro_export]
27macro_rules! impl_client_v17__combine_raw_transaction {
28 () => {
29 impl Client {
30 pub fn combine_raw_transaction(
31 &self,
32 txs: &[bitcoin::Transaction],
33 ) -> Result<CombineRawTransaction> {
34 let encoded = txs
35 .iter()
36 .map(|tx| bitcoin::consensus::encode::serialize_hex(tx))
37 .collect::<Vec<String>>();
38 self.call("combinerawtransaction", &[into_json(encoded)?])
39 }
40 }
41 };
42}
43
44#[macro_export]
46macro_rules! impl_client_v17__convert_to_psbt {
47 () => {
48 impl Client {
49 pub fn convert_to_psbt(&self, tx: &bitcoin::Transaction) -> Result<ConvertToPsbt> {
50 let hex = bitcoin::consensus::encode::serialize_hex(tx);
51 self.call("converttopsbt", &[hex.into()])
52 }
53 }
54 };
55}
56
57#[macro_export]
59macro_rules! impl_client_v17__create_psbt {
60 () => {
61 impl Client {
62 pub fn create_psbt(&self, inputs: &[Input], outputs: &[Output]) -> Result<CreatePsbt> {
63 self.call("createpsbt", &[into_json(inputs)?, into_json(outputs)?])
64 }
65 }
66 };
67}
68
69#[macro_export]
71macro_rules! impl_client_v17__create_raw_transaction {
72 () => {
73 impl Client {
74 pub fn create_raw_transaction(
75 &self,
76 inputs: &[Input],
77 outputs: &[Output],
78 ) -> Result<CreateRawTransaction> {
79 self.call("createrawtransaction", &[into_json(inputs)?, into_json(outputs)?])
80 }
81 }
82 };
83}
84
85#[macro_export]
87macro_rules! impl_client_v17__decode_psbt {
88 () => {
89 impl Client {
90 pub fn decode_psbt(&self, psbt: &str) -> Result<DecodePsbt> {
91 self.call("decodepsbt", &[psbt.into()])
92 }
93 }
94 };
95}
96
97#[macro_export]
99macro_rules! impl_client_v17__finalize_psbt {
100 () => {
101 impl Client {
102 pub fn finalize_psbt(&self, psbt: &bitcoin::Psbt) -> Result<FinalizePsbt> {
103 let psbt = format!("{}", psbt);
104 self.call("finalizepsbt", &[psbt.into(), false.into()])
106 }
107 }
108 };
109}
110
111#[macro_export]
113macro_rules! impl_client_v17__decode_raw_transaction {
114 () => {
115 impl Client {
116 pub fn decode_raw_transaction(
117 &self,
118 tx: &bitcoin::Transaction,
119 ) -> Result<DecodeRawTransaction> {
120 let hex = bitcoin::consensus::encode::serialize_hex(tx);
121 self.call("decoderawtransaction", &[hex.into()])
122 }
123 }
124 };
125}
126
127#[macro_export]
129macro_rules! impl_client_v17__decode_script {
130 () => {
131 impl Client {
132 pub fn decode_script(&self, script: &str) -> Result<DecodeScript> {
134 self.call("decodescript", &[script.into()])
135 }
136 }
137 };
138}
139
140#[macro_export]
142macro_rules! impl_client_v17__fund_raw_transaction {
143 () => {
144 impl Client {
145 pub fn fund_raw_transaction(
146 &self,
147 tx: &bitcoin::Transaction,
148 ) -> Result<FundRawTransaction> {
149 let hex = bitcoin::consensus::encode::serialize_hex(tx);
150 self.call("fundrawtransaction", &[hex.into()])
151 }
152 }
153 };
154}
155
156#[macro_export]
158macro_rules! impl_client_v17__get_raw_transaction {
159 () => {
160 impl Client {
161 pub fn get_raw_transaction(&self, txid: bitcoin::Txid) -> Result<GetRawTransaction> {
162 self.call("getrawtransaction", &[into_json(&txid)?, false.into()])
163 }
164
165 pub fn get_raw_transaction_verbose(
166 &self,
167 txid: Txid,
168 ) -> Result<GetRawTransactionVerbose> {
169 self.call("getrawtransaction", &[into_json(&txid)?, true.into()])
170 }
171 }
172 };
173}
174
175#[macro_export]
177macro_rules! impl_client_v17__send_raw_transaction {
178 () => {
179 impl Client {
180 pub fn send_raw_transaction(
181 &self,
182 tx: &bitcoin::Transaction,
183 ) -> Result<SendRawTransaction> {
184 let hex = bitcoin::consensus::encode::serialize_hex(tx);
185 self.call("sendrawtransaction", &[hex.into()])
186 }
187 }
188 };
189}
190
191#[macro_export]
193macro_rules! impl_client_v17__sign_raw_transaction {
194 () => {
195 impl Client {
196 pub fn sign_raw_transaction(
197 &self,
198 tx: &bitcoin::Transaction,
199 ) -> Result<SignRawTransaction> {
200 let hex = bitcoin::consensus::encode::serialize_hex(tx);
201 self.call("signrawtransaction", &[hex.into()])
202 }
203 }
204 };
205}
206
207#[macro_export]
209macro_rules! impl_client_v17__sign_raw_transaction_with_key {
210 () => {
211 impl Client {
212 pub fn sign_raw_transaction_with_key(
213 &self,
214 tx: &bitcoin::Transaction,
215 keys: &[bitcoin::PrivateKey],
216 ) -> Result<SignRawTransactionWithKey> {
217 let hex = bitcoin::consensus::encode::serialize_hex(tx);
218 let keys = keys.iter().map(|k| format!("{}", k)).collect::<Vec<String>>();
219 self.call("signrawtransactionwithkey", &[hex.into(), into_json(keys)?])
220 }
221 }
222 };
223}
224
225#[macro_export]
227macro_rules! impl_client_v17__test_mempool_accept {
228 () => {
229 impl Client {
230 pub fn test_mempool_accept(
231 &self,
232 txs: &[bitcoin::Transaction],
233 ) -> Result<TestMempoolAccept> {
234 let encoded = txs
235 .iter()
236 .map(|tx| bitcoin::consensus::encode::serialize_hex(tx))
237 .collect::<Vec<String>>();
238 self.call("testmempoolaccept", &[into_json(encoded)?])
239 }
240 }
241 };
242}