blvm-node 0.1.1

Bitcoin Commons BLVM: Minimal Bitcoin node implementation using blvm-protocol and blvm-consensus
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
# RPC API Reference

## Overview

Implements a JSON-RPC 2.0 API compatible with common Bitcoin RPC method names. API organized into categories: blockchain, network, mining, mempool, raw transactions, and control.

## Endpoints

**Default RPC Endpoint**: `http://localhost:18332` (regtest) or `http://localhost:8332` (mainnet)

**Protocol**: HTTP POST with JSON-RPC 2.0

**Content-Type**: `application/json`

## Authentication

Authentication is optional. When enabled, use:
- **Token-based**: `Authorization: Bearer <token>`
- **Certificate-based**: TLS client certificates

## Rate Limiting

Rate limiting is enforced per IP, per user, and per method. Default limits:
- Authenticated users: 100 burst, 10 req/sec
- Unauthenticated: 50 burst, 5 req/sec
- Per-method limits may override defaults

---

## Blockchain Methods

### getblockchaininfo

Returns blockchain state information.

**Parameters**: None

**Returns**:
```json
{
  "chain": "regtest",
  "blocks": 123456,
  "headers": 123456,
  "bestblockhash": "0000...",
  "difficulty": 4.656542373906925e-10,
  "mediantime": 1234567890,
  "verificationprogress": 1.0,
  "initialblockdownload": false,
  "chainwork": "0000...",
  "size_on_disk": 1234567890,
  "pruned": false,
  "pruneheight": null,
  "automatic_pruning": false,
  "warnings": ""
}
```

---

### getblock

Returns block information.

**Parameters**:
1. `hash` (string, required) - Block hash
2. `verbosity` (numeric, optional, default=1) - 0=hex, 1=JSON, 2=JSON with transaction details

**Returns**: Block data (format depends on verbosity)

**Example**:
```json
{
  "hash": "0000...",
  "confirmations": 1,
  "size": 285,
  "strippedsize": 285,
  "weight": 1140,
  "height": 123456,
  "version": 536870912,
  "versionHex": "20000000",
  "merkleroot": "0000...",
  "tx": ["txid1", "txid2"],
  "time": 1234567890,
  "mediantime": 1234567890,
  "nonce": 0,
  "bits": "207fffff",
  "difficulty": 4.656542373906925e-10,
  "chainwork": "0000...",
  "nTx": 2,
  "previousblockhash": "0000...",
  "nextblockhash": "0000..."
}
```

---

### getblockhash

Returns block hash for given height.

**Parameters**:
1. `height` (numeric, required) - Block height

**Returns**: Block hash (string)

---

### getblockheader

Returns block header information.

**Parameters**:
1. `hash` (string, required) - Block hash
2. `verbose` (boolean, optional, default=true) - Return JSON object vs hex string

**Returns**: Block header (JSON object or hex string)

---

### getbestblockhash

Returns hash of best (tip) block.

**Parameters**: None

**Returns**: Block hash (string)

---

### getblockcount

Returns current block height.

**Parameters**: None

**Returns**: Block height (numeric)

---

### getdifficulty

Returns current proof-of-work difficulty.

**Parameters**: None

**Returns**: Difficulty (numeric)

---

### gettxoutsetinfo

Returns UTXO set statistics.

**Parameters**: None

**Returns**:
```json
{
  "height": 123456,
  "bestblock": "0000...",
  "transactions": 1234567,
  "txouts": 2345678,
  "bogosize": 123456789,
  "muhash": "0000...",
  "disk_size": 1234567890,
  "total_amount": 21000000.0
}
```

---

### verifychain

Verifies blockchain database.

**Parameters**:
1. `checklevel` (numeric, optional, default=3) - Verification level (0-4)
2. `nblocks` (numeric, optional, default=6) - Number of blocks to check (0=all)

**Returns**: `true` if verification passed, `false` otherwise

---

### getchaintips

Returns information about all known chain tips.

**Parameters**: None

**Returns**: Array of chain tip objects

---

### getchaintxstats

