-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathuser myusername
More file actions
992 lines (863 loc) · 49 KB
/
user myusername
File metadata and controls
992 lines (863 loc) · 49 KB
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
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
---
name: analyzepsbt
btcversion: 24.0.0
btcgroup: rawtransactions
permalink: en/doc/24.0.0/rpc/rawtransactions/analyzepsbt/
---
analyzepsbt "psbt"
Analyzes and provides information about the current status of a PSBT and its inputs
Arguments:
1. psbt (string, required) A base64 string of a PSBT
Result:
{ (json object)
"inputs" : [ (json array, optional)
{ (json object)
"has_utxo" : true|false, (boolean) Whether a UTXO is provided
"is_final" : true|false, (boolean) Whether the input is finalized
"missing" : { (json object, optional) Things that are missing that are required to complete this input
"pubkeys" : [ (json array, optional)
"hex", (string) Public key ID, hash160 of the public key, of a public key whose BIP 32 derivation path is missing
...
],
"signatures" : [ (json array, optional)
"hex", (string) Public key ID, hash160 of the public key, of a public key whose signature is missing
...
],
"redeemscript" : "hex", (string, optional) Hash160 of the redeemScript that is missing
"witnessscript" : "hex" (string, optional) SHA256 of the witnessScript that is missing
},
"next" : "str" (string, optional) Role of the next person that this input needs to go to
},
...
],
"estimated_vsize" : n, (numeric, optional) Estimated vsize of the final signed transaction
"estimated_feerate" : n, (numeric, optional) Estimated feerate of the final signed transaction in BTC/kvB. Shown only if all UTXO slots in the PSBT have been filled
"fee" : n, (numeric, optional) The transaction fee paid. Shown only if all UTXO slots in the PSBT have been filled
"next" : "str", (string) Role of the next person that this psbt needs to go to
"error" : "str" (string, optional) Error message (if there is one)
}
Examples:
> bitcoin-cli analyzepsbt "psbt"
---
name: combinepsbt
btcversion: 24.0.0
btcgroup: rawtransactions
permalink: en/doc/24.0.0/rpc/rawtransactions/combinepsbt/
---
combinepsbt ["psbt",...]
Combine multiple partially signed Bitcoin transactions into one transaction.
Implements the Combiner role.
Arguments:
1. txs (json array, required) The base64 strings of partially signed transactions
[
"psbt", (string) A base64 string of a PSBT
...
]
Result:
"str" (string) The base64-encoded partially signed transaction
Examples:
> bitcoin-cli combinepsbt '["mybase64_1", "mybase64_2", "mybase64_3"]'
---
name: combinerawtransaction
btcversion: 24.0.0
btcgroup: rawtransactions
permalink: en/doc/24.0.0/rpc/rawtransactions/combinerawtransaction/
---
combinerawtransaction ["hexstring",...]
Combine multiple partially signed transactions into one transaction.
The combined transaction may be another partially signed transaction or a
fully signed transaction.
Arguments:
1. txs (json array, required) The hex strings of partially signed transactions
[
"hexstring", (string) A hex-encoded raw transaction
...
]
Result:
"str" (string) The hex-encoded raw transaction with signature(s)
Examples:
> bitcoin-cli combinerawtransaction '["myhex1", "myhex2", "myhex3"]'
name: converttopsbt
btcversion: 24.0.0
btcgroup: rawtransactions
permalink: en/doc/24.0.0/rpc/rawtransactions/converttopsbt/
---
converttopsbt "hexstring" ( permitsigdata iswitness )
Converts a network serialized transaction to a PSBT. This should be used only with createrawtransaction and fundrawtransaction
createpsbt and walletcreatefundedpsbt should be used for new applications.
Arguments:
1. hexstring (string, required) The hex string of a raw transaction
2. permitsigdata (boolean, optional, default=false) If true, any signatures in the input will be discarded and conversion
will continue. If false, RPC will fail if any signatures are present.
3. iswitness (boolean, optional, default=depends on heuristic tests) Whether the transaction hex is a serialized witness transaction.
If iswitness is not present, heuristic tests will be used in decoding.
If true, only witness deserialization will be tried.
If false, only non-witness deserialization will be tried.
This boolean should reflect whether the transaction has inputs
(e.g. fully valid, or on-chain transactions), if known by the caller.
Result:
"str" (string) The resulting raw transaction (base64-encoded string)
Examples:
Create a transaction
> bitcoin-cli createrawtransaction "[{\"txid\":\"myid\",\"vout\":0}]" "[{\"data\":\"00010203\"}]"
Convert the transaction to a PSBT
> bitcoin-cli converttopsbt "rawtransaction"
name: createpsbt
btcversion: 24.0.0
btcgroup: rawtransactions
permalink: en/doc/24.0.0/rpc/rawtransactions/createpsbt/
---
createpsbt [{"txid":"hex","vout":n,"sequence":n},...] [{"address":amount,...},{"data":"hex"},...] ( locktime replaceable )
Creates a transaction in the Partially Signed Transaction format.
Implements the Creator role.
Arguments:
1. inputs (json array, required) The inputs
[
{ (json object)
"txid": "hex", (string, required) The transaction id
"vout": n, (numeric, required) The output number
"sequence": n, (numeric, optional, default=depends on the value of the 'replaceable' and 'locktime' arguments) The sequence number
},
...
]
2. outputs (json array, required) The outputs (key-value pairs), where none of the keys are duplicated.
That is, each address can only appear once and there can only be one 'data' object.
For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also
accepted as second parameter.
[
{ (json object)
"address": amount, (numeric or string, required) A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in BTC
...
},
{ (json object)
"data": "hex", (string, required) A key-value pair. The key must be "data", the value is hex-encoded data
},
...
]
3. locktime (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs
4. replaceable (boolean, optional, default=true) Marks this transaction as BIP125-replaceable.
Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible.
Result:
"str" (string) The resulting raw transaction (base64-encoded string)
Examples:
> bitcoin-cli createpsbt "[{\"txid\":\"myid\",\"vout\":0}]" "[{\"data\":\"00010203\"}]"
name: createrawtransaction
btcversion: 24.0.0
btcgroup: rawtransactions
permalink: en/doc/24.0.0/rpc/rawtransactions/createrawtransaction/
---
createrawtransaction [{"txid":"hex","vout":n,"sequence":n},...] [{"address":amount,...},{"data":"hex"},...] ( locktime replaceable )
Create a transaction spending the given inputs and creating new outputs.
Outputs can be addresses or data.
Returns hex-encoded raw transaction.
Note that the transaction's inputs are not signed, and
it is not stored in the wallet or transmitted to the network.
Arguments:
1. inputs (json array, required) The inputs
[
{ (json object)
"txid": "hex", (string, required) The transaction id
"vout": n, (numeric, required) The output number
"sequence": n, (numeric, optional, default=depends on the value of the 'replaceable' and 'locktime' arguments) The sequence number
},
...
]
2. outputs (json array, required) The outputs (key-value pairs), where none of the keys are duplicated.
That is, each address can only appear once and there can only be one 'data' object.
For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also
accepted as second parameter.
[
{ (json object)
"address": amount, (numeric or string, required) A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in BTC
...
},
{ (json object)
"data": "hex", (string, required) A key-value pair. The key must be "data", the value is hex-encoded data
},
...
]
3. locktime (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs
4. replaceable (boolean, optional, default=true) Marks this transaction as BIP125-replaceable.
Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible.
Result:
"hex" (string) hex string of the transaction
Examples:
> bitcoin-cli createrawtransaction "[{\"txid\":\"myid\",\"vout\":0}]" "[{\"address\":0.01}]"
> bitcoin-cli createrawtransaction "[{\"txid\":\"myid\",\"vout\":0}]" "[{\"data\":\"00010203\"}]"
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "createrawtransaction", "params": ["[{\"txid\":\"myid\",\"vout\":0}]", "[{\"address\":0.01}]"]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "createrawtransaction", "params": ["[{\"txid\":\"myid\",\"vout\":0}]", "[{\"data\":\"00010203\"}]"]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/
Your account has been flagged.
Because of that, your profile is hidden from the public. If you believe this is a mistake, contact support to have your account status reviewed.
bitcoin-core
/
bitcoincore.org
Public
Code
Issues
15
Pull requests
18
Security
Insights
bitcoincore.org/_doc/en/24.0.0/rpc/rawtransactions/decodepsbt.html
@stickies-v
stickies-v RPC Docs: add 24.0.0
1 contributor
217 lines (210 sloc) 11.1 KB
---
name: decodepsbt
btcversion: 24.0.0
btcgroup: rawtransactions
permalink: en/doc/24.0.0/rpc/rawtransactions/decodepsbt/
---
decodepsbt "psbt"
Return a JSON object representing the serialized, base64-encoded partially signed Bitcoin transaction.
Arguments:
1. psbt (string, required) The PSBT base64 string
Result:
{ (json object)
"tx" : { (json object) The decoded network-serialized unsigned transaction.
... The layout is the same as the output of decoderawtransaction.
},
"global_xpubs" : [ (json array)
{ (json object)
"xpub" : "str", (string) The extended public key this path corresponds to
"master_fingerprint" : "hex", (string) The fingerprint of the master key
"path" : "str" (string) The path
},
...
],
"psbt_version" : n, (numeric) The PSBT version number. Not to be confused with the unsigned transaction version
"proprietary" : [ (json array) The global proprietary map
{ (json object)
"identifier" : "hex", (string) The hex string for the proprietary identifier
"subtype" : n, (numeric) The number for the subtype
"key" : "hex", (string) The hex for the key
"value" : "hex" (string) The hex for the value
},
...
],
"unknown" : { (json object) The unknown global fields
"key" : "hex", (string) (key-value pair) An unknown key-value pair
...
},
"inputs" : [ (json array)
{ (json object)
"non_witness_utxo" : { (json object, optional) Decoded network transaction for non-witness UTXOs
...
},
"witness_utxo" : { (json object, optional) Transaction output for witness UTXOs
"amount" : n, (numeric) The value in BTC
"scriptPubKey" : { (json object)
"asm" : "str", (string) Disassembly of the public key script
"desc" : "str", (string) Inferred descriptor for the output
"hex" : "hex", (string) The raw public key script bytes, hex-encoded
"type" : "str", (string) The type, eg 'pubkeyhash'
"address" : "str" (string, optional) The Bitcoin address (only if a well-defined address exists)
}
},
"partial_signatures" : { (json object, optional)
"pubkey" : "str", (string) The public key and signature that corresponds to it.
...
},
"sighash" : "str", (string, optional) The sighash type to be used
"redeem_script" : { (json object, optional)
"asm" : "str", (string) Disassembly of the redeem script
"hex" : "hex", (string) The raw redeem script bytes, hex-encoded
"type" : "str" (string) The type, eg 'pubkeyhash'
},
"witness_script" : { (json object, optional)
"asm" : "str", (string) Disassembly of the witness script
"hex" : "hex", (string) The raw witness script bytes, hex-encoded
"type" : "str" (string) The type, eg 'pubkeyhash'
},
"bip32_derivs" : [ (json array, optional)
{ (json object)
"pubkey" : "str", (string) The public key with the derivation path as the value.
"master_fingerprint" : "str", (string) The fingerprint of the master key
"path" : "str" (string) The path
},
...
],
"final_scriptSig" : { (json object, optional)
"asm" : "str", (string) Disassembly of the final signature script
"hex" : "hex" (string) The raw final signature script bytes, hex-encoded
},
"final_scriptwitness" : [ (json array, optional)
"hex", (string) hex-encoded witness data (if any)
...
],
"ripemd160_preimages" : { (json object, optional)
"hash" : "str", (string) The hash and preimage that corresponds to it.
...
},
"sha256_preimages" : { (json object, optional)
"hash" : "str", (string) The hash and preimage that corresponds to it.
...
},
"hash160_preimages" : { (json object, optional)
"hash" : "str", (string) The hash and preimage that corresponds to it.
...
},
"hash256_preimages" : { (json object, optional)
"hash" : "str", (string) The hash and preimage that corresponds to it.
...
},
"taproot_key_path_sig" : "hex", (string, optional) hex-encoded signature for the Taproot key path spend
"taproot_script_path_sigs" : [ (json array, optional)
{ (json object, optional) The signature for the pubkey and leaf hash combination
"pubkey" : "str", (string) The x-only pubkey for this signature
"leaf_hash" : "str", (string) The leaf hash for this signature
"sig" : "str" (string) The signature itself
},
...
],
"taproot_scripts" : [ (json array, optional)
{ (json object)
"script" : "hex", (string) A leaf script
"leaf_ver" : n, (numeric) The version number for the leaf script
"control_blocks" : [ (json array) The control blocks for this script
"hex", (string) A hex-encoded control block for this script
...
]
},
...
],
"taproot_bip32_derivs" : [ (json array, optional)
{ (json object)
"pubkey" : "str", (string) The x-only public key this path corresponds to
"master_fingerprint" : "str", (string) The fingerprint of the master key
"path" : "str", (string) The path
"leaf_hashes" : [ (json array) The hashes of the leaves this pubkey appears in
"hex", (string) The hash of a leaf this pubkey appears in
...
]
},
...
],
"taproot_internal_key" : "hex", (string, optional) The hex-encoded Taproot x-only internal key
"taproot_merkle_root" : "hex", (string, optional) The hex-encoded Taproot merkle root
"unknown" : { (json object, optional) The unknown input fields
"key" : "hex", (string) (key-value pair) An unknown key-value pair
...
},
"proprietary" : [ (json array, optional) The input proprietary map
{ (json object)
"identifier" : "hex", (string) The hex string for the proprietary identifier
"subtype" : n, (numeric) The number for the subtype
"key" : "hex", (string) The hex for the key
"value" : "hex" (string) The hex for the value
},
...
]
},
...
],
"outputs" : [ (json array)
{ (json object)
"redeem_script" : { (json object, optional)
"asm" : "str", (string) Disassembly of the redeem script
"hex" : "hex", (string) The raw redeem script bytes, hex-encoded
"type" : "str" (string) The type, eg 'pubkeyhash'
},
"witness_script" : { (json object, optional)
"asm" : "str", (string) Disassembly of the witness script
"hex" : "hex", (string) The raw witness script bytes, hex-encoded
"type" : "str" (string) The type, eg 'pubkeyhash'
},
"bip32_derivs" : [ (json array, optional)
{ (json object)
"pubkey" : "str", (string) The public key this path corresponds to
"master_fingerprint" : "str", (string) The fingerprint of the master key
"path" : "str" (string) The path
},
...
],
"taproot_internal_key" : "hex", (string, optional) The hex-encoded Taproot x-only internal key
"taproot_tree" : [ (json array, optional) The tuples that make up the Taproot tree, in depth first search order
{ (json object, optional) A single leaf script in the taproot tree
"depth" : n, (numeric) The depth of this element in the tree
"leaf_ver" : n, (numeric) The version of this leaf
"script" : "str" (string) The hex-encoded script itself
},
...
],
"taproot_bip32_derivs" : [ (json array, optional)
{ (json object)
"pubkey" : "str", (string) The x-only public key this path corresponds to
"master_fingerprint" : "str", (string) The fingerprint of the master key
"path" : "str", (string) The path
"leaf_hashes" : [ (json array) The hashes of the leaves this pubkey appears in
"hex", (string) The hash of a leaf this pubkey appears in
...
]
},
...
],
"unknown" : { (json object, optional) The unknown output fields
"key" : "hex", (string) (key-value pair) An unknown key-value pair
...
},
"proprietary" : [ (json array, optional) The output proprietary map
{ (json object)
"identifier" : "hex", (string) The hex string for the proprietary identifier
"subtype" : n, (numeric) The number for the subtype
"key" : "hex", (string) The hex for the key
"value" : "hex" (string) The hex for the value
},
...
]
},
...
],
"fee" : n (numeric, optional) The transaction fee paid if all UTXOs slots in the PSBT have been filled.
}
Examples:
> bitcoin-cli decodepsbt "psbt"
name: decoderawtransaction
btcversion: 24.0.0
btcgroup: rawtransactions
permalink: en/doc/24.0.0/rpc/rawtransactions/decoderawtransaction/
---
decoderawtransaction "hexstring" ( iswitness )
Return a JSON object representing the serialized, hex-encoded transaction.
Arguments:
1. hexstring (string, required) The transaction hex string
2. iswitness (boolean, optional, default=depends on heuristic tests) Whether the transaction hex is a serialized witness transaction.
If iswitness is not present, heuristic tests will be used in decoding.
If true, only witness deserialization will be tried.
If false, only non-witness deserialization will be tried.
This boolean should reflect whether the transaction has inputs
(e.g. fully valid, or on-chain transactions), if known by the caller.
Result:
{ (json object)
"txid" : "hex", (string) The transaction id
"hash" : "hex", (string) The transaction hash (differs from txid for witness transactions)
"size" : n, (numeric) The serialized transaction size
"vsize" : n, (numeric) The virtual transaction size (differs from size for witness transactions)
"weight" : n, (numeric) The transaction's weight (between vsize*4-3 and vsize*4)
"version" : n, (numeric) The version
"locktime" : xxx, (numeric) The lock time
"vin" : [ (json array)
{ (json object)
"coinbase" : "hex", (string, optional) The coinbase value (only if coinbase transaction)
"txid" : "hex", (string, optional) The transaction id (if not coinbase transaction)
"vout" : n, (numeric, optional) The output number (if not coinbase transaction)
"scriptSig" : { (json object, optional) The script (if not coinbase transaction)
"asm" : "str", (string) Disassembly of the signature script
"hex" : "hex" (string) The raw signature script bytes, hex-encoded
},
"txinwitness" : [ (json array, optional)
"hex", (string) hex-encoded witness data (if any)
...
],
"sequence" : n (numeric) The script sequence number
},
...
],
"vout" : [ (json array)
{ (json object)
"value" : n, (numeric) The value in BTC
"n" : n, (numeric) index
"scriptPubKey" : { (json object)
"asm" : "str", (string) Disassembly of the public key script
"desc" : "str", (string) Inferred descriptor for the output
"hex" : "hex", (string) The raw public key script bytes, hex-encoded
"type" : "str", (string) The type, eg 'pubkeyhash'
"address" : "str" (string, optional) The Bitcoin address (only if a well-defined address exists)
}
},
...
]
}
Examples:
> bitcoin-cli decoderawtransaction "hexstring"
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "decoderawtransaction", "params": ["hexstring"]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/
name: decodescript
btcversion: 24.0.0
btcgroup: rawtransactions
permalink: en/doc/24.0.0/rpc/rawtransactions/decodescript/
---
decodescript "hexstring"
Decode a hex-encoded script.
Arguments:
1. hexstring (string, required) the hex-encoded script
Result:
{ (json object)
"asm" : "str", (string) Script public key
"desc" : "str", (string) Inferred descriptor for the script
"type" : "str", (string) The output type (e.g. nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_scripthash, witness_v0_keyhash, witness_v1_taproot, witness_unknown)
"address" : "str", (string, optional) The Bitcoin address (only if a well-defined address exists)
"p2sh" : "str", (string, optional) address of P2SH script wrapping this redeem script (not returned for types that should not be wrapped)
"segwit" : { (json object, optional) Result of a witness script public key wrapping this redeem script (not returned for types that should not be wrapped)
"asm" : "str", (string) String representation of the script public key
"hex" : "hex", (string) Hex string of the script public key
"type" : "str", (string) The type of the script public key (e.g. witness_v0_keyhash or witness_v0_scripthash)
"address" : "str", (string, optional) The Bitcoin address (only if a well-defined address exists)
"desc" : "str", (string) Inferred descriptor for the script
"p2sh-segwit" : "str" (string) address of the P2SH script wrapping this witness redeem script
}
}
Examples:
> bitcoin-cli decodescript "hexstring"
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "decodescript", "params": ["hexstring"]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/
---
name: finalizepsbt
btcversion: 24.0.0
btcgroup: rawtransactions
permalink: en/doc/24.0.0/rpc/rawtransactions/finalizepsbt/
---
finalizepsbt "psbt" ( extract )
Finalize the inputs of a PSBT. If the transaction is fully signed, it will produce a
network serialized transaction which can be broadcast with sendrawtransaction. Otherwise a PSBT will be
created which has the final_scriptSig and final_scriptWitness fields filled for inputs that are complete.
Implements the Finalizer and Extractor roles.
Arguments:
1. psbt (string, required) A base64 string of a PSBT
2. extract (boolean, optional, default=true) If true and the transaction is complete,
extract and return the complete transaction in normal network serialization instead of the PSBT.
Result:
{ (json object)
"psbt" : "str", (string, optional) The base64-encoded partially signed transaction if not extracted
"hex" : "hex", (string, optional) The hex-encoded network transaction if extracted
"complete" : true|false (boolean) If the transaction has a complete set of signatures
}
Examples:
> bitcoin-cli finalizepsbt "psbt"
name: fundrawtransaction
btcversion: 24.0.0
btcgroup: rawtransactions
permalink: en/doc/24.0.0/rpc/rawtransactions/fundrawtransaction/
---
fundrawtransaction "hexstring" ( options iswitness )
If the transaction has no inputs, they will be automatically selected to meet its out value.
It will add at most one change output to the outputs.
No existing outputs will be modified unless "subtractFeeFromOutputs" is specified.
Note that inputs which were signed may need to be resigned after completion since in/outputs have been added.
The inputs added will not be signed, use signrawtransactionwithkey
or signrawtransactionwithwallet for that.
All existing inputs must either have their previous output transaction be in the wallet
or be in the UTXO set. Solving data must be provided for non-wallet inputs.
Note that all inputs selected must be of standard form and P2SH scripts must be
in the wallet using importaddress or addmultisigaddress (to calculate fees).
You can see whether this is the case by checking the "solvable" field in the listunspent output.
Only pay-to-pubkey, multisig, and P2SH versions thereof are currently supported for watch-only
Arguments:
1. hexstring (string, required) The hex string of the raw transaction
2. options (json object, optional) for backward compatibility: passing in a true instead of an object will result in {"includeWatching":true}
{
"add_inputs": bool, (boolean, optional, default=true) For a transaction with existing inputs, automatically include more if they are not enough.
"include_unsafe": bool, (boolean, optional, default=false) Include inputs that are not safe to spend (unconfirmed transactions from outside keys and unconfirmed replacement transactions).
Warning: the resulting transaction may become invalid if one of the unsafe inputs disappears.
If that happens, you will need to fund the transaction with different inputs and republish it.
"changeAddress": "str", (string, optional, default=automatic) The bitcoin address to receive the change
"changePosition": n, (numeric, optional, default=random) The index of the change output
"change_type": "str", (string, optional, default=set by -changetype) The output type to use. Only valid if changeAddress is not specified. Options are "legacy", "p2sh-segwit", "bech32", and "bech32m".
"includeWatching": bool, (boolean, optional, default=true for watch-only wallets, otherwise false) Also select inputs which are watch only.
Only solvable inputs can be used. Watch-only destinations are solvable if the public key and/or output script was imported,
e.g. with 'importpubkey' or 'importmulti' with the 'pubkeys' or 'desc' field.
"lockUnspents": bool, (boolean, optional, default=false) Lock selected unspent outputs
"fee_rate": amount, (numeric or string, optional, default=not set, fall back to wallet fee estimation) Specify a fee rate in sat/vB.
"feeRate": amount, (numeric or string, optional, default=not set, fall back to wallet fee estimation) Specify a fee rate in BTC/kvB.
"subtractFeeFromOutputs": [ (json array, optional, default=[]) The integers.
The fee will be equally deducted from the amount of each specified output.
Those recipients will receive less bitcoins than you enter in their corresponding amount field.
If no outputs are specified here, the sender pays the fee.
vout_index, (numeric) The zero-based output index, before a change output is added.
...
],
"input_weights": [ (json array, optional) Inputs and their corresponding weights
"txid", (string, required) The transaction id
vout, (numeric, required) The output index
weight, (numeric, required) The maximum weight for this input, including the weight of the outpoint and sequence number. Note that serialized signature sizes are not guaranteed to be consistent, so the maximum DER signatures size of 73 bytes should be used when considering ECDSA signatures.Remember to convert serialized sizes to weight units when necessary.
...
],
"conf_target": n, (numeric, optional, default=wallet -txconfirmtarget) Confirmation target in blocks
"estimate_mode": "str", (string, optional, default="unset") The fee estimate mode, must be one of (case insensitive):
"unset"
"economical"
"conservative"
"replaceable": bool, (boolean, optional, default=wallet default) Marks this transaction as BIP125-replaceable.
Allows this transaction to be replaced by a transaction with higher fees
"solving_data": { (json object, optional) Keys and scripts needed for producing a final transaction with a dummy signature.
Used for fee estimation during coin selection.
"pubkeys": [ (json array, optional, default=[]) Public keys involved in this transaction.
"pubkey", (string) A public key
...
],
"scripts": [ (json array, optional, default=[]) Scripts involved in this transaction.
"script", (string) A script
...
],
"descriptors": [ (json array, optional, default=[]) Descriptors that provide solving data for this transaction.
"descriptor", (string) A descriptor
...
],
},
}
3. iswitness (boolean, optional, default=depends on heuristic tests) Whether the transaction hex is a serialized witness transaction.
If iswitness is not present, heuristic tests will be used in decoding.
If true, only witness deserialization will be tried.
If false, only non-witness deserialization will be tried.
This boolean should reflect whether the transaction has inputs
(e.g. fully valid, or on-chain transactions), if known by the caller.
Result:
{ (json object)
"hex" : "hex", (string) The resulting raw transaction (hex-encoded string)
"fee" : n, (numeric) Fee in BTC the resulting transaction pays
"changepos" : n (numeric) The position of the added change output, or -1
}
Examples:
Create a transaction with no inputs
> bitcoin-cli createrawtransaction "[]" "{\"myaddress\":0.01}"
Add sufficient unsigned inputs to meet the output value
> bitcoin-cli fundrawtransaction "rawtransactionhex"
Sign the transaction
> bitcoin-cli signrawtransactionwithwallet "fundedtransactionhex"
Send the transaction
> bitcoin-cli sendrawtransaction "signedtransactionhex"
name: getrawtransaction
btcversion: 24.0.0
btcgroup: rawtransactions
permalink: en/doc/24.0.0/rpc/rawtransactions/getrawtransaction/
---
getrawtransaction "txid" ( verbose "blockhash" )
Return the raw transaction data.
By default, this call only returns a transaction if it is in the mempool. If -txindex is enabled
and no blockhash argument is passed, it will return the transaction if it is in the mempool or any block.
If a blockhash argument is passed, it will return the transaction if
the specified block is available and the transaction is in that block.
Hint: Use gettransaction for wallet transactions.
If verbose is 'true', returns an Object with information about 'txid'.
If verbose is 'false' or omitted, returns a string that is serialized, hex-encoded data for 'txid'.
Arguments:
1. txid (string, required) The transaction id
2. verbose (boolean, optional, default=false) If false, return a string, otherwise return a json object
3. blockhash (string, optional) The block in which to look for the transaction
Result (if verbose is not set or set to false):
"str" (string) The serialized, hex-encoded data for 'txid'
Result (if verbose is set to true):
{ (json object)
"in_active_chain" : true|false, (boolean, optional) Whether specified block is in the active chain or not (only present with explicit "blockhash" argument)
"blockhash" : "hex", (string, optional) the block hash
"confirmations" : n, (numeric, optional) The confirmations
"blocktime" : xxx, (numeric, optional) The block time expressed in UNIX epoch time
"time" : n, (numeric, optional) Same as "blocktime"
"hex" : "hex", (string) The serialized, hex-encoded data for 'txid'
"txid" : "hex", (string) The transaction id (same as provided)
"hash" : "hex", (string) The transaction hash (differs from txid for witness transactions)
"size" : n, (numeric) The serialized transaction size
"vsize" : n, (numeric) The virtual transaction size (differs from size for witness transactions)
"weight" : n, (numeric) The transaction's weight (between vsize*4-3 and vsize*4)
"version" : n, (numeric) The version
"locktime" : xxx, (numeric) The lock time
"vin" : [ (json array)
{ (json object)
"coinbase" : "hex", (string, optional) The coinbase value (only if coinbase transaction)
"txid" : "hex", (string, optional) The transaction id (if not coinbase transaction)
"vout" : n, (numeric, optional) The output number (if not coinbase transaction)
"scriptSig" : { (json object, optional) The script (if not coinbase transaction)
"asm" : "str", (string) Disassembly of the signature script
"hex" : "hex" (string) The raw signature script bytes, hex-encoded
},
"txinwitness" : [ (json array, optional)
"hex", (string) hex-encoded witness data (if any)
...
],
"sequence" : n (numeric) The script sequence number
},
...
],
"vout" : [ (json array)
{ (json object)
"value" : n, (numeric) The value in BTC
"n" : n, (numeric) index
"scriptPubKey" : { (json object)
"asm" : "str", (string) Disassembly of the public key script
"desc" : "str", (string) Inferred descriptor for the output
"hex" : "hex", (string) The raw public key script bytes, hex-encoded
"type" : "str", (string) The type, eg 'pubkeyhash'
"address" : "str" (string, optional) The Bitcoin address (only if a well-defined address exists)
}
},
...
]
}
Examples:
> bitcoin-cli getrawtransaction "mytxid"
> bitcoin-cli getrawtransaction "mytxid" true
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getrawtransaction", "params": ["mytxid", true]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/
> bitcoin-cli getrawtransaction "mytxid" false "myblockhash"
> bitcoin-cli getrawtransaction "mytxid" true "myblockhash"
name: joinpsbts
btcversion: 24.0.0
btcgroup: rawtransactions
permalink: en/doc/24.0.0/rpc/rawtransactions/joinpsbts/
---
joinpsbts ["psbt",...]
Joins multiple distinct PSBTs with different inputs and outputs into one PSBT with inputs and outputs from all of the PSBTs
No input in any of the PSBTs can be in more than one of the PSBTs.
Arguments:
1. txs (json array, required) The base64 strings of partially signed transactions
[
"psbt", (string, required) A base64 string of a PSBT
...
]
Result:
"str" (string) The base64-encoded partially signed transaction
Examples:
> bitcoin-cli joinpsbts "psbt"
name: sendrawtransaction
btcversion: 24.0.0
btcgroup: rawtransactions
permalink: en/doc/24.0.0/rpc/rawtransactions/sendrawtransaction/
---
sendrawtransaction "hexstring" ( maxfeerate )
Submit a raw transaction (serialized, hex-encoded) to local node and network.
The transaction will be sent unconditionally to all peers, so using sendrawtransaction
for manual rebroadcast may degrade privacy by leaking the transaction's origin, as
nodes will normally not rebroadcast non-wallet transactions already in their mempool.
A specific exception, RPC_TRANSACTION_ALREADY_IN_CHAIN, may throw if the transaction cannot be added to the mempool.
Related RPCs: createrawtransaction, signrawtransactionwithkey
Arguments:
1. hexstring (string, required) The hex string of the raw transaction
2. maxfeerate (numeric or string, optional, default="0.10") Reject transactions whose fee rate is higher than the specified value, expressed in BTC/kvB.
Set to 0 to accept any fee rate.
Result:
"hex" (string) The transaction hash in hex
Examples:
Create a transaction
> bitcoin-cli createrawtransaction "[{\"txid\" : \"mytxid\",\"vout\":0}]" "{\"myaddress\":0.01}"
Sign the transaction, and get back the hex
> bitcoin-cli signrawtransactionwithwallet "myhex"
Send the transaction (signed hex)
> bitcoin-cli sendrawtransaction "signedhex"
As a JSON-RPC call
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "sendrawtransaction", "params": ["signedhex"]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/
name: signrawtransactionwithkey
btcversion: 24.0.0
btcgroup: rawtransactions
permalink: en/doc/24.0.0/rpc/rawtransactions/signrawtransactionwithkey/
---
signrawtransactionwithkey "hexstring" ["privatekey",...] ( [{"txid":"hex","vout":n,"scriptPubKey":"hex","redeemScript":"hex","witnessScript":"hex","amount":amount},...] "sighashtype" )
Sign inputs for raw transaction (serialized, hex-encoded).
The second argument is an array of base58-encoded private
keys that will be the only keys used to sign the transaction.
The third optional argument (may be null) is an array of previous transaction outputs that
this transaction depends on but may not yet be in the block chain.
Arguments:
1. hexstring (string, required) The transaction hex string
2. privkeys (json array, required) The base58-encoded private keys for signing
[
"privatekey", (string) private key in base58-encoding
...
]
3. prevtxs (json array, optional) The previous dependent transaction outputs
[
{ (json object)
"txid": "hex", (string, required) The transaction id
"vout": n, (numeric, required) The output number
"scriptPubKey": "hex", (string, required) script key
"redeemScript": "hex", (string) (required for P2SH) redeem script
"witnessScript": "hex", (string) (required for P2WSH or P2SH-P2WSH) witness script
"amount": amount, (numeric or string) (required for Segwit inputs) the amount spent
},
...
]
4. sighashtype (string, optional, default="DEFAULT for Taproot, ALL otherwise") The signature hash type. Must be one of:
"DEFAULT"
"ALL"
"NONE"
"SINGLE"
"ALL|ANYONECANPAY"
"NONE|ANYONECANPAY"
"SINGLE|ANYONECANPAY"
Result:
{ (json object)
"hex" : "hex", (string) The hex-encoded raw transaction with signature(s)
"complete" : true|false, (boolean) If the transaction has a complete set of signatures
"errors" : [ (json array, optional) Script verification errors (if there are any)
{ (json object)
"txid" : "hex", (string) The hash of the referenced, previous transaction
"vout" : n, (numeric) The index of the output to spent and used as input
"witness" : [ (json array)
"hex", (string)
...
],
"scriptSig" : "hex", (string) The hex-encoded signature script
"sequence" : n, (numeric) Script sequence number
"error" : "str" (string) Verification or signing error related to the input
},
...
]
}
Examples:
> bitcoin-cli signrawtransactionwithkey "myhex" "[\"key1\",\"key2\"]"
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "signrawtransactionwithkey", "params": ["myhex", "[\"key1\",\"key2\"]"]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/
name: testmempoolaccept
btcversion: 24.0.0
btcgroup: rawtransactions
permalink: en/doc/24.0.0/rpc/rawtransactions/testmempoolaccept/
---
testmempoolaccept ["rawtx",...] ( maxfeerate )
Returns result of mempool acceptance tests indicating if raw transaction(s) (serialized, hex-encoded) would be accepted by mempool.
If multiple transactions are passed in, parents must come before children and package policies apply: the transactions cannot conflict with any mempool transactions or each other.
If one transaction fails, other transactions may not be fully validated (the 'allowed' key will be blank).
The maximum number of transactions allowed is 25.
This checks if transactions violate the consensus or policy rules.
See sendrawtransaction call.
Arguments:
1. rawtxs (json array, required) An array of hex strings of raw transactions.
[
"rawtx", (string)
...
]
2. maxfeerate (numeric or string, optional, default="0.10") Reject transactions whose fee rate is higher than the specified value, expressed in BTC/kvB
Result:
[ (json array) The result of the mempool acceptance test for each raw transaction in the input array.
Returns results for each transaction in the same order they were passed in.
Transactions that cannot be fully validated due to failures in other transactions will not contain an 'allowed' result.
{ (json object)
"txid" : "hex", (string) The transaction hash in hex
"wtxid" : "hex", (string) The transaction witness hash in hex
"package-error" : "str", (string, optional) Package validation error, if any (only possible if rawtxs had more than 1 transaction).
"allowed" : true|false, (boolean, optional) Whether this tx would be accepted to the mempool and pass client-specified maxfeerate. If not present, the tx was not fully validated due to a failure in another tx in the list.
"vsize" : n, (numeric, optional) Virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted (only present when 'allowed' is true)
"fees" : { (json object, optional) Transaction fees (only present if 'allowed' is true)
"base" : n (numeric) transaction fee in BTC
},
"reject-reason" : "str" (string, optional) Rejection string (only present when 'allowed' is false)
},
...
]
Examples:
Create a transaction
> bitcoin-cli createrawtransaction "[{\"txid\" : \"mytxid\",\"vout\":0}]" "{\"myaddress\":0.01}"
Sign the transaction, and get back the hex
> bitcoin-cli signrawtransactionwithwallet "myhex"
Test acceptance of the transaction (signed hex)
> bitcoin-cli testmempoolaccept '["signedhex"]'
As a JSON-RPC call
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "testmempoolaccept", "params": [["signedhex"]]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/
name: utxoupdatepsbt
btcversion: 24.0.0
btcgroup: rawtransactions
permalink: en/doc/24.0.0/rpc/rawtransactions/utxoupdatepsbt/
---
utxoupdatepsbt "psbt" ( ["",{"desc":"str","range":n or [n,n]},...] )
Updates all segwit inputs and outputs in a PSBT with data from output descriptors, the UTXO set or the mempool.
Arguments:
1. psbt (string, required) A base64 string of a PSBT
2. descriptors (json array, optional) An array of either strings or objects
[
"", (string) An output descriptor
{ (json object) An object with an output descriptor and extra information
"desc": "str", (string, required) An output descriptor
"range": n or [n,n], (numeric or array, optional, default=1000) Up to what index HD chains should be explored (either end or [begin,end])
},
...
]
Result:
"str" (string) The base64-encoded partially signed transaction with inputs updated
Examples:
> bitcoin-cli utxoupdatepsbt "psbt"