Skip to content

Commit

Permalink
Add rpc method for estimating smart fee
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladyslav Melnyk committed Sep 5, 2018
1 parent 4d97238 commit 2e20b7d
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.github.jleskovar</groupId>
<artifactId>btc-rpc-client</artifactId>
<version>1.2.0</version>
<version>1.2.1</version>
<packaging>jar</packaging>

<name>btc-rpc-client</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ interface AsyncBitcoinRpcClient {
@JsonRpcMethod("settxfee")
fun setTransactionFee(fee: Double): CompletableFuture<Void>

@JsonRpcMethod("estimatesmartfee")
fun estimateSmartFee(confTarget: Int, feeEstimateMode: FeeEstimateMode? = FeeEstimateMode.CONSERVATIVE): CompletableFuture<EstimateSmartFee>

@JsonRpcMethod("signmessage")
fun signMessage(
address: String,
Expand Down Expand Up @@ -326,20 +329,20 @@ interface AsyncBitcoinRpcClient {
@JsonRpcMethod("searchrawtransactions")
fun searchRawSerialisedTransactions(
address: String,
verbose: Int?=0,
skip: Int?=null,
count: Int?=null,
vInExtra: Int?=null,
reverse: Boolean?=null): CompletableFuture<List<String>>
verbose: Int? = 0,
skip: Int? = null,
count: Int? = null,
vInExtra: Int? = null,
reverse: Boolean? = null): CompletableFuture<List<String>>

@JsonRpcMethod("searchrawtransactions")
fun searchRawVerboseTransactions(
address: String,
verbose: Int?=1,
skip: Int?=null,
count: Int?=null,
vInExtra: Int?=null,
reverse: Boolean?=null): CompletableFuture<List<SearchedTransactionResult>>
verbose: Int? = 1,
skip: Int? = null,
count: Int? = null,
vInExtra: Int? = null,
reverse: Boolean? = null): CompletableFuture<List<SearchedTransactionResult>>

/**
* btcd-specific extension methods
Expand Down
23 changes: 13 additions & 10 deletions src/main/kotlin/com/github/jleskovar/btcrpc/BitcoinRpcClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ interface BitcoinRpcClient {
@JsonRpcMethod("settxfee")
fun setTransactionFee(fee: Double)

@JsonRpcMethod("estimatesmartfee")
fun estimateSmartFee(confTarget: Int, feeEstimateMode: FeeEstimateMode? = FeeEstimateMode.CONSERVATIVE): EstimateSmartFee

@JsonRpcMethod("signmessage")
fun signMessage(
address: String,
Expand Down Expand Up @@ -323,20 +326,20 @@ interface BitcoinRpcClient {
@JsonRpcMethod("searchrawtransactions")
fun searchRawSerialisedTransactions(
address: String,
verbose: Int?=0,
skip: Int?=null,
count: Int?=null,
vInExtra: Int?=null,
reverse: Boolean?=null): List<String>
verbose: Int? = 0,
skip: Int? = null,
count: Int? = null,
vInExtra: Int? = null,
reverse: Boolean? = null): List<String>

@JsonRpcMethod("searchrawtransactions")
fun searchRawVerboseTransactions(
address: String,
verbose: Int?=1,
skip: Int?=null,
count: Int?=null,
vInExtra: Int?=null,
reverse: Boolean?=null): List<SearchedTransactionResult>
verbose: Int? = 1,
skip: Int? = null,
count: Int? = null,
vInExtra: Int? = null,
reverse: Boolean? = null): List<SearchedTransactionResult>

/**
* btcd-specific extension methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,9 @@ data class SearchedTransactionResult(
val confirmations: Int? = null,
val time: Long? = null,
val blocktime: Long? = null)

data class EstimateSmartFee(
val feerate: BigDecimal? = null,
val errors: List<String>? = null,
val blocks: Long? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ class WrappedAsyncWebSocketBtcClient(
return delegate.setTransactionFee(fee)
}

override fun estimateSmartFee(confTarget: Int, feeEstimateMode: FeeEstimateMode?): CompletableFuture<EstimateSmartFee> {
return delegate.estimateSmartFee(confTarget, feeEstimateMode)
}

override fun signMessage(address: String, message: String): CompletableFuture<Void> {
return delegate.signMessage(address, message)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ class WrappedWebSocketBtcClient(
delegate.setTransactionFee(fee)
}

override fun estimateSmartFee(confTarget: Int, feeEstimateMode: FeeEstimateMode?): EstimateSmartFee {
return delegate.estimateSmartFee(confTarget, feeEstimateMode)
}

override fun signMessage(address: String, message: String) {
delegate.signMessage(address, message)
}
Expand Down

0 comments on commit 2e20b7d

Please sign in to comment.