Returns statistics about total number and rate of transactions.

**Parameters**:
1. `nblocks` (numeric, optional) - Number of blocks to analyze
2. `blockhash` (string, optional) - Block hash to analyze from

**Returns**: Transaction statistics

---

### getblockstats

Returns per-block statistics.

**Parameters**:
1. `hash_or_height` (string|numeric, required) - Block hash or height
2. `stats` (array, optional) - Specific stats to return

**Returns**: Block statistics

---

### pruneblockchain

Prunes the blockchain to specified height.

**Parameters**:
1. `height` (numeric, required) - Height to prune to

**Returns**: Pruned height (numeric)

---

### getpruneinfo

Returns pruning information.

**Parameters**: None

**Returns**:
```json
{
  "pruned": false,
  "pruneheight": null,
  "automatic_pruning": false,
  "prune_target_size": 0
}
```

---

### invalidateblock

Permanently marks a block as invalid.

**Parameters**:
1. `blockhash` (string, required) - Block hash to invalidate

**Returns**: `null` on success

---

### reconsiderblock

Removes invalidation status of a block.

**Parameters**:
1. `blockhash` (string, required) - Block hash to reconsider

**Returns**: `null` on success

---

### waitfornewblock

Waits for a new block and returns its hash.

**Parameters**:
1. `timeout` (numeric, optional, default=0) - Timeout in seconds (0=no timeout)

**Returns**: Block hash and height

---

### waitforblock

Waits for a specific block.

**Parameters**:
1. `blockhash` (string, required) - Block hash to wait for
2. `timeout` (numeric, optional, default=0) - Timeout in seconds

**Returns**: Block hash and height

---

### waitforblockheight

Waits for a specific block height.

**Parameters**:
1. `height` (numeric, required) - Block height to wait for
2. `timeout` (numeric, optional, default=0) - Timeout in seconds

**Returns**: Block hash and height

---

### getblockfilter

Returns BIP 157 compact block filter.

**Parameters**:
1. `blockhash` (string, required) - Block hash
2. `filtertype` (string, optional, default="basic") - Filter type

**Returns**: Block filter (hex string)

---

### getindexinfo

Returns status of optional indexes.

**Parameters**: None

**Returns**: Index status information

---

## Network Methods

### getnetworkinfo

Returns network information.

**Parameters**: None

**Returns**:
```json
{
  "version": 70015,
  "subversion": "/blvm-node:0.1.0/",
  "protocolversion": 70015,
  "localservices": "0000000000000001",
  "localrelay": true,
  "timeoffset": 0,
  "networkactive": true,
  "connections": 8,
  "networks": [...],
  "relayfee": 0.00001000,
  "incrementalfee": 0.00001000,
  "localaddresses": [],
  "warnings": ""
}
```

---

### getpeerinfo

Returns peer connection information.

**Parameters**: None

**Returns**: Array of peer objects

---

### getconnectioncount

Returns number of connections.

**Parameters**: None

**Returns**: Connection count (numeric)

---

### ping

Pings all connected peers.

**Parameters**: None

**Returns**: `null` on success

---

### addnode

Adds a node to the connection list.

**Parameters**:
1. `node` (string, required) - Node address (IP:port)
2. `command` (string, required) - "add", "remove", "onetry"

**Returns**: `null` on success

---

### disconnectnode

Disconnects from a peer.

**Parameters**:
1. `address` (string, optional) - Peer address
2. `nodeid` (numeric, optional) - Peer node ID

**Returns**: `null` on success

---

### getnettotals

Returns network traffic statistics.

**Parameters**: None

**Returns**:
```json
{
  "totalbytesrecv": 1234567890,
  "totalbytessent": 1234567890,
  "timemillis": 1234567890123
}
```

---

### clearbanned

Clears all banned IPs.

**Parameters**: None

**Returns**: `null` on success

---

### setban

Bans or unbans an IP address.

**Parameters**:
1. `subnet` (string, required) - IP address or subnet
2. `command` (string, required) - "add" or "remove"
3. `bantime` (numeric, optional) - Ban duration in seconds
4. `absolute` (boolean, optional) - Use absolute time

