当前位置: 首页>>代码示例>>Java>>正文


Java ProtocolException类代码示例

本文整理汇总了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;
    }
}
 
开发者ID:cannabiscoindev,项目名称:cannabiscoinj,代码行数:21,代码来源:MasterNodeVote.java

示例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;


}
 
开发者ID:cannabiscoindev,项目名称:cannabiscoinj,代码行数:27,代码来源:MasterNodeVote.java

示例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;
}
 
开发者ID:10xEngineer,项目名称:My-Wallet-Android,代码行数:8,代码来源:MyTransactionOutPoint.java

示例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();
	}			
}
 
开发者ID:10xEngineer,项目名称:My-Wallet-Android,代码行数:36,代码来源:SharedCoin.java

示例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);
}
 
开发者ID:lukmaz,项目名称:BitcoinLottery,代码行数:7,代码来源:PutMoneyTx.java

示例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();
}
 
开发者ID:9cat,项目名称:templecoin-android-wallet,代码行数:68,代码来源:AcceptBluetoothService.java


注:本文中的com.google.bitcoin.core.ProtocolException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。