Skip to content

Commit

Permalink
Added first API for raw transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
bpfaff committed May 28, 2018
1 parent e6a4d4b commit 3da62cd
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 2 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
export(addnode)
export(clearbanned)
export(conrpc)
export(decoderawtransaction)
export(disconnectnode)
export(getaddednodeinfo)
export(getbestblockhash)
Expand All @@ -25,6 +26,7 @@ export(getnettotals)
export(getnetworkinfo)
export(getpeerinfo)
export(getrawmempool)
export(getrawtransaction)
export(gettxout)
export(gettxoutproof)
export(gettxoutsetinfo)
Expand Down
8 changes: 6 additions & 2 deletions R/AllClasses.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,21 @@ setClass("CONRPC", representation = list(
#' @description
#' S4-class union of \code{NULL} or \code{character}.
#' @family bitcoind functions
#' @name NullOrCharacter-class
#' @rdname NullOrCharacter-class
#' @export
setClassUnion(name = "NullOrCharacter",
members = c("NULL", "character"))
members = c("character", "NULL"))
#' @title S4 Class Union NULL or integer
#'
#' @description
#' S4-class union of \code{NULL} or \code{integer}.
#' @family bitcoind functions
#' @name NullOrInteger-class
#' @rdname NullOrInteger-class
#' @export
setClassUnion(name = "NullOrInteger",
members = c("NULL", "integer"))
members = c("integer", "NULL"))
#' The ANSRPC class
#'
#' This class definition is employed to cast the JSON-objects
Expand Down
56 changes: 56 additions & 0 deletions R/Rawtransactions.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#' RPC-JSON API: getrawtransaction
#'
#' Returns the raw transaction data.
#'
#' @section: Details
#' By default this function only works for mempool transactions.
#' If the -txindex option is enabled, it also works for blockchain transactions.
#' DEPRECATED: for now, it also works for transactions with unspent outputs.
#' 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'.
#'
#' @param obj object of class \code{CONRPC}.
#' @param txid \code{character}, the transaction id.
#' @param verbose \code{logical}, type of output.
#'
#' @return A S4-object of class \code{ANSRPC}.
#' @family RawTransactions RPCs
#' @author Bernhard Pfaff
#' @references \url{https://bitcoin.org/en/developer-reference#getblock},
#' \url{https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs}
#' @name getrawtransaction
#' @aliases getrawtransaction
#' @rdname getrawtransaction
#' @export
getrawtransaction <- function(obj, txid, verbose = FALSE){
txid <- as.character(txid)
verb <- ifelse(verbose, 1L, 0L)
pl <- list(txid = txid, verbose = verb)
rpcpost(obj, "getrawtransaction", pl)
}



#' RPC-JSON API: decoderawtransaction
#'
#' Return a JSON object representing the serialized,
#' hex-encoded transaction.
#'
#' @param obj object of class \code{CONRPC}.
#' @param hexstring \code{character}, the transaction hex string.
#'
#' @return A S4-object of class \code{ANSRPC}.
#' @family RawTransactions RPCs
#' @author Bernhard Pfaff
#' @references \url{https://bitcoin.org/en/developer-reference#getblock},
#' \url{https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs}
#' @name decoderawtransaction
#' @aliases decoderawtransaction
#' @rdname decoderawtransaction
#' @export
decoderawtransaction <- function(obj, hexstring){
hexstring <- as.character(hexstring)
pl <- list(hexstring = hexstring)
rpcpost(obj, "decoderawtransaction", pl)
}
30 changes: 30 additions & 0 deletions man/decoderawtransaction.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions man/getrawtransaction.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3da62cd

Please sign in to comment.