**Returns**: `null` on success

---

### listbanned

Lists all banned IPs.

**Parameters**: None

**Returns**: Array of banned IP objects

---

### getaddednodeinfo

Returns information about manually added nodes.

**Parameters**:
1. `dummy` (boolean, required) - Dummy parameter
2. `node` (string, optional) - Specific node address

**Returns**: Array of node information objects

---

### getnodeaddresses

Returns known node addresses.

**Parameters**:
1. `count` (numeric, optional, default=1) - Number of addresses to return

**Returns**: Array of node address objects

---

### setnetworkactive

Enables or disables network activity.

**Parameters**:
1. `state` (boolean, required) - `true` to enable, `false` to disable

**Returns**: `null` on success

---

## Mining Methods

### getmininginfo

Returns mining information.

**Parameters**: None

**Returns**:
```json
{
  "blocks": 123456,
  "currentblocksize": 285,
  "currentblocktx": 1,
  "difficulty": 4.656542373906925e-10,
  "networkhashps": 0.0,
  "pooledtx": 0,
  "chain": "regtest",
  "warnings": ""
}
```

---

### getblocktemplate

Returns block template for mining.

**Parameters**:
1. `template_request` (object, optional) - Template request options

**Returns**:
```json
{
  "capabilities": ["proposal"],
  "version": 536870912,
  "rules": ["segwit"],
  "vbavailable": {},
  "vbrequired": 0,
  "previousblockhash": "0000...",
  "transactions": [...],
  "coinbaseaux": {},
  "coinbasevalue": 5000000000,
  "longpollid": "...",
  "target": "0000...",
  "mintime": 1234567890,
  "mutable": ["time", "transactions", "prevblock"],
  "noncerange": "00000000ffffffff",
  "sigoplimit": 80000,
  "sizelimit": 4000000,
  "weightlimit": 4000000,
  "curtime": 1234567890,
  "bits": "207fffff",
  "height": 123456
}
```

---

### submitblock

Submits a new block to the network.

**Parameters**:
1. `hexdata` (string, required) - Serialized block (hex)
2. `dummy` (string, optional) - Dummy parameter

**Returns**: `null` on success, error string on failure

---

### estimatesmartfee

Estimates fee rate for confirmation target.

**Parameters**:
1. `conf_target` (numeric, required) - Confirmation target (blocks)
2. `estimate_mode` (string, optional) - "UNSET", "ECONOMICAL", "CONSERVATIVE"

**Returns**:
```json
{
  "feerate": 0.00001000,
  "blocks": 2
}
```

---

### prioritisetransaction

Accepts the transaction into mined blocks at a higher priority.

**Parameters**:
1. `txid` (string, required) - Transaction ID
2. `dummy` (numeric, optional) - Dummy parameter
3. `fee_delta` (numeric, required) - Fee delta (satoshis)

**Returns**: `true` on success

---

## Mempool Methods

### getmempoolinfo

Returns mempool information.

**Parameters**: None

**Returns**:
```json
{
  "loaded": true,
  "size": 123,
  "bytes": 30750,
  "usage": 30750,
  "maxmempool": 300000000,
  "mempoolminfee": 0.00001000,
  "minrelaytxfee": 0.00001000
}
```

---

### getrawmempool

Returns transaction IDs in mempool.

**Parameters**:
1. `verbose` (boolean, optional, default=false) - Return verbose information

**Returns**: Array of transaction IDs or objects

---

### savemempool

Saves mempool to disk.

**Parameters**: None

**Returns**: `null` on success

---

### getmempoolancestors

Returns mempool ancestors of a transaction.

**Parameters**:
1. `txid` (string, required) - Transaction ID
2. `verbose` (boolean, optional, default=false) - Return verbose information

**Returns**: Array of transaction IDs or objects

---

### getmempooldescendants

Returns mempool descendants of a transaction.

