diff --git a/NAMESPACE b/NAMESPACE index d0a633c..775d7cb 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,6 +3,7 @@ export(addnode) export(clearbanned) export(conrpc) +export(decoderawtransaction) export(disconnectnode) export(getaddednodeinfo) export(getbestblockhash) @@ -25,6 +26,7 @@ export(getnettotals) export(getnetworkinfo) export(getpeerinfo) export(getrawmempool) +export(getrawtransaction) export(gettxout) export(gettxoutproof) export(gettxoutsetinfo) diff --git a/R/AllClasses.R b/R/AllClasses.R index 0ee19a2..2e1b0db 100644 --- a/R/AllClasses.R +++ b/R/AllClasses.R @@ -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 diff --git a/R/Rawtransactions.R b/R/Rawtransactions.R new file mode 100644 index 0000000..8291e4c --- /dev/null +++ b/R/Rawtransactions.R @@ -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) +} diff --git a/man/decoderawtransaction.Rd b/man/decoderawtransaction.Rd new file mode 100644 index 0000000..d1ad5f8 --- /dev/null +++ b/man/decoderawtransaction.Rd @@ -0,0 +1,30 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/Rawtransactions.R +\name{decoderawtransaction} +\alias{decoderawtransaction} +\title{RPC-JSON API: decoderawtransaction} +\usage{ +decoderawtransaction(obj, hexstring) +} +\arguments{ +\item{obj}{object of class \code{CONRPC}.} + +\item{hexstring}{\code{character}, the transaction hex string.} +} +\value{ +A S4-object of class \code{ANSRPC}. +} +\description{ +Return a JSON object representing the serialized, +hex-encoded transaction. +} +\references{ +\url{https://bitcoin.org/en/developer-reference#getblock}, +\url{https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs} +} +\seealso{ +Other RawTransactions RPCs: \code{\link{getrawtransaction}} +} +\author{ +Bernhard Pfaff +} diff --git a/man/getrawtransaction.Rd b/man/getrawtransaction.Rd new file mode 100644 index 0000000..02d9b20 --- /dev/null +++ b/man/getrawtransaction.Rd @@ -0,0 +1,41 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/Rawtransactions.R +\name{getrawtransaction} +\alias{getrawtransaction} +\title{RPC-JSON API: getrawtransaction} +\usage{ +getrawtransaction(obj, txid, verbose = FALSE) +} +\arguments{ +\item{obj}{object of class \code{CONRPC}.} + +\item{txid}{\code{character}, the transaction id.} + +\item{verbose}{\code{logical}, type of output.} +} +\value{ +A S4-object of class \code{ANSRPC}. +} +\description{ +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'. +} + +\references{ +\url{https://bitcoin.org/en/developer-reference#getblock}, +\url{https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs} +} +\seealso{ +Other RawTransactions RPCs: \code{\link{decoderawtransaction}} +} +\author{ +Bernhard Pfaff +}