diff --git a/proto/cusf/common/v1/common.proto b/proto/cusf/common/v1/common.proto index bbc6681..104bf59 100644 --- a/proto/cusf/common/v1/common.proto +++ b/proto/cusf/common/v1/common.proto @@ -13,4 +13,17 @@ message ConsensusHex { /// Reverse-encoded hex message ReverseHex { google.protobuf.StringValue hex = 1; -} \ No newline at end of file +} + +message SidechainDeclarationV0 { + google.protobuf.StringValue title = 1; + google.protobuf.StringValue description = 2; + ConsensusHex hash_id_1 = 3; + ConsensusHex hash_id_2 = 4; +} + +message SidechainDeclaration { + oneof version { + SidechainDeclarationV0 v0 = 1; + } +} diff --git a/proto/cusf/mainchain/v1/common.proto b/proto/cusf/mainchain/v1/common.proto new file mode 100644 index 0000000..3a3a15e --- /dev/null +++ b/proto/cusf/mainchain/v1/common.proto @@ -0,0 +1,25 @@ +/* Common message types */ + +syntax = "proto3"; +package cusf.mainchain.v1; + +import "google/protobuf/wrappers.proto"; + +import "cusf/common/v1/common.proto"; + +message OutPoint { + cusf.common.v1.ReverseHex txid = 1; + google.protobuf.UInt32Value vout = 2; +} + +message SidechainDeclaration { + message V0 { + google.protobuf.StringValue title = 1; + google.protobuf.StringValue description = 2; + cusf.common.v1.ConsensusHex hash_id_1 = 3; + cusf.common.v1.ConsensusHex hash_id_2 = 4; + } + oneof sidechain_declaration { + V0 v0 = 1; + } +} diff --git a/proto/cusf/mainchain/v1/validator.proto b/proto/cusf/mainchain/v1/validator.proto index 9b9e927..28532e2 100644 --- a/proto/cusf/mainchain/v1/validator.proto +++ b/proto/cusf/mainchain/v1/validator.proto @@ -6,6 +6,7 @@ package cusf.mainchain.v1; import "google/protobuf/wrappers.proto"; import "cusf/common/v1/common.proto"; +import "cusf/mainchain/v1/common.proto"; message BlockHeaderInfo { cusf.common.v1.ReverseHex block_hash = 1; @@ -24,11 +25,6 @@ enum Network { NETWORK_TESTNET = 5; } -message OutPoint { - cusf.common.v1.ConsensusHex txid = 1; - uint32 vout = 2; -} - message Output { cusf.common.v1.ConsensusHex address = 2; uint64 value_sats = 3; @@ -59,19 +55,6 @@ message BlockInfo { optional cusf.common.v1.ConsensusHex bmm_commitment = 3; } -message SidechainDeclarationV0 { - google.protobuf.StringValue title = 1; - google.protobuf.StringValue description = 2; - cusf.common.v1.ConsensusHex hash_id_1 = 3; - cusf.common.v1.ConsensusHex hash_id_2 = 4; -} - -message SidechainDeclaration { - oneof version { - SidechainDeclarationV0 v0 = 1; - } -} - service ValidatorService { rpc GetBlockHeaderInfo(GetBlockHeaderInfoRequest) returns (GetBlockHeaderInfoResponse); @@ -147,7 +130,7 @@ message GetCoinbasePSBTRequest { } message ProposeBundle { google.protobuf.UInt32Value sidechain_number = 1; - cusf.common.v1.ConsensusHex bundle_txid = 2; + cusf.common.v1.ReverseHex bundle_txid = 2; } message AckBundles { message RepeatPrevious { @@ -178,7 +161,7 @@ message GetCtipRequest { } message GetCtipResponse { message Ctip { - cusf.common.v1.ConsensusHex txid = 1; + cusf.common.v1.ReverseHex txid = 1; uint32 vout = 2; uint64 value = 3; uint64 sequence_number = 4; @@ -190,24 +173,19 @@ message GetSidechainProposalsRequest { } message GetSidechainProposalsResponse { message SidechainProposal { - uint32 sidechain_number = 1; - - // protolint:disable MAX_LINE_LENGTH - - // Raw sidechain proposal data (M1 message of BIP300) - // https://github.com/bitcoin/bips/blob/master/bip-0300.mediawiki#m1----propose-sidechain - google.protobuf.BytesValue data = 2; + google.protobuf.UInt32Value sidechain_number = 1; - // protolint:enable MAX_LINE_LENGTH + // Raw sidechain proposal description + cusf.common.v1.ConsensusHex description = 2; // Sidechain data, as declared in the M1 proposal. // Might be nil, if the proposal uses an unknown version. optional SidechainDeclaration declaration = 7; - cusf.common.v1.ConsensusHex data_hash = 3; - uint32 vote_count = 4; - uint32 proposal_height = 5; - uint32 proposal_age = 6; + cusf.common.v1.ReverseHex description_sha256d_hash = 3; + google.protobuf.UInt32Value vote_count = 4; + google.protobuf.UInt32Value proposal_height = 5; + google.protobuf.UInt32Value proposal_age = 6; } repeated SidechainProposal sidechain_proposals = 1; } @@ -216,11 +194,11 @@ message GetSidechainsRequest { } message GetSidechainsResponse { message SidechainInfo { - uint32 sidechain_number = 1; - google.protobuf.BytesValue data = 2; - uint32 vote_count = 3; - uint32 proposal_height = 4; - uint32 activation_height = 5; + google.protobuf.UInt32Value sidechain_number = 1; + cusf.common.v1.ConsensusHex description = 2; + google.protobuf.UInt32Value vote_count = 3; + google.protobuf.UInt32Value proposal_height = 4; + google.protobuf.UInt32Value activation_height = 5; } repeated SidechainInfo sidechains = 1; } diff --git a/proto/cusf/mainchain/v1/wallet.proto b/proto/cusf/mainchain/v1/wallet.proto index bbbab31..f4b2315 100644 --- a/proto/cusf/mainchain/v1/wallet.proto +++ b/proto/cusf/mainchain/v1/wallet.proto @@ -6,6 +6,7 @@ package cusf.mainchain.v1; import "google/protobuf/wrappers.proto"; import "cusf/common/v1/common.proto"; +import "cusf/mainchain/v1/common.proto"; service WalletService { rpc BroadcastWithdrawalBundle(BroadcastWithdrawalBundleRequest) @@ -16,6 +17,14 @@ service WalletService { returns (CreateDepositTransactionResponse); rpc CreateNewAddress(CreateNewAddressRequest) returns (CreateNewAddressResponse); + // Create a new sidechain proposal (M1 in BIP300) and persist to the local + // database for further processing. + // Sidechain proposals must be included in the coinbase transaction of a + // newly mined block, so this proposal is not active until the wallet has + // been able to generate a new block. + // Returns a stream of (non-)confirmation events for the sidechain proposal. + rpc CreateSidechainProposal(CreateSidechainProposalRequest) + returns (stream CreateSidechainProposalResponse); // Regtest only rpc GenerateBlocks(GenerateBlocksRequest) returns (GenerateBlocksResponse); @@ -36,7 +45,7 @@ message CreateBmmCriticalDataTransactionRequest { cusf.common.v1.ReverseHex prev_bytes = 5; } message CreateBmmCriticalDataTransactionResponse { - cusf.common.v1.ConsensusHex txid = 1; + cusf.common.v1.ReverseHex txid = 1; } message CreateDepositTransactionRequest { @@ -46,7 +55,7 @@ message CreateDepositTransactionRequest { uint64 fee_sats = 4; } message CreateDepositTransactionResponse { - cusf.common.v1.ConsensusHex txid = 1; + cusf.common.v1.ReverseHex txid = 1; } message CreateNewAddressRequest { @@ -56,6 +65,30 @@ message CreateNewAddressResponse { string address = 1; } +message CreateSidechainProposalRequest { + google.protobuf.UInt32Value sidechain_id = 1; + SidechainDeclaration declaration = 2; +} + +message CreateSidechainProposalResponse { + message Confirmed { + cusf.common.v1.ReverseHex block_hash = 1; + google.protobuf.UInt32Value confirmations = 2; + google.protobuf.UInt32Value height = 3; + OutPoint outpoint = 4; + cusf.common.v1.ReverseHex prev_block_hash = 5; + } + message NotConfirmed { + cusf.common.v1.ReverseHex block_hash = 1; + google.protobuf.UInt32Value height = 2; + cusf.common.v1.ReverseHex prev_block_hash = 3; + } + oneof event { + Confirmed confirmed = 1; + NotConfirmed not_confirmed = 2; + } +} + message GenerateBlocksRequest { google.protobuf.UInt32Value blocks = 1; }