9
9
//!
10
10
//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`.
11
11
12
+ /// Implements Bitcoin Core JSON-RPC API method `combinepsbt`
13
+ #[ macro_export]
14
+ macro_rules! impl_client_v17__combinepsbt {
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
+ /// Implements Bitcoin Core JSON-RPC API method `combinerawtransaction`
26
+ #[ macro_export]
27
+ macro_rules! impl_client_v17__combinerawtransaction {
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
+ /// Implements Bitcoin Core JSON-RPC API method `converttopsbt`
45
+ #[ macro_export]
46
+ macro_rules! impl_client_v17__converttopsbt {
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
+ /// Implements Bitcoin Core JSON-RPC API method `createpsbt`
58
+ #[ macro_export]
59
+ macro_rules! impl_client_v17__createpsbt {
60
+ ( ) => {
61
+ impl Client {
62
+ pub fn create_psbt(
63
+ & self ,
64
+ inputs: & [ $crate:: client_sync:: Input ] ,
65
+ outputs: & [ $crate:: client_sync:: Output ] ,
66
+ ) -> Result <CreatePsbt > {
67
+ self . call( "createpsbt" , & [ into_json( inputs) ?, into_json( outputs) ?] )
68
+ }
69
+ }
70
+ } ;
71
+ }
72
+
12
73
/// Implements Bitcoin Core JSON-RPC API method `createrawtransaction`
13
74
#[ macro_export]
14
75
macro_rules! impl_client_v17__createrawtransaction {
@@ -17,24 +78,98 @@ macro_rules! impl_client_v17__createrawtransaction {
17
78
pub fn create_raw_transaction(
18
79
& self ,
19
80
inputs: & [ $crate:: client_sync:: Input ] ,
20
- outputs: & std :: collections :: BTreeMap < String , f64 > , // Map of address to amount.
81
+ outputs: & [ $crate :: client_sync :: Output ] ,
21
82
) -> Result <CreateRawTransaction > {
22
83
self . call( "createrawtransaction" , & [ into_json( inputs) ?, into_json( outputs) ?] )
23
84
}
24
85
}
25
86
} ;
26
87
}
27
88
89
+ /// Implements Bitcoin Core JSON-RPC API method `decodepsbt`
90
+ #[ macro_export]
91
+ macro_rules! impl_client_v17__decodepsbt {
92
+ ( ) => {
93
+ impl Client {
94
+ pub fn decode_psbt( & self , psbt: & str ) -> Result <DecodePsbt > {
95
+ self . call( "decodepsbt" , & [ psbt. into( ) ] )
96
+ }
97
+ }
98
+ } ;
99
+ }
100
+
101
+ /// Implements Bitcoin Core JSON-RPC API method `finalizepsbt`
102
+ #[ macro_export]
103
+ macro_rules! impl_client_v17__finalizepsbt {
104
+ ( ) => {
105
+ impl Client {
106
+ pub fn finalize_psbt( & self , psbt: & bitcoin:: Psbt ) -> Result <FinalizePsbt > {
107
+ let psbt = format!( "{}" , psbt) ;
108
+ self . call( "finalizepsbt" , & [ psbt. into( ) ] )
109
+ }
110
+ }
111
+ } ;
112
+ }
113
+
114
+ /// Implements Bitcoin Core JSON-RPC API method `decoderawtransaction`
115
+ #[ macro_export]
116
+ macro_rules! impl_client_v17__decoderawtransaction {
117
+ ( ) => {
118
+ impl Client {
119
+ pub fn decode_raw_transaction(
120
+ & self ,
121
+ tx: & bitcoin:: Transaction ,
122
+ ) -> Result <DecodeRawTransaction > {
123
+ let hex = bitcoin:: consensus:: encode:: serialize_hex( tx) ;
124
+ self . call( "decoderawtransaction" , & [ hex. into( ) ] )
125
+ }
126
+ }
127
+ } ;
128
+ }
129
+
130
+ /// Implements Bitcoin Core JSON-RPC API method `decodescript`
131
+ #[ macro_export]
132
+ macro_rules! impl_client_v17__decodescript {
133
+ ( ) => {
134
+ impl Client {
135
+ // Arg is the hex encoded script we want to decode.
136
+ pub fn decode_script( & self , script: & str ) -> Result <DecodeScript > {
137
+ self . call( "decodescript" , & [ script. into( ) ] )
138
+ }
139
+ }
140
+ } ;
141
+ }
142
+
28
143
/// Implements Bitcoin Core JSON-RPC API method `fundrawtransaction`
29
144
#[ macro_export]
30
145
macro_rules! impl_client_v17__fundrawtransaction {
31
146
( ) => {
32
147
impl Client {
33
148
pub fn fund_raw_transaction(
34
149
& self ,
35
- hex : & str , // Hex encoded transaction.
150
+ tx : & bitcoin :: Transaction ,
36
151
) -> Result <FundRawTransaction > {
37
- self . call( "fundrawtransaction" , & [ into_json( hex) ?] )
152
+ let hex = bitcoin:: consensus:: encode:: serialize_hex( tx) ;
153
+ self . call( "fundrawtransaction" , & [ hex. into( ) ] )
154
+ }
155
+ }
156
+ } ;
157
+ }
158
+
159
+ /// Implements Bitcoin Core JSON-RPC API method `getrawtransaction`
160
+ #[ macro_export]
161
+ macro_rules! impl_client_v17__getrawtransaction {
162
+ ( ) => {
163
+ impl Client {
164
+ pub fn get_raw_transaction( & self , txid: bitcoin:: Txid ) -> Result <GetRawTransaction > {
165
+ self . call( "getrawtransaction" , & [ into_json( & txid) ?, false . into( ) ] )
166
+ }
167
+
168
+ pub fn get_raw_transaction_verbose(
169
+ & self ,
170
+ txid: Txid ,
171
+ ) -> Result <GetRawTransactionVerbose > {
172
+ self . call( "getrawtransaction" , & [ into_json( & txid) ?, true . into( ) ] )
38
173
}
39
174
}
40
175
} ;
@@ -55,3 +190,56 @@ macro_rules! impl_client_v17__sendrawtransaction {
55
190
}
56
191
} ;
57
192
}
193
+
194
+ /// Implements Bitcoin Core JSON-RPC API method `signrawtransaction`
195
+ #[ macro_export]
196
+ macro_rules! impl_client_v17__signrawtransaction {
197
+ ( ) => {
198
+ impl Client {
199
+ pub fn sign_raw_transaction(
200
+ & self ,
201
+ tx: & bitcoin:: Transaction ,
202
+ ) -> Result <SignRawTransaction > {
203
+ let hex = bitcoin:: consensus:: encode:: serialize_hex( tx) ;
204
+ self . call( "signrawtransaction" , & [ hex. into( ) ] )
205
+ }
206
+ }
207
+ } ;
208
+ }
209
+
210
+ /// Implements Bitcoin Core JSON-RPC API method `signrawtransactionwithkey`
211
+ #[ macro_export]
212
+ macro_rules! impl_client_v17__signrawtransactionwithkey {
213
+ ( ) => {
214
+ impl Client {
215
+ pub fn sign_raw_transaction_with_key(
216
+ & self ,
217
+ tx: & bitcoin:: Transaction ,
218
+ keys: & [ bitcoin:: PrivateKey ] ,
219
+ ) -> Result <SignRawTransaction > {
220
+ let hex = bitcoin:: consensus:: encode:: serialize_hex( tx) ;
221
+ let keys = keys. iter( ) . map( |k| format!( "{}" , k) ) . collect:: <Vec <String >>( ) ;
222
+ self . call( "signrawtransactionwithkey" , & [ hex. into( ) , into_json( keys) ?] )
223
+ }
224
+ }
225
+ } ;
226
+ }
227
+
228
+ /// Implements Bitcoin Core JSON-RPC API method `testmempoolaccept`
229
+ #[ macro_export]
230
+ macro_rules! impl_client_v17__testmempoolaccept {
231
+ ( ) => {
232
+ impl Client {
233
+ pub fn test_mempool_accept(
234
+ & self ,
235
+ txs: & [ bitcoin:: Transaction ] ,
236
+ ) -> Result <TestMempoolAccept > {
237
+ let encoded = txs
238
+ . iter( )
239
+ . map( |tx| bitcoin:: consensus:: encode:: serialize_hex( tx) )
240
+ . collect:: <Vec <String >>( ) ;
241
+ self . call( "testmempoolaccept" , & [ into_json( encoded) ?] )
242
+ }
243
+ }
244
+ } ;
245
+ }
0 commit comments