update protobuf files from lightwalletd's commit `68789356fb1a75f62735a529b38389ef08ea7582`

This commit is contained in:
Francisco Gindre 2022-04-27 16:19:25 -03:00 committed by Kris Nuttycombe
parent 72c1f14aa6
commit e179153420
5 changed files with 142 additions and 20 deletions

View File

@ -81,19 +81,21 @@ struct CompactTx {
var fee: UInt32 = 0 var fee: UInt32 = 0
/// inputs /// inputs
var spends: [CompactSpend] = [] var spends: [CompactSaplingSpend] = []
/// outputs /// outputs
var outputs: [CompactOutput] = [] var outputs: [CompactSaplingOutput] = []
var actions: [CompactOrchardAction] = []
var unknownFields = SwiftProtobuf.UnknownStorage() var unknownFields = SwiftProtobuf.UnknownStorage()
init() {} init() {}
} }
/// CompactSpend is a Sapling Spend Description as described in 7.3 of the Zcash /// CompactSaplingSpend is a Sapling Spend Description as described in 7.3 of the Zcash
/// protocol specification. /// protocol specification.
struct CompactSpend { struct CompactSaplingSpend {
// SwiftProtobuf.Message conformance is added in an extension below. See the // SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages. // methods supported on all messages.
@ -108,7 +110,7 @@ struct CompactSpend {
/// output is a Sapling Output Description as described in section 7.4 of the /// output is a Sapling Output Description as described in section 7.4 of the
/// Zcash protocol spec. Total size is 948. /// Zcash protocol spec. Total size is 948.
struct CompactOutput { struct CompactSaplingOutput {
// SwiftProtobuf.Message conformance is added in an extension below. See the // SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages. // methods supported on all messages.
@ -119,7 +121,31 @@ struct CompactOutput {
/// ephemeral public key /// ephemeral public key
var epk: Data = SwiftProtobuf.Internal.emptyData var epk: Data = SwiftProtobuf.Internal.emptyData
/// ciphertext and zkproof /// first 52 bytes of ciphertext
var ciphertext: Data = SwiftProtobuf.Internal.emptyData
var unknownFields = SwiftProtobuf.UnknownStorage()
init() {}
}
/// https://github.com/zcash/zips/blob/main/zip-0225.rst#orchard-action-description-orchardaction
/// (but not all fields are needed)
struct CompactOrchardAction {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
/// [32] The nullifier of the input note
var nullifier: Data = SwiftProtobuf.Internal.emptyData
/// [32] The x-coordinate of the note commitment for the output note
var cmx: Data = SwiftProtobuf.Internal.emptyData
/// [32] An encoding of an ephemeral Pallas public key
var ephemeralKey: Data = SwiftProtobuf.Internal.emptyData
/// [52] The note plaintext component of the encCiphertext field
var ciphertext: Data = SwiftProtobuf.Internal.emptyData var ciphertext: Data = SwiftProtobuf.Internal.emptyData
var unknownFields = SwiftProtobuf.UnknownStorage() var unknownFields = SwiftProtobuf.UnknownStorage()
@ -204,6 +230,7 @@ extension CompactTx: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementation
3: .same(proto: "fee"), 3: .same(proto: "fee"),
4: .same(proto: "spends"), 4: .same(proto: "spends"),
5: .same(proto: "outputs"), 5: .same(proto: "outputs"),
6: .same(proto: "actions"),
] ]
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws { mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
@ -214,6 +241,7 @@ extension CompactTx: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementation
case 3: try decoder.decodeSingularUInt32Field(value: &self.fee) case 3: try decoder.decodeSingularUInt32Field(value: &self.fee)
case 4: try decoder.decodeRepeatedMessageField(value: &self.spends) case 4: try decoder.decodeRepeatedMessageField(value: &self.spends)
case 5: try decoder.decodeRepeatedMessageField(value: &self.outputs) case 5: try decoder.decodeRepeatedMessageField(value: &self.outputs)
case 6: try decoder.decodeRepeatedMessageField(value: &self.actions)
default: break default: break
} }
} }
@ -235,6 +263,9 @@ extension CompactTx: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementation
if !self.outputs.isEmpty { if !self.outputs.isEmpty {
try visitor.visitRepeatedMessageField(value: self.outputs, fieldNumber: 5) try visitor.visitRepeatedMessageField(value: self.outputs, fieldNumber: 5)
} }
if !self.actions.isEmpty {
try visitor.visitRepeatedMessageField(value: self.actions, fieldNumber: 6)
}
try unknownFields.traverse(visitor: &visitor) try unknownFields.traverse(visitor: &visitor)
} }
@ -244,13 +275,14 @@ extension CompactTx: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementation
if lhs.fee != rhs.fee {return false} if lhs.fee != rhs.fee {return false}
if lhs.spends != rhs.spends {return false} if lhs.spends != rhs.spends {return false}
if lhs.outputs != rhs.outputs {return false} if lhs.outputs != rhs.outputs {return false}
if lhs.actions != rhs.actions {return false}
if lhs.unknownFields != rhs.unknownFields {return false} if lhs.unknownFields != rhs.unknownFields {return false}
return true return true
} }
} }
extension CompactSpend: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { extension CompactSaplingSpend: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".CompactSpend" static let protoMessageName: String = _protobuf_package + ".CompactSaplingSpend"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "nf"), 1: .same(proto: "nf"),
] ]
@ -271,15 +303,15 @@ extension CompactSpend: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat
try unknownFields.traverse(visitor: &visitor) try unknownFields.traverse(visitor: &visitor)
} }
static func ==(lhs: CompactSpend, rhs: CompactSpend) -> Bool { static func ==(lhs: CompactSaplingSpend, rhs: CompactSaplingSpend) -> Bool {
if lhs.nf != rhs.nf {return false} if lhs.nf != rhs.nf {return false}
if lhs.unknownFields != rhs.unknownFields {return false} if lhs.unknownFields != rhs.unknownFields {return false}
return true return true
} }
} }
extension CompactOutput: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { extension CompactSaplingOutput: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".CompactOutput" static let protoMessageName: String = _protobuf_package + ".CompactSaplingOutput"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "cmu"), 1: .same(proto: "cmu"),
2: .same(proto: "epk"), 2: .same(proto: "epk"),
@ -310,7 +342,7 @@ extension CompactOutput: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementa
try unknownFields.traverse(visitor: &visitor) try unknownFields.traverse(visitor: &visitor)
} }
static func ==(lhs: CompactOutput, rhs: CompactOutput) -> Bool { static func ==(lhs: CompactSaplingOutput, rhs: CompactSaplingOutput) -> Bool {
if lhs.cmu != rhs.cmu {return false} if lhs.cmu != rhs.cmu {return false}
if lhs.epk != rhs.epk {return false} if lhs.epk != rhs.epk {return false}
if lhs.ciphertext != rhs.ciphertext {return false} if lhs.ciphertext != rhs.ciphertext {return false}
@ -318,3 +350,50 @@ extension CompactOutput: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementa
return true return true
} }
} }
extension CompactOrchardAction: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".CompactOrchardAction"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "nullifier"),
2: .same(proto: "cmx"),
3: .same(proto: "ephemeralKey"),
4: .same(proto: "ciphertext"),
]
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
while let fieldNumber = try decoder.nextFieldNumber() {
switch fieldNumber {
case 1: try decoder.decodeSingularBytesField(value: &self.nullifier)
case 2: try decoder.decodeSingularBytesField(value: &self.cmx)
case 3: try decoder.decodeSingularBytesField(value: &self.ephemeralKey)
case 4: try decoder.decodeSingularBytesField(value: &self.ciphertext)
default: break
}
}
}
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
if !self.nullifier.isEmpty {
try visitor.visitSingularBytesField(value: self.nullifier, fieldNumber: 1)
}
if !self.cmx.isEmpty {
try visitor.visitSingularBytesField(value: self.cmx, fieldNumber: 2)
}
if !self.ephemeralKey.isEmpty {
try visitor.visitSingularBytesField(value: self.ephemeralKey, fieldNumber: 3)
}
if !self.ciphertext.isEmpty {
try visitor.visitSingularBytesField(value: self.ciphertext, fieldNumber: 4)
}
try unknownFields.traverse(visitor: &visitor)
}
static func ==(lhs: CompactOrchardAction, rhs: CompactOrchardAction) -> Bool {
if lhs.nullifier != rhs.nullifier {return false}
if lhs.cmx != rhs.cmx {return false}
if lhs.ephemeralKey != rhs.ephemeralKey {return false}
if lhs.ciphertext != rhs.ciphertext {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}
}

