Skip to content

Commit

Permalink
feat: update rpc methods with bitcoin core v25.0 (#18)
Browse files Browse the repository at this point in the history
Co-authored-by: dolcalmi <dolcalmi@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and dolcalmi authored May 28, 2023
1 parent 9293f3d commit 4722255
Show file tree
Hide file tree
Showing 26 changed files with 144 additions and 61 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bitcoin-cli-ts",
"version": "24.1.0",
"version": "25.0.0",
"description": "Auto-generated Bitcoin client library for bitcoind JSON-RPC API",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down
3 changes: 3 additions & 0 deletions src/rpc/blockchain/get-block-from-peer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ type GetBlockFromPeerParams = {
* Attempt to fetch block from a given peer.
* We must have the header for this block, e.g. using submitheader.
* Subsequent calls for the same block and a new peer will cause the response from the previous peer to be ignored.
* Peers generally ignore requests for a stale block that they never fully verified, or one that is more than a month old.
* When a peer does not respond with a block, we will disconnect.
* Note: The block could be re-pruned as soon as it is received.
* Returns an empty JSON object if the request was successfully scheduled.
*
*/
Expand Down
1 change: 1 addition & 0 deletions src/rpc/blockchain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export * from './get-tx-spending-prevout'
export * from './precious-block'
export * from './prune-blockchain'
export * from './save-mempool'
export * from './scan-block-s'
export * from './scan-tx-outset'
export * from './verify-chain'
export * from './verify-tx-out-proof'
44 changes: 44 additions & 0 deletions src/rpc/blockchain/scan-block-s.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Auto synced from github actions. Don't change this file

import { Bitcoind, Json } from '../../types'
import request from '../../rpc-request'

type ScanBlockSParams = {
bitcoind: Bitcoind
/* The action to execute
"start" for starting a scan
"abort" for aborting the current scan (returns true when abort was successful)
"status" for progress report (in %) of the current scan */
action: string
/* [
"descriptor", (string) An output descriptor
{ (json object) An object with output descriptor and metadata
"desc": "str", (string, required) An output descriptor
"range": n or [n,n], (numeric or array, optional, default=1000) The range of HD chain indexes to explore (either end or [begin,end])
},
...
] */
scanobjects?: Array<unknown>
/* Height to start to scan from */
start_height?: number
/* Height to stop to scan */
stop_height?: number
/* The type name of the filter */
filtertype?: string
/* {
"filter_false_positives": bool, (boolean, optional, default=false) Filter false positives (slower and may fail on pruned nodes). Otherwise they may occur at a rate of 1/M
} */
options?: Json
}

/**
* scanblocks "action" ( [scanobjects,...] start_height stop_height "filtertype" "options" )
*
* Return relevant blockhashes for given descriptors (requires blockfilterindex).
* This call may take several minutes. Make sure to use no RPC timeout (bitcoin-cli -rpcclienttimeout=0)
*
*/
export function scanBlockS(params: ScanBlockSParams) {
const { bitcoind, ...methodParams } = params
return request({ method: 'scanblocks', params: methodParams }, bitcoind)
}
6 changes: 5 additions & 1 deletion src/rpc/blockchain/scan-tx-outset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type ScanTxOutsetParams = {
},
...
] */
scanobjects: Array<unknown>
scanobjects?: Array<unknown>
}

/**
Expand All @@ -31,6 +31,10 @@ type ScanTxOutsetParams = {
* combo(<pubkey>) P2PK, P2PKH, P2WPKH, and P2SH-P2WPKH outputs for the given pubkey
* pkh(<pubkey>) P2PKH outputs for the given pubkey
* sh(multi(<n>,<pubkey>,<pubkey>,...)) P2SH-multisig outputs for the given threshold and pubkeys
* tr(<pubkey>) P2TR
* tr(<pubkey>,{pk(<pubkey>)}) P2TR with single fallback pubkey in tapscript
* rawtr(<pubkey>) P2TR with the specified key as output key rather than inner
* wsh(and_v(v:pk(<pubkey>),after(2))) P2WSH miniscript with mandatory pubkey and a timelock
*
* In the above, <pubkey> either refers to a fixed public key in hexadecimal notation, or to an xpub/xprv optionally followed by one
* or more path elements separated by "/", and optionally ending in "/*" (unhardened), or "/*'" or "/*h" (hardened) to specify all
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/control/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type LoggingParams = {
* When called with arguments, adds or removes categories from debug logging and return the lists above.
* The arguments are evaluated in order "include", "exclude".
* If an item is both included and excluded, it will thus end up being excluded.
* The valid logging categories are: addrman, bench, blockstorage, cmpctblock, coindb, estimatefee, http, i2p, ipc, leveldb, libevent, mempool, mempoolrej, net, proxy, prune, qt, rand, reindex, rpc, selectcoins, tor, util, validation, walletdb, zmq
* The valid logging categories are: addrman, bench, blockstorage, cmpctblock, coindb, estimatefee, http, i2p, ipc, leveldb, libevent, mempool, mempoolrej, net, proxy, prune, qt, rand, reindex, rpc, scan, selectcoins, tor, txreconciliation, util, validation, walletdb, zmq
* In addition, the following are available as category names with special meanings:
* - "all", "1" : represent all logging categories.
* - "none", "0" : even if other logging categories are specified, ignore all of them.
Expand Down
4 changes: 3 additions & 1 deletion src/rpc/hidden/generate-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ type GenerateBlockParams = {
...
] */
transactions: Array<unknown>
/* Whether to submit the block before the RPC call returns or to return it as hex. */
submit?: boolean
}

