本文整理汇总了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 ();
}
};
}
示例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");
}
});
}
示例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;
}
示例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 ();
}
示例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;
}
示例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);
}
});
}
示例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);
}
});
}
示例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;
}
示例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;
}
示例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());
}
}
}
示例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;
}
示例12: getTransaction
import com.bitsofproof.supernode.api.Transaction; //导入依赖的package包/类
public Transaction getTransaction ()
{
return transaction;
}
示例13: setTransaction
import com.bitsofproof.supernode.api.Transaction; //导入依赖的package包/类
public void setTransaction (Transaction transaction)
{
this.transaction = transaction;
}
示例14: MineTxListener
import com.bitsofproof.supernode.api.Transaction; //导入依赖的package包/类
private MineTxListener(Set<String> seen,
BlockingQueue<Transaction> mempool) {
this.seen = seen;
this.mempool = mempool;
}