**Parameters**:
1. `txid` (string, required) - Transaction ID
2. `verbose` (boolean, optional, default=false) - Return verbose information

**Returns**: Array of transaction IDs or objects

---

### getmempoolentry

Returns mempool entry for a transaction.

**Parameters**:
1. `txid` (string, required) - Transaction ID

**Returns**: Mempool entry object

---

## Raw Transaction Methods

### sendrawtransaction

Submits a raw transaction to the network.

**Parameters**:
1. `hexstring` (string, required) - Serialized transaction (hex)
2. `maxfeerate` (numeric, optional) - Maximum fee rate

**Returns**: Transaction ID (string)

---

### testmempoolaccept

Tests if a transaction would be accepted to mempool.

**Parameters**:
1. `rawtxs` (array, required) - Array of raw transactions (hex)
2. `maxfeerate` (numeric, optional) - Maximum fee rate

**Returns**: Array of acceptance results

---

### decoderawtransaction

Decodes a raw transaction.

**Parameters**:
1. `hexstring` (string, required) - Serialized transaction (hex)
2. `iswitness` (boolean, optional) - Whether transaction is SegWit

**Returns**: Decoded transaction object

---

### getrawtransaction

Returns raw transaction data.

**Parameters**:
1. `txid` (string, required) - Transaction ID
2. `verbose` (boolean, optional, default=false) - Return verbose information
3. `blockhash` (string, optional) - Block hash to search in

**Returns**: Transaction data (hex string or JSON object)

---

### gettxout

Returns transaction output information.

**Parameters**:
1. `txid` (string, required) - Transaction ID
2. `n` (numeric, required) - Output index
3. `include_mempool` (boolean, optional, default=true) - Include mempool

**Returns**: Transaction output object or `null`

---

### gettxoutproof

Returns merkle proof for a transaction.

**Parameters**:
1. `txids` (array, required) - Array of transaction IDs
2. `blockhash` (string, optional) - Block hash

**Returns**: Merkle proof (hex string)

---

### verifytxoutproof

Verifies a merkle proof.

**Parameters**:
1. `proof` (string, required) - Merkle proof (hex)

**Returns**: Array of transaction IDs proven by the proof

---

## Control Methods

### stop

Stops the node.

**Parameters**: None

**Returns**: `"blvm-node stopping"`

---

### uptime

Returns node uptime.

**Parameters**: None

**Returns**: Uptime in seconds (numeric)

---

### getmemoryinfo

Returns memory usage information.

**Parameters**:
1. `mode` (string, optional, default="stats") - "stats" or "mallocinfo"

**Returns**: Memory usage information

---

### getrpcinfo

Returns RPC server information.

**Parameters**: None

**Returns**:
```json
{
  "active_commands": ["getblockchaininfo", "getblock", ...],
  "logpath": ""
}
```

---

### help

Returns help for RPC methods.

**Parameters**:
1. `command` (string, optional) - Specific command to get help for

**Returns**: Help text (string)

---

### logging

Controls logging levels.

**Parameters**:
1. `include` (array, optional) - Categories to include
2. `exclude` (array, optional) - Categories to exclude

**Returns**: Logging configuration

---

### gethealth

Returns node health status.

**Parameters**: None

**Returns**: Health status object

---

### getmetrics

Returns Prometheus metrics.

**Parameters**: None

**Returns**: Prometheus-formatted metrics (text)

---

## Error Responses

All methods return JSON-RPC 2.0 error responses on failure:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": -32602,
    "message": "Invalid params"
  }
}
```

**Error Codes**:
- `-32700`: Parse error
- `-32600`: Invalid Request
- `-32601`: Method not found
- `-32602`: Invalid params
- `-32603`: Internal error
- `-32000` to `-32099`: Server errors

---

## Related Documentation

- [High Availability]HIGH_AVAILABILITY.md - Health checks and metrics
- [Configuration reference]https://docs.thebitcoincommons.org/reference/configuration-reference.html ([BLVM Documentation]https://docs.thebitcoincommons.org/)
- [Module System]MODULE_SYSTEM.md - Module system documentation