當前位置: 首頁>>代碼示例>>Java>>正文


Java Transaction類代碼示例

本文整理匯總了Java中com.bitsofproof.supernode.api.Transaction的典型用法代碼示例。如果您正苦於以下問題:Java Transaction類的具體用法?Java Transaction怎麽用?Java Transaction使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Transaction類屬於com.bitsofproof.supernode.api包,在下文中一共展示了Transaction類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createTransactionSource

import com.bitsofproof.supernode.api.Transaction; //導入依賴的package包/類
@Override
protected TransactionSource createTransactionSource (TransactionOutput output)
{
	return new TransactionSource (output, this)
	{
		@Override
		protected byte[] spend (int ix, Transaction transaction) throws ValidationException
		{
			ScriptFormat.Writer sw = new ScriptFormat.Writer ();
			sw.writeData (new byte[0]);
			for ( int i = 0; i < publicKeys.size (); ++i )
			{
				sw.writeData (new byte[0]);
			}
			sw.writeData (getVaultScript ());
			return sw.toByteArray ();
		}
	};
}
 
開發者ID:bitsofproof,項目名稱:btc1k,代碼行數:20,代碼來源:Vault.java

示例2: Vault

import com.bitsofproof.supernode.api.Transaction; //導入依賴的package包/類
public Vault (Map<String, String> keys) throws BCSAPIException, ValidationException
{
	for ( Map.Entry<String, String> keyEntry : keys.entrySet () )
	{
		publicKeys.put (keyEntry.getKey (), new ECPublicKey (ByteUtils.fromHexString (keyEntry.getValue ()), true));
	}
	log.info ("Vault address: " + getVaultAddress ());
	this.accountManager = new AM ();
	accountManager.setCreated (new DateTime (2013, 12, 1, 0, 0).getMillis ());
	accountManager.addAccountListener (new AccountListener ()
	{
		@Override
		public void accountChanged (AccountManager account, Transaction t)
		{
			log.info ("New account balance " + fromSatoshi (account.getBalance ()) + " " +
					fromSatoshi (account.getConfirmed ()) + " confrirmed " +
					fromSatoshi (account.getChange ()) + " change " +
					fromSatoshi (account.getReceiving ()) + " receiving");
		}
	});
}
 
開發者ID:bitsofproof,項目名稱:btc1k,代碼行數:22,代碼來源:Vault.java

示例3: prepareBlockToMine

import com.bitsofproof.supernode.api.Transaction; //導入依賴的package包/類
private Block prepareBlockToMine(String previousHash, int blockHeight)
		throws ValidationException {
	Transaction coinbase = Transaction.createCoinbase(minerAddress,
			MinerTestChain.REWARD_COINS * BkbcUtils.BTC, blockHeight);
	Block block = createBlock(previousHash, coinbase);
	if (blockHeight > 1) {
		List<Transaction> translist = block.getTransactions();
		// only poll once ??
		if (translist.size() < numberOfTxInBlock) {
			try {
				Transaction t = mempool.poll(timeout,
						TimeUnit.MILLISECONDS);
				if (t != null) {
					translist.add(t);
				}
			} catch (InterruptedException e) {
			}
		}
		// Why drainTo??
		//mempool.drainTo(translist);
		log.debug("[PREPARE Block with transaction list size ={}]",
				translist.size());
	}
	return block;
}
 
開發者ID:y12studio,項目名稱:BlackBananaCoin,代碼行數:26,代碼來源:SuperNodeApiTester.java

示例4: PendingTransaction

import com.bitsofproof.supernode.api.Transaction; //導入依賴的package包/類
public PendingTransaction (Transaction transaction, BigDecimal amount, Address targetAddress, String title)
{
	this.id = UUID.randomUUID ();
	this.transaction = transaction;
	this.title = title;
	this.amount = amount;
	this.targetAddress = targetAddress;
	this.createdAt = DateTime.now ();
}
 
開發者ID:bitsofproof,項目名稱:btc1k,代碼行數:10,代碼來源:PendingTransaction.java

示例5: updateWithTransaction

import com.bitsofproof.supernode.api.Transaction; //導入依賴的package包/類
@Override
public boolean updateWithTransaction (Transaction t)
{
	if ( super.updateWithTransaction (t) )
	{
		log.info ("Vault updated with transaction " + t.getHash () + " balance " + getBalance ());
		return true;
	}
	return false;
}
 
開發者ID:bitsofproof,項目名稱:btc1k,代碼行數:11,代碼來源:Vault.java

示例6: sync

import com.bitsofproof.supernode.api.Transaction; //導入依賴的package包/類
@Override
public void sync (BCSAPI api) throws BCSAPIException
{
	reset ();
	api.scanUTXOForAddresses (getAddresses (), new TransactionListener ()
	{
		@Override
		public boolean process (Transaction t)
		{
			return updateWithTransaction (t);
		}
	});
}
 
開發者ID:bitsofproof,項目名稱:btc1k,代碼行數:14,代碼來源:Vault.java

示例7: syncHistory