View File

@ -37,20 +37,30 @@ message CompactTx {
// valueBalance + (sum(vPubNew) - sum(vPubOld) - sum(tOut)) // valueBalance + (sum(vPubNew) - sum(vPubOld) - sum(tOut))
uint32 fee = 3; uint32 fee = 3;
repeated CompactSpend spends = 4; // inputs repeated CompactSaplingSpend spends = 4; // inputs
repeated CompactOutput outputs = 5; // outputs repeated CompactSaplingOutput outputs = 5; // outputs
repeated CompactOrchardAction actions = 6;
} }
// CompactSpend is a Sapling Spend Description as described in 7.3 of the Zcash // CompactSaplingSpend is a Sapling Spend Description as described in 7.3 of the Zcash
// protocol specification. // protocol specification.
message CompactSpend { message CompactSaplingSpend {
bytes nf = 1; // nullifier (see the Zcash protocol specification) bytes nf = 1; // nullifier (see the Zcash protocol specification)
} }
// output is a Sapling Output Description as described in section 7.4 of the // output is a Sapling Output Description as described in section 7.4 of the
// Zcash protocol spec. Total size is 948. // Zcash protocol spec. Total size is 948.
message CompactOutput { message CompactSaplingOutput {
bytes cmu = 1; // note commitment u-coordinate bytes cmu = 1; // note commitment u-coordinate
bytes epk = 2; // ephemeral public key bytes epk = 2; // ephemeral public key
bytes ciphertext = 3; // ciphertext and zkproof bytes ciphertext = 3; // first 52 bytes of ciphertext
}
// https://github.com/zcash/zips/blob/main/zip-0225.rst#orchard-action-description-orchardaction
// (but not all fields are needed)
message CompactOrchardAction {
bytes nullifier = 1; // [32] The nullifier of the input note
bytes cmx = 2; // [32] The x-coordinate of the note commitment for the output note
bytes ephemeralKey = 3; // [32] An encoding of an ephemeral Pallas public key
bytes ciphertext = 4; // [52] The note plaintext component of the encCiphertext field
} }

