@@ -43,11 +43,25 @@ pub fn historical_price(currency: &str, timestamp: &str) {
43
43
& format!( "{:}" , & currency) ,
44
44
& format!( "{:}" , & timestamp)
45
45
) ) ;
46
- // let _res = blocking(&format!(
47
- // "v1/historical-price?currency={}×tamp={}",
48
- // &format!("{:}", "EUR"),
49
- // &format!("{:}", "1500000000")
50
- // ));
46
+ }
47
+ //GET /api/block/:hash/txid/:index
48
+ //https://mempool.space/docs/api/rest#get-block-transaction-id
49
+ pub fn block_tx_id ( block_hash : & str , txindex : & str ) {
50
+ //REF: mempool-space --block_txid 000000000000000015dc777b3ff2611091336355d3f0ee9766a2cf3be8e4b1ce --txindex 218
51
+ //EXPECT: 0fa6da60e484941f255cbb025c3d6440e5a7e970119e899b4065c7999360e406
52
+ let _res = blocking ( & format ! ( "block/{}/txid/{}" , block_hash, txindex) ) ;
53
+ }
54
+ //GET /api/block/:hash/txids
55
+ //https://mempool.space/docs/api/rest#get-block-transaction-ids
56
+ pub fn block_tx_ids ( block_hash : & str ) {
57
+ //REF: mempool-space --block_txids 000000000000000015dc777b3ff2611091336355d3f0ee9766a2cf3be8e4b1ce
58
+ //EXPECT:
59
+ // [
60
+ // "cfe624ccdd8010cf78dbedd1b25e1ff601b470c4d7d90fa9fc8c1bcc5cdc6e0e",
61
+ // "a5ef89881bd5103f223a0fa285dfc75f4718974cb792cf85e623a7de05801bc9",
62
+ // ...,
63
+ // ]
64
+ let _res = blocking ( & format ! ( "block/{}/txids" , block_hash) ) ;
51
65
}
52
66
53
67
/// <https://mempool.space/docs/api/rest>
@@ -130,6 +144,8 @@ pub struct Args {
130
144
/// - BLOCK <BLOCK_HASH> <TXID> <INDEX>
131
145
/// `https://mempool.space/api/block/<TXID>/<INDEX>`
132
146
pub block_txid : Option < String > ,
147
+ pub block_txindex : Option < String > ,
148
+
133
149
/// - BLOCK <BLOCK_HASH> <TXIDS>
134
150
/// `https://mempool.space/api/block/<TXID>`
135
151
pub block_txids : Option < String > ,
@@ -226,6 +242,14 @@ impl Args {
226
242
opts. optflag ( "" , "blocks_tip_height" , "GET /api/blocks/tip/height api call" ) ;
227
243
opts. optflag ( "" , "blocks_tip_hash" , "GET /api/blocks/tip/hash api call" ) ;
228
244
245
+ opts. optopt ( "" , "block_txid" , "block txid api call" , "BLOCK_TXID" ) ;
246
+ opts. optopt ( "" , "block_txindex" , "block_txindex api call" , "BLOCK_TXINDEX" ) ;
247
+
248
+ opts. optopt ( "" , "block_txids" , "block txids api call" , "BLOCK_TXIDS" ) ;
249
+ opts. optopt ( "" , "block_txs" , "block txids api call" , "BLOCK_TXS" ) ;
250
+ opts. optopt ( "" , "blocks" , "block txids api call" , "BLOCKS" ) ;
251
+ opts. optopt ( "" , "blocks_bulk" , "block txids api call" , "BLOCKS_BULK" ) ;
252
+
229
253
//OPTOPT
230
254
opts. optopt ( "c" , "config" , "sets the configuration file" , "CONFIG" ) ;
231
255
opts. optopt ( "s" , "server" , "sets the address of the rustypaste server" , "SERVER" ) ;
@@ -342,7 +366,17 @@ impl Args {
342
366
generic_sys_call ( "blocks_tip_hash" , & "extraneous_arg" ) ;
343
367
std:: process:: exit ( 0 ) ;
344
368
}
345
-
369
+ if matches. opt_present ( "block_txid" ) {
370
+ let block_txid = matches. opt_str ( "block_txid" ) ; //expect a block_hash
371
+ let block_txindex = matches. opt_str ( "block_txindex" ) ;
372
+ block_tx_id ( & block_txid. unwrap ( ) , & block_txindex. unwrap ( ) ) ;
373
+ std:: process:: exit ( 0 ) ;
374
+ }
375
+ if matches. opt_present ( "block_txids" ) {
376
+ let block_txids = matches. opt_str ( "block_txids" ) ; //expect a block_hash
377
+ block_tx_ids ( & block_txids. unwrap ( ) ) ;
378
+ std:: process:: exit ( 0 ) ;
379
+ }
346
380
if matches. opt_present ( "h" )
347
381
|| ( matches. free . is_empty ( )
348
382
&& !matches. opt_present ( "u" )
@@ -432,6 +466,7 @@ impl Args {
432
466
// BLOCK BLOCK_HASH TXID INDEX
433
467
// https://mempool.space/api/block/<block_hash>/<txid>/<index>
434
468
block_txid : matches. opt_str ( "block_txid" ) ,
469
+ block_txindex : matches. opt_str ( "block_txindex" ) ,
435
470
// BLOCK BLOCK_HASH TXIDS
436
471
// https://mempool.space/api/block/<block_hash>/<txids>
437
472
block_txids : matches. opt_str ( "block_txids" ) ,
0 commit comments