import com.bitsofproof.supernode.api.Transaction; //導入依賴的package包/類
@Override
public void syncHistory (BCSAPI api) throws BCSAPIException
{
	reset ();
	api.scanTransactionsForAddresses (getAddresses (), getCreated (), new TransactionListener ()
	{
		@Override
		public boolean process (Transaction t)
		{
			return updateWithTransaction (t);
		}
	});
}
 
開發者ID:bitsofproof,項目名稱:btc1k,代碼行數:14,代碼來源:Vault.java

示例8: createTransaction

import com.bitsofproof.supernode.api.Transaction; //導入依賴的package包/類
public PendingTransaction createTransaction (Address targetAddress, BigDecimal btcAmount) throws ValidationException
{
	log.info ("Create transaction to pay " + btcAmount + " BTC to " + targetAddress + " vault has " + fromSatoshi (accountManager.getBalance ()));
	Transaction tx = accountManager.pay (targetAddress, toSatoshi (btcAmount), PaymentOptions.receiverPaysFee);
	PendingTransaction pendingTransaction = new PendingTransaction (tx, btcAmount, targetAddress, "");
	return pendingTransaction;
}
 
開發者ID:bitsofproof,項目名稱:btc1k,代碼行數:8,代碼來源:Vault.java

示例9: getSignedBy

import com.bitsofproof.supernode.api.Transaction; //導入依賴的package包/類
List<String> getSignedBy (Transaction transaction) throws ValidationException
{
	List<String> names = new ArrayList<> ();
	for ( TransactionInput input : transaction.getInputs () )
	{
		List<Token> tokens = ScriptFormat.parse (input.getScript ());
		Iterator<Map.Entry<String, ECPublicKey>> it = publicKeys.entrySet ().iterator ();
		for ( int i = 1; i < tokens.size () - 1; ++i )
		{
			if ( tokens.get (i).data != null )
			{
				Map.Entry<String, ECPublicKey> e = it.next ();
				String name = e.getKey ();
				Key k = e.getValue ();
				if ( tokens.get (i).op != ScriptFormat.Opcode.OP_FALSE )
				{
					byte[] digest = transaction.hashTransaction (0, ScriptFormat.SIGHASH_ALL, getVaultScript ());
					if ( k.verify (digest, tokens.get (i).data) )
					{
						names.add (name);
					}
				}
			}
		}
		break;
	}
	return names;
}
 
開發者ID:bitsofproof,項目名稱:btc1k,代碼行數:29,代碼來源:Vault.java

示例10: process

import com.bitsofproof.supernode.api.Transaction; //導入依賴的package包/類
public void process(Tx transaction, boolean doubleSpend) {
	synchronized (seen) {
		if (!transaction.getInputs().get(0).getSourceHash()
				.equals(Hash.ZERO_HASH_STRING)
				&& !seen.contains(transaction.getHash())) {
			Transaction t = Transaction.fromWireDump(transaction
					.toWireDump());
			mempool.offer(t);
			seen.add(transaction.getHash());
		}
	}
}
 
開發者ID:y12studio,項目名稱:BlackBananaCoin,代碼行數:13,代碼來源:SuperNodeApiTester.java

示例11: createBlock

import com.bitsofproof.supernode.api.Transaction; //導入依賴的package包/類
public Block createBlock(String previous, Transaction coinbase) {
	Block block = new Block();
	try {
		Thread.sleep(1001);
	} catch (InterruptedException e) {
	}
	block.setCreateTime(System.currentTimeMillis() / 1000);
	block.setDifficultyTarget(chain.getGenesis().getDifficultyTarget());
	block.setPreviousHash(previous);
	block.setVersion(2);
	block.setNonce(0);
	block.setTransactions(new ArrayList<Transaction>());
	block.getTransactions().add(coinbase);
	return block;
}
 
開發者ID:y12studio,項目名稱:BlackBananaCoin,代碼行數:16,代碼來源:SuperNodeApiTester.java

示例12: getTransaction

import com.bitsofproof.supernode.api.Transaction; //導入依賴的package包/類
public Transaction getTransaction ()
{
	return transaction;
}
 
開發者ID:bitsofproof,項目名稱:btc1k,代碼行數:5,代碼來源:PendingTransaction.java

示例13: setTransaction

import com.bitsofproof.supernode.api.Transaction; //導入依賴的package包/類
public void setTransaction (Transaction transaction)
{
	this.transaction = transaction;
}
 
開發者ID:bitsofproof,項目名稱:btc1k,代碼行數:5,代碼來源:PendingTransaction.java

示例14: MineTxListener

import com.bitsofproof.supernode.api.Transaction; //導入依賴的package包/類
private MineTxListener(Set<String> seen,
		BlockingQueue<Transaction> mempool) {
	this.seen = seen;
	this.mempool = mempool;
}
 
開發者ID:y12studio,項目名稱:BlackBananaCoin,代碼行數:6,代碼來源:SuperNodeApiTester.java


注:本文中的com.bitsofproof.supernode.api.Transaction類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。