View File

@ -32,7 +32,8 @@ message TxFilter {
} }
// RawTransaction contains the complete transaction data. It also optionally includes // RawTransaction contains the complete transaction data. It also optionally includes
// the block height in which the transaction was included. // the block height in which the transaction was included, or, when returned
// by GetMempoolStream(), the latest block height.
message RawTransaction { message RawTransaction {
bytes data = 1; // exact data returned by Zcash 'getrawtransaction' bytes data = 1; // exact data returned by Zcash 'getrawtransaction'
uint64 height = 2; // height that the transaction was mined (or -1) uint64 height = 2; // height that the transaction was mined (or -1)
@ -164,6 +165,10 @@ service CompactTxStreamer {
// in the exclude list that don't exist in the mempool are ignored. // in the exclude list that don't exist in the mempool are ignored.
rpc GetMempoolTx(Exclude) returns (stream CompactTx) {} rpc GetMempoolTx(Exclude) returns (stream CompactTx) {}
// Return a stream of current Mempool transactions. This will keep the output stream open while
// there are mempool transactions. It will close the returned stream when a new block is mined.
rpc GetMempoolStream(Empty) returns (stream RawTransaction) {}
// GetTreeState returns the note commitment tree state corresponding to the given block. // GetTreeState returns the note commitment tree state corresponding to the given block.
// See section 3.7 of the Zcash protocol specification. It returns several other useful // See section 3.7 of the Zcash protocol specification. It returns several other useful
// values also (even though they can be obtained using GetBlock). // values also (even though they can be obtained using GetBlock).

View File

@ -74,6 +74,12 @@ internal protocol CompactTxStreamerClientProtocol: GRPCClient {
handler: @escaping (CompactTx) -> Void handler: @escaping (CompactTx) -> Void
) -> ServerStreamingCall<Exclude, CompactTx> ) -> ServerStreamingCall<Exclude, CompactTx>
func getMempoolStream(
_ request: Empty,
callOptions: CallOptions?,
handler: @escaping (RawTransaction) -> Void
) -> ServerStreamingCall<Empty, RawTransaction>
func getTreeState( func getTreeState(
_ request: BlockID, _ request: BlockID,
callOptions: CallOptions? callOptions: CallOptions?
@ -274,6 +280,27 @@ extension CompactTxStreamerClientProtocol {
) )
} }
/// Return a stream of current Mempool transactions. This will keep the output stream open while
/// there are mempool transactions. It will close the returned stream when a new block is mined.
///
/// - Parameters:
/// - request: Request to send to GetMempoolStream.
/// - callOptions: Call options.
/// - handler: A closure called when each response is received from the server.
/// - Returns: A `ServerStreamingCall` with futures for the metadata and status.
internal func getMempoolStream(
_ request: Empty,
callOptions: CallOptions? = nil,
handler: @escaping (RawTransaction) -> Void
) -> ServerStreamingCall<Empty, RawTransaction> {
return self.makeServerStreamingCall(
path: "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetMempoolStream",
request: request,
callOptions: callOptions ?? self.defaultCallOptions,
handler: handler
)
}
/// GetTreeState returns the note commitment tree state corresponding to the given block. /// GetTreeState returns the note commitment tree state corresponding to the given block.
/// See section 3.7 of the Zcash protocol specification. It returns several other useful /// See section 3.7 of the Zcash protocol specification. It returns several other useful
/// values also (even though they can be obtained using GetBlock). /// values also (even though they can be obtained using GetBlock).

View File

@ -105,7 +105,8 @@ struct TxFilter {
} }
/// RawTransaction contains the complete transaction data. It also optionally includes /// RawTransaction contains the complete transaction data. It also optionally includes
/// the block height in which the transaction was included. /// the block height in which the transaction was included, or, when returned
/// by GetMempoolStream(), the latest block height.
struct RawTransaction { struct RawTransaction {
// SwiftProtobuf.Message conformance is added in an extension below. See the // SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for // `Message` and `Message+*Additions` files in the SwiftProtobuf library for