本文整理汇总了Java中com.google.bitcoin.core.ProtocolException类的典型用法代码示例。如果您正苦于以下问题:Java ProtocolException类的具体用法?Java ProtocolException怎么用?Java ProtocolException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProtocolException类属于com.google.bitcoin.core包,在下文中一共展示了ProtocolException类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseLite
import com.google.bitcoin.core.ProtocolException; //导入依赖的package包/类
@Override
protected void parseLite() throws ProtocolException {
if (parseLazy && length == UNKNOWN_LENGTH) {
//If length hasn't been provided this tx is probably contained within a block.
//In parseRetain mode the block needs to know how long the transaction is
//unfortunately this requires a fairly deep (though not total) parse.
//This is due to the fact that transactions in the block's list do not include a
//size header and inputs/outputs are also variable length due the contained
//script so each must be instantiated so the scriptlength varint can be read
//to calculate total length of the transaction.
//We will still persist will this semi-light parsing because getting the lengths
//of the various components gains us the ability to cache the backing bytearrays
//so that only those subcomponents that have changed will need to be reserialized.
//parse();
//parsed = true;
length = calcLength(bytes, offset);
cursor = offset + length;
}
}
示例2: parse
import com.google.bitcoin.core.ProtocolException; //导入依赖的package包/类
@Override
void parse() throws ProtocolException {
if(parsed)
return;
cursor = offset;
//version = (int)readUint32();
blockHeight = readInt64();
optimalEncodingMessageSize = 8;
//TODO: not finished
//pubkey = ?
long scriptSize = readVarInt();
optimalEncodingMessageSize += VarInt.sizeOf(scriptSize);
byte [] scriptBytes = readBytes((int)scriptSize);
pubkey = new Script(scriptBytes);
optimalEncodingMessageSize += scriptSize;
votes = (int)readUint32();
optimalEncodingMessageSize += 4;
length = cursor - offset;
}
示例3: MyTransactionOutPoint
import com.google.bitcoin.core.ProtocolException; //导入依赖的package包/类
public MyTransactionOutPoint(Sha256Hash txHash, int txOutputN, BigInteger value, byte[] scriptBytes) throws ProtocolException {
super(MainNetParams.get(), txOutputN, new Sha256Hash(txHash.getBytes()));
this.scriptBytes = scriptBytes;
this.value = value;
this.txOutputN = txOutputN;
this.txHash = txHash;
}
示例4: determineOutputsToOfferNextStage
import com.google.bitcoin.core.ProtocolException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void determineOutputsToOfferNextStage(String tx_hex, ObjectSuccessCallback objectSuccessCallback) {
try {
Log.d("SharedCoin", "SharedCoin determineOutputsToOfferNextStage ");
Transaction tx = new Transaction(this.sharedCoin.params, Hex.decode(tx_hex.getBytes()), 0, null, false, true, Message.UNKNOWN_LENGTH);
List<TransactionOutput> transactionOutputs = tx.getOutputs();
JSONArray outpoints_to_offer_next_stage = new JSONArray();
Log.d("SharedCoin", "SharedCoin determineOutputsToOfferNextStage transactionOutputs.size() " + transactionOutputs.size());
for (int i = 0; i < transactionOutputs.size(); i++) {
TransactionOutput output = transactionOutputs.get(i);
Log.d("SharedCoin", "SharedCoin determineOutputsToOfferNextStage i " + i);
if (isOutputOneWeRequested(output)) {
if (isOutputChange(output)) {
JSONObject dict = new JSONObject();
dict.put("hash", null);
dict.put("index", (long) i);
dict.put("value", output.getValue().toString());
outpoints_to_offer_next_stage.add(dict);
}
}
}
Log.d("SharedCoin", "SharedCoin determineOutputsToOfferNextStage outpoints_to_offer_next_stage.size " + outpoints_to_offer_next_stage.size());
objectSuccessCallback.onSuccess(outpoints_to_offer_next_stage);
} catch (ProtocolException e) {
objectSuccessCallback.onFail(e.getLocalizedMessage());
e.printStackTrace();
}
}
示例5: PutMoneyTx
import com.google.bitcoin.core.ProtocolException; //导入依赖的package包/类
public PutMoneyTx(byte[] rawTx, byte[] pkHash, BigInteger stake,
boolean testnet) throws VerificationException, ProtocolException {
NetworkParameters params = getNetworkParameters(testnet);
tx = new Transaction(params, rawTx);
outNr = validateIsPutMoney(pkHash, stake);
}
示例6: onCreate
import com.google.bitcoin.core.ProtocolException; //导入依赖的package包/类
@Override
public void onCreate()
{
serviceCreatedAt = System.currentTimeMillis();
log.debug(".onCreate()");
super.onCreate();
application = (WalletApplication) getApplication();
final BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
final Wallet wallet = application.getWallet();
final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getPackageName() + " bluetooth transaction submission");
wakeLock.acquire();
registerReceiver(bluetoothStateChangeReceiver, new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED));
acceptBluetoothThread = new AcceptBluetoothThread(bluetoothAdapter)
{
@Override
public boolean handleTx(final byte[] msg)
{
try
{
final Transaction tx = new Transaction(Constants.NETWORK_PARAMETERS, msg);
log.info("tx " + tx.getHashAsString() + " arrived via blueooth");
try
{
if (wallet.isTransactionRelevant(tx))
{
wallet.receivePending(tx, null);
handler.post(new Runnable()
{
@Override
public void run()
{
application.broadcastTransaction(tx);
}
});
}
else
{
log.info("tx " + tx.getHashAsString() + " irrelevant");
}
return true;
}
catch (final VerificationException x)
{
log.info("cannot verify tx " + tx.getHashAsString() + " received via bluetooth", x);
}
}
catch (final ProtocolException x)
{
log.info("cannot decode message received via bluetooth", x);
}
return false;
}
};
acceptBluetoothThread.start();
}