/**
* generateblock "output" ["rawtx/txid",...]
* generateblock "output" ["rawtx/txid",...] ( submit )
*
* Mine a set of ordered transactions to a specified address or descriptor and return the block hash.
*
Expand Down
26 changes: 5 additions & 21 deletions src/rpc/rawtransactions/fund-raw-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,11 @@ type FundRawTransactionParams = {
bitcoind: Bitcoind
/* The hex string of the raw transaction */
hexstring: string
/* {
"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.
...
], */
/* { (json object)
"txid": "hex", (string, required) The transaction id
"vout": n, (numeric, required) The output index
"weight": n, (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.
}, */
options?: Json
/* Whether the transaction hex is a serialized witness transaction.
If iswitness is not present, heuristic tests will be used in decoding.
Expand Down
12 changes: 6 additions & 6 deletions src/rpc/rawtransactions/get-raw-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ type GetRawTransactionParams = {
bitcoind: Bitcoind
/* The transaction id */
txid: string
/* If false, return a string, otherwise return a json object */
verbose?: boolean
/* 0 for hex-encoded data, 1 for a JSON object, and 2 for JSON object with fee and prevout */
verbosity?: number
/* The block in which to look for the transaction */
blockhash?: string
}

/**
* getrawtransaction "txid" ( verbose "blockhash" )
* getrawtransaction "txid" ( verbosity "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'.
* If verbosity is 0 or omitted, returns the serialized transaction as a hex-encoded string.
* If verbosity is 1, returns a JSON Object with information about the transaction.
* If verbosity is 2, returns a JSON Object with information about the transaction, including fee and prevout information.
*
*/
export function getRawTransaction(params: GetRawTransactionParams) {
Expand Down
6 changes: 5 additions & 1 deletion src/rpc/rawtransactions/send-raw-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ type SendRawTransactionParams = {
/* Reject transactions whose fee rate is higher than the specified value, expressed in BTC/kvB.
Set to 0 to accept any fee rate. */
maxfeerate?: number | string
/* Reject transactions with provably unspendable outputs (e.g. 'datacarrier' outputs that use the OP_RETURN opcode) greater than the specified value, expressed in BTC.
If burning funds through unspendable outputs is desired, increase this value.
This check is based on heuristics and does not guarantee spendability of outputs. */
maxburnamount?: number | string
}

/**
* sendrawtransaction "hexstring" ( maxfeerate )
* sendrawtransaction "hexstring" ( maxfeerate maxburnamount )
*
* Submit a raw transaction (serialized, hex-encoded) to local node and network.
* The transaction will be sent unconditionally to all peers, so using sendrawtransaction
Expand Down
6 changes: 3 additions & 3 deletions src/rpc/rawtransactions/sign-raw-transaction-with-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ type SignRawTransactionWithKeyParams = {
"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
"redeemScript": "hex", (string, optional) (required for P2SH) redeem script
"witnessScript": "hex", (string, optional) (required for P2WSH or P2SH-P2WSH) witness script
"amount": amount, (numeric or string, optional) (required for Segwit inputs) the amount spent
},
...
] */
Expand Down
9 changes: 5 additions & 4 deletions src/rpc/util/derive-addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ type DeriveAddressesParams = {
*
* Derives one or more addresses corresponding to an output descriptor.
* Examples of output descriptors are:
* pkh(<pubkey>) P2PKH outputs for the given pubkey
* wpkh(<pubkey>) Native segwit P2PKH outputs for the given pubkey
* sh(multi(<n>,<pubkey>,<pubkey>,...)) P2SH-multisig outputs for the given threshold and pubkeys
* raw(<hex script>) Outputs whose scriptPubKey equals the specified hex scripts
* pkh(<pubkey>) P2PKH outputs for the given pubkey
* wpkh(<pubkey>) Native segwit P2PKH outputs for the given pubkey
* sh(multi(<n>,<pubkey>,<pubkey>,...)) P2SH-multisig outputs for the given threshold and pubkeys
* raw(<hex script>) Outputs whose scriptPubKey equals the specified hex scripts
* tr(<pubkey>,multi_a(<n>,<pubkey>,<pubkey>,...)) P2TR-multisig outputs for the given threshold and pubkeys
*
* In the above, <pubkey> either refers to a fixed public key in hexadecimal notation, or to an xpub/xprv optionally followed by one
* or more path elements separated by "/", where "h" represents a hardened child key.
Expand Down
15 changes: 14 additions & 1 deletion src/rpc/wallet/bump-fee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,20 @@ type BumpFeeParams = {
"unset"
"economical"
"conservative"
} */
"outputs": [ (json array, optional, default=[]) New outputs (key-value pairs) which will replace
the original ones, if provided. Each address can only appear once and there can
only be one "data" object.
{ (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
},
...
], */
options?: Json
}

Expand Down
5 changes: 3 additions & 2 deletions src/rpc/wallet/import-descriptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ type ImportDescriptorsParams = {
{ (json object)
"desc": "str", (string, required) Descriptor to import.
"active": bool, (boolean, optional, default=false) Set this descriptor to be the active descriptor for the corresponding output type/externality
"range": n or [n,n], (numeric or array) If a ranged descriptor is used, this specifies the end or the range (in the form [begin,end]) to import
"next_index": n, (numeric) If a ranged descriptor is set to active, this specifies the next index to generate addresses from
"range": n or [n,n], (numeric or array, optional) If a ranged descriptor is used, this specifies the end or the range (in the form [begin,end]) to import
"next_index": n, (numeric, optional) If a ranged descriptor is set to active, this specifies the next index to generate addresses from
"timestamp": timestamp | "now", (integer / string, required) Time from which to start rescanning the blockchain for this descriptor, in UNIX epoch time
Use the string "now" to substitute the current synced blockchain time.
"now" can be specified to bypass scanning, for outputs which are known to never have been used, and
Expand All @@ -30,6 +30,7 @@ type ImportDescriptorsParams = {
* Import descriptors. This will trigger a rescan of the blockchain based on the earliest timestamp of all descriptors being imported. Requires a new wallet backup.
* Note: This call can take over an hour to complete if using an early timestamp; during that time, other rpc calls
* may report that the imported keys, addresses or scripts exist but related transactions are still missing.
* The rescan is significantly faster if block filters are available (using startup option "-blockfilterindex=1").
*
*/
export function importDescriptors(params: ImportDescriptorsParams) {
Expand Down
6 changes: 3 additions & 3 deletions src/rpc/wallet/import-multi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ type ImportMultiParams = {
bitcoind: Bitcoind
/* [
{ (json object)
"desc": "str", (string) Descriptor to import. If using descriptor, do not also provide address/scriptPubKey, scripts, or pubkeys
"desc": "str", (string, optional) Descriptor to import. If using descriptor, do not also provide address/scriptPubKey, scripts, or pubkeys
"scriptPubKey": "<script>" | { "address":"<address>" }, (string / json, required) Type of scriptPubKey (string for script, json for address). Should not be provided if using a descriptor
"timestamp": timestamp | "now", (integer / string, required) Creation time of the key expressed in UNIX epoch time,
or the string "now" to substitute the current synced blockchain time. The timestamp of the oldest
key will determine how far back blockchain rescans need to begin for missing wallet transactions.
"now" can be specified to bypass scanning, for keys which are known to never have been used, and
0 can be specified to scan the entire blockchain. Blocks up to 2 hours before the earliest key
creation time of all keys being imported by the importmulti call will be scanned.
"redeemscript": "str", (string) Allowed only if the scriptPubKey is a P2SH or P2SH-P2WSH address/scriptPubKey
"witnessscript": "str", (string) Allowed only if the scriptPubKey is a P2SH-P2WSH or P2WSH address/scriptPubKey
"redeemscript": "str", (string, optional) Allowed only if the scriptPubKey is a P2SH or P2SH-P2WSH address/scriptPubKey
"witnessscript": "str", (string, optional) Allowed only if the scriptPubKey is a P2SH-P2WSH or P2WSH address/scriptPubKey
"pubkeys": [ (json array, optional, default=[]) Array of strings giving pubkeys to import. They must occur in P2PKH or P2WPKH scripts. They are not required when the private key is also provided (see the "keys" argument).
"pubKey", (string)
...
Expand Down
4 changes: 3 additions & 1 deletion src/rpc/wallet/list-since-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ type ListSinceBlockParams = {
include_removed?: boolean
/* Also add entries for change outputs. */
include_change?: boolean
/* Return only incoming transactions paying to addresses with the specified label. */
label?: string
}

/**
* listsinceblock ( "blockhash" target_confirmations include_watchonly include_removed include_change )
* listsinceblock ( "blockhash" target_confirmations include_watchonly include_removed include_change "label" )
*
* Get all transactions in blocks since block [blockhash], or all transactions if omitted.
* If "blockhash" is no longer a part of the main chain, transactions from the fork point onward are included.
Expand Down
Loading

0 comments on commit 4722255

Please sign in to comment.