2012-01-11 10:04:00 -08:00
|
|
|
/** Copyright 2012 Google Inc.
|
2012-01-06 14:50:34 -08:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2012-01-11 10:04:00 -08:00
|
|
|
* Authors: Jim Burton, Miron Cuperman
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Notes:
|
|
|
|
* - Endianness: All byte arrays that represent numbers (such as hashes and private keys) are Big Endian (a.k.a. network order)
|
2012-01-06 14:50:34 -08:00
|
|
|
*/
|
|
|
|
|
|
|
|
package wallet;
|
|
|
|
|
|
|
|
option java_package = "org.bitcoinj.wallet";
|
|
|
|
option java_outer_classname = "Protos";
|
|
|
|
|
2012-01-10 11:10:15 -08:00
|
|
|
message Key {
|
2012-01-11 10:04:00 -08:00
|
|
|
enum Type {
|
|
|
|
ORIGINAL = 1; // Original bitcoin secp256k1 curve
|
|
|
|
}
|
|
|
|
required bytes private_key = 1; // integer representation of the EC private key
|
|
|
|
required Type type = 2;
|
|
|
|
optional string label = 3; // for presentation purposes
|
|
|
|
optional int64 creation_timestamp = 4; // datetime stored as millis since epoch.
|
2012-01-10 11:10:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
message TransactionInput {
|
|
|
|
// Sha256Hash of transaction output this input is using
|
|
|
|
required bytes transaction_out_point_hash = 1;
|
|
|
|
// index of transaction output used by this input if in this wallet
|
|
|
|
required int32 transaction_out_point_index = 2;
|
|
|
|
required bytes script_bytes = 3; // script of transaction input
|
2012-01-11 10:04:00 -08:00
|
|
|
optional uint32 sequence = 4; // currently unused field in bitcoin, was originally planned for contracts
|
2012-01-10 11:10:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
message TransactionOutput {
|
|
|
|
required int64 value = 1;
|
|
|
|
required bytes script_bytes = 2; // script of transaction output
|
|
|
|
optional bytes spent_by_transaction_hash = 3; // if spent, the Sha256Hash of the transaction doing the spend
|
|
|
|
optional int32 spent_by_transaction_index = 4;
|
|
|
|
// if spent, the index of the transaction output of the transaction doing the spend
|
|
|
|
}
|
|
|
|
|
2012-01-25 10:40:20 -08:00
|
|
|
message TransactionConfidence {
|
|
|
|
enum Type {
|
|
|
|
UNKNOWN = 0;
|
|
|
|
BUILDING = 1;
|
|
|
|
NOT_SEEN_IN_CHAIN = 2;
|
|
|
|
NOT_IN_BEST_CHAIN = 3;
|
|
|
|
OVERRIDDEN_BY_DOUBLE_SPEND = 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
required Type type = 1;
|
|
|
|
optional int32 appeared_at_height = 2;
|
|
|
|
optional bytes overriding_transaction = 3;
|
|
|
|
}
|
|
|
|
|
2012-01-10 11:10:15 -08:00
|
|
|
message Transaction {
|
2012-01-11 16:29:09 -08:00
|
|
|
/**
|
|
|
|
* This is a bitfield oriented enum, with the following bits:
|
|
|
|
*
|
|
|
|
* bit 0 - spent
|
|
|
|
* bit 1 - appears in alt chain
|
|
|
|
* bit 2 - appears in best chain
|
|
|
|
* bit 3 - double-spent
|
|
|
|
* bit 4 - pending (we would like the tx to go into the best chain)
|
|
|
|
*
|
|
|
|
* Not all combinations are interesting, just the ones actually used in the enum.
|
|
|
|
*/
|
2012-01-10 11:10:15 -08:00
|
|
|
enum Pool {
|
2012-01-11 16:29:09 -08:00
|
|
|
UNSPENT = 4; // In best chain, not all outputs spent
|
|
|
|
SPENT = 5; // In best chain, all outputs spent
|
2012-01-11 10:04:00 -08:00
|
|
|
INACTIVE = 2; // In non-best chain, not our transaction
|
2012-01-11 16:29:09 -08:00
|
|
|
DEAD = 10; // Double-spent by a transaction in the best chain
|
2012-01-11 10:04:00 -08:00
|
|
|
PENDING = 16; // Our transaction, not in any chain
|
|
|
|
PENDING_INACTIVE = 18; // In non-best chain, our transaction
|
2012-01-06 14:50:34 -08:00
|
|
|
}
|
|
|
|
|
2012-01-10 11:10:15 -08:00
|
|
|
// See com.google.bitcoin.core.Wallet.java for detailed description of pool semantics
|
|
|
|
required int32 version = 1;
|
|
|
|
required bytes hash = 2;
|
|
|
|
required Pool pool = 3;
|
2012-01-06 14:50:34 -08:00
|
|
|
|
2012-01-11 10:04:00 -08:00
|
|
|
optional uint32 lock_time = 4; // currently unused field in bitcoin, was originally planned for contracts
|
2012-01-10 11:10:15 -08:00
|
|
|
optional int64 updated_at = 5; // millis since epoch the transaction was last updated
|
2012-01-06 14:50:34 -08:00
|
|
|
|
2012-01-10 11:10:15 -08:00
|
|
|
repeated TransactionInput transaction_input = 6;
|
2012-01-06 14:50:34 -08:00
|
|
|
|
2012-01-10 11:10:15 -08:00
|
|
|
repeated TransactionOutput transaction_output = 7;
|
2012-01-06 14:50:34 -08:00
|
|
|
|
|
|
|
|
2012-01-10 11:10:15 -08:00
|
|
|
repeated bytes block_hash = 8;
|
2012-01-25 10:40:20 -08:00
|
|
|
|
|
|
|
optional TransactionConfidence confidence = 9;
|
2012-01-10 11:10:15 -08:00
|
|
|
// Sha256Hash of block in block chain in which this transaction appears
|
|
|
|
}
|
2012-01-06 14:50:34 -08:00
|
|
|
|
2012-01-11 10:04:00 -08:00
|
|
|
message Extension {
|
|
|
|
required string id = 1; // like org.whatever.foo.bar
|
|
|
|
required bytes data = 2;
|
|
|
|
// If we do not understand a mandatory extension, abort to prevent data loss.
|
|
|
|
// For example, this could be applied to a new type of holding, such as a contract, where
|
|
|
|
// dropping of an extension in a read/write cycle could cause loss of value.
|
|
|
|
required bool mandatory = 3;
|
|
|
|
}
|
|
|
|
|
2012-01-10 11:10:15 -08:00
|
|
|
message Wallet {
|
|
|
|
required string network_identifier = 1; // the network used by this wallet
|
|
|
|
// org.bitcoin.production = production network (Satoshi genesis block)
|
|
|
|
// org.bitcoin.test = test network (Andresen genesis block)
|
2012-01-06 14:50:34 -08:00
|
|
|
|
2012-01-10 11:10:15 -08:00
|
|
|
optional bytes last_seen_block_hash = 2; // the Sha256 hash of the block last seen by this wallet
|
2012-01-06 14:50:34 -08:00
|
|
|
|
2012-01-10 11:10:15 -08:00
|
|
|
repeated Key key = 3;
|
2012-01-06 14:50:34 -08:00
|
|
|
|
2012-01-11 10:04:00 -08:00
|
|
|
repeated Transaction transaction = 4;
|
|
|
|
|
|
|
|
repeated Extension extension = 10;
|
2012-01-06 14:50:34 -08:00
|
|
|
} // end of Wallet
|