Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#368 - add vbfi bitcoin_confirmation field to getblock #373

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.google.protobuf.ByteString
import nodecore.api.grpc.RpcAbandonAddressTransactionsRequest
import nodecore.api.grpc.RpcAbandonTransactionRequest
import nodecore.api.grpc.RpcAddressIndexPair
import nodecore.api.grpc.RpcGetLastBitcoinFinalizedBlockRequest
import nodecore.api.grpc.RpcGetPendingTransactionsRequest
import nodecore.api.grpc.RpcGetTransactionsRequest
import nodecore.api.grpc.RpcMakeUnsignedMultisigTxRequest
Expand Down Expand Up @@ -182,6 +183,24 @@ fun CommandFactory.transactionCommands() {
}
}

rpcCommand(
name = "Get last BTC finalized block",
form = "getlastbtcfinalizedblock",
description = "Gets information regarding last BTC finalized block by bitcoint confirmation number",
parameters = listOf(
CommandParameter(name = "bitcoinConfirmations", mapper = CommandParameterMappers.INTEGER, required = true)
)
) {
val bitcoinConfirmations: Int = getParameter("bitcoinConfirmations")
val request = RpcGetLastBitcoinFinalizedBlockRequest.newBuilder().setBitcoinConfirmations(bitcoinConfirmations)

val result = cliShell.adminService.getLastBitcoinFinalizedBlock(request.build())

prepareResult(result.success, result.resultsList) {
result.lastBtcFinalizedBlock
}
}

rpcCommand(
name = "Send",
form = "send|sendtoaddress|sendtoaddr",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import nodecore.api.grpc.RpcGetInfoReply
import nodecore.api.grpc.RpcGetInfoRequest
import nodecore.api.grpc.RpcGetLastBitcoinBlockReply
import nodecore.api.grpc.RpcGetLastBitcoinBlockRequest
import nodecore.api.grpc.RpcGetLastBitcoinFinalizedBlockReply
import nodecore.api.grpc.RpcGetLastBitcoinFinalizedBlockRequest
import nodecore.api.grpc.RpcGetNewAddressReply
import nodecore.api.grpc.RpcGetNewAddressRequest
import nodecore.api.grpc.RpcGetPeerInfoReply
Expand Down Expand Up @@ -149,6 +151,7 @@ interface AdminService {
fun getSignatureIndex(request: RpcGetSignatureIndexRequest): RpcGetSignatureIndexReply
fun setDefaultAddress(request: RpcSetDefaultAddressRequest): RpcSetDefaultAddressReply
fun getLastBitcoinBlock(request: RpcGetLastBitcoinBlockRequest): RpcGetLastBitcoinBlockReply
fun getLastBitcoinFinalizedBlock(request: RpcGetLastBitcoinFinalizedBlockRequest): RpcGetLastBitcoinFinalizedBlockReply
fun getProtectedChildren(request: RpcGetProtectedChildrenRequest): RpcGetProtectedChildrenReply
fun getProtectingParents(request: RpcGetProtectingParentsRequest): RpcGetProtectingParentsReply
fun restartPoolWebServer(request: RpcRestartPoolWebServerRequest): RpcRestartPoolWebServerReply
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ import nodecore.api.grpc.RpcGetInfoReply
import nodecore.api.grpc.RpcGetInfoRequest
import nodecore.api.grpc.RpcGetLastBitcoinBlockReply
import nodecore.api.grpc.RpcGetLastBitcoinBlockRequest
import nodecore.api.grpc.RpcGetLastBitcoinFinalizedBlockReply
import nodecore.api.grpc.RpcGetLastBitcoinFinalizedBlockRequest
import nodecore.api.grpc.RpcGetNewAddressReply
import nodecore.api.grpc.RpcGetNewAddressRequest
import nodecore.api.grpc.RpcGetPeerInfoReply
Expand Down Expand Up @@ -226,6 +228,8 @@ class AdminServiceClient(

override fun getLastBitcoinBlock(request: RpcGetLastBitcoinBlockRequest): RpcGetLastBitcoinBlockReply = blockingStub.getLastBitcoinBlock(request)

override fun getLastBitcoinFinalizedBlock(request: RpcGetLastBitcoinFinalizedBlockRequest): RpcGetLastBitcoinFinalizedBlockReply = blockingStub.getLastBitcoinFinalizedBlock(request)

override fun getPendingTransactions(request: RpcGetPendingTransactionsRequest): RpcGetPendingTransactionsReply = blockingStub.getPendingTransactions(request)

override fun getStateInfo(request: RpcGetStateInfoRequest): RpcGetStateInfoReply = blockingStub.getStateInfo(request)
Expand Down
31 changes: 31 additions & 0 deletions nodecore-grpc/src/main/proto/veriblock.proto
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,8 @@ message RpcEvent {
RpcGetStateInfoReply state_info_reply = 36;
RpcGetVtbsForBtcBlocksRequest vtb_for_btc_request = 37;
RpcGetVtbsForBtcBlocksReply vtb_for_btc_reply = 38;
RpcGetLastBitcoinFinalizedBlockRequest last_btc_finalized_block_request = 39;
RpcGetLastBitcoinFinalizedBlockReply last_btc_finalized_block_reply = 40;
}
string id = 11;
bool acknowledge = 12;
Expand Down Expand Up @@ -1035,6 +1037,28 @@ message RpcGetTransactionReply {
RpcTransactionInfo transaction = 3;
}

message RpcGetLastBitcoinFinalizedBlockRequest {
int32 bitcoinConfirmations = 1;
}

message RpcGetLastBitcoinFinalizedBlockReply {
bool success = 1;
repeated RpcResult results = 2;
RpcGetLastBitcoinFinalizedBlockInfo last_btc_finalized_block = 3;
}

message RpcGetLastBitcoinFinalizedBlockInfo {
int32 height = 1;
bytes hash = 2 [(hex_encoded)=true];
bool known = 3;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this field?

bool pop_verified = 4;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this

RpcVerifiedOrEndorsedInInfo verified_in = 5;
RpcVerifiedOrEndorsedInInfo endorsed_in = 6;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and above two

int32 sp_finality = 7;
int32 bitcoin_finality = 8;
bool is_attack_in_progress = 9;
}

message RpcTransactionInfo {
int32 confirmations = 1;
RpcTransaction transaction = 2;
Expand All @@ -1048,6 +1072,11 @@ message RpcTransactionInfo {
string merkle_path = 10;
}

message RpcVerifiedOrEndorsedInInfo {
int32 height = 1;
bytes hash = 2 [(hex_encoded)=true];
}

message RpcGetTransactionsReply {
bool success = 1;
repeated RpcResult results = 2;
Expand Down Expand Up @@ -1728,6 +1757,8 @@ service Admin {

rpc GetTransactions(RpcGetTransactionsRequest) returns (RpcGetTransactionsReply) {}

rpc GetLastBitcoinFinalizedBlock(RpcGetLastBitcoinFinalizedBlockRequest) returns (RpcGetLastBitcoinFinalizedBlockReply) {}

rpc ValidateAddress(RpcValidateAddressRequest) returns (RpcValidateAddressReply) {}

rpc GenerateMultisigAddress(RpcGenerateMultisigAddressRequest) returns (RpcGenerateMultisigAddressReply) {}
Expand Down