本文整理了Java中org.bitcoinj.core.Transaction.getOutputs()
方法的一些代码示例,展示了Transaction.getOutputs()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transaction.getOutputs()
方法的具体详情如下:
包路径:org.bitcoinj.core.Transaction
类名称:Transaction
方法名:getOutputs
[英]Returns an unmodifiable view of all outputs.
[中]返回所有输出的不可修改视图。
代码示例来源:origin: Coinomi/coinomi-android
public boolean isOutputAvailable(int index) {
checkIndex(index);
if (trimmedOutputs == null) {
return index < super.getOutputs().size();
} else {
return trimmedOutputs.containsKey(index);
}
}
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
/**
* Gets the index of this output in the parent transaction, or throws if this output is free standing. Iterates
* over the parents list to discover this.
*/
public int getIndex() {
List<TransactionOutput> outputs = getParentTransaction().getOutputs();
for (int i = 0; i < outputs.size(); i++) {
if (outputs.get(i) == this)
return i;
}
throw new IllegalStateException("Output linked to wrong parent transaction?");
}
代码示例来源:origin: greenaddress/GreenBits
/**
* Gets the index of this output in the parent transaction, or throws if this output is free standing. Iterates
* over the parents list to discover this.
*/
public int getIndex() {
List<TransactionOutput> outputs = getParentTransaction().getOutputs();
for (int i = 0; i < outputs.size(); i++) {
if (outputs.get(i) == this)
return i;
}
throw new IllegalStateException("Output linked to wrong parent transaction?");
}
代码示例来源:origin: Coinomi/coinomi-android
public List<TransactionOutput> getOutputs(boolean includeEmptyOutputs) {
if (tx instanceof TrimmedTransaction) {
return ((TrimmedTransaction) tx).getOutputs(includeEmptyOutputs);
} else {
return tx.getOutputs();
}
}
代码示例来源:origin: Coinomi/coinomi-android
private long getNumberOfOutputs() {
if (tx instanceof TrimmedTransaction) {
return ((TrimmedTransaction) tx).getNumberOfOutputs();
} else {
return tx.getOutputs().size();
}
}
代码示例来源:origin: openwalletGH/openwallet-android
public List<TransactionOutput> getOutputs(boolean includeEmptyOutputs) {
if (tx instanceof TrimmedTransaction) {
return ((TrimmedTransaction) tx).getOutputs(includeEmptyOutputs);
} else {
return tx.getOutputs();
}
}
代码示例来源:origin: openwalletGH/openwallet-android
private long getNumberOfOutputs() {
if (tx instanceof TrimmedTransaction) {
return ((TrimmedTransaction) tx).getNumberOfOutputs();
} else {
return tx.getOutputs().size();
}
}
代码示例来源:origin: HashEngineering/dashj
/**
* Gets the index of this output in the parent transaction, or throws if this output is free standing. Iterates
* over the parents list to discover this.
*/
public int getIndex() {
List<TransactionOutput> outputs = getParentTransaction().getOutputs();
for (int i = 0; i < outputs.size(); i++) {
if (outputs.get(i) == this)
return i;
}
throw new IllegalStateException("Output linked to wrong parent transaction?");
}
代码示例来源:origin: fr.acinq/bitcoinj-core
/**
* Gets the index of this output in the parent transaction, or throws if this output is free standing. Iterates
* over the parents list to discover this.
*/
public int getIndex() {
List<TransactionOutput> outputs = getParentTransaction().getOutputs();
for (int i = 0; i < outputs.size(); i++) {
if (outputs.get(i) == this)
return i;
}
throw new IllegalStateException("Output linked to wrong parent transaction?");
}
代码示例来源:origin: openwalletGH/openwallet-android
public boolean isOutputAvailable(int index) {
checkIndex(index);
if (trimmedOutputs == null) {
return index < super.getOutputs().size();
} else {
return trimmedOutputs.containsKey(index);
}
}
代码示例来源:origin: greenaddress/GreenBits
/**
* Locates the referenced output from the given pool of transactions.
*
* @return The TransactionOutput or null if the transactions map doesn't contain the referenced tx.
*/
@Nullable
TransactionOutput getConnectedOutput(Map<Sha256Hash, Transaction> transactions) {
Transaction tx = transactions.get(outpoint.getHash());
if (tx == null)
return null;
return tx.getOutputs().get((int) outpoint.getIndex());
}
代码示例来源:origin: fr.acinq/bitcoinj-core
/**
* Locates the referenced output from the given pool of transactions.
*
* @return The TransactionOutput or null if the transactions map doesn't contain the referenced tx.
*/
@Nullable
TransactionOutput getConnectedOutput(Map<Sha256Hash, Transaction> transactions) {
Transaction tx = transactions.get(outpoint.getHash());
if (tx == null)
return null;
return tx.getOutputs().get((int) outpoint.getIndex());
}
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
/**
* Locates the referenced output from the given pool of transactions.
*
* @return The TransactionOutput or null if the transactions map doesn't contain the referenced tx.
*/
@Nullable
TransactionOutput getConnectedOutput(Map<Sha256Hash, Transaction> transactions) {
Transaction tx = transactions.get(outpoint.getHash());
if (tx == null)
return null;
return tx.getOutputs().get((int) outpoint.getIndex());
}
代码示例来源:origin: blockchain/thunder
public void addAnchorOutputToAnchor () {
List<TransactionOutput> outputList = new ArrayList<>();
outputList.add(new TransactionOutput(
Constants.getNetwork(),
null,
Coin.valueOf(channelStatus.amountClient + channelStatus.amountServer),
getAnchorScript().getProgram()));
outputList.addAll(anchorTx.getOutputs());
Transaction tx = new Transaction(Constants.getNetwork());
anchorTx.getInputs().stream().forEach(tx::addInput);
outputList.stream().forEach(tx::addOutput);
this.anchorTx = tx;
}
代码示例来源:origin: Multibit-Legacy/multibit-hardware
@Override
public Optional<MessageEvent> signTx(Transaction tx) {
return sendMessage(
TrezorMessage.SignTx
.newBuilder()
.setCoinName("Bitcoin")
.setInputsCount(tx.getInputs().size())
.setOutputsCount(tx.getOutputs().size())
.build()
);
}
代码示例来源:origin: Multibit-Legacy/multibit-hardware
@Override
public Optional<MessageEvent> signTx(Transaction tx) {
return sendMessage(
KeepKeyMessage.SignTx
.newBuilder()
.setCoinName("Bitcoin")
.setInputsCount(tx.getInputs().size())
.setOutputsCount(tx.getOutputs().size())
.build()
);
}
代码示例来源:origin: greenaddress/GreenBits
private void basicSanityChecks(Wallet wallet, Transaction t, Address destination) throws VerificationException {
assertEquals("Wrong number of tx inputs", 1, t.getInputs().size());
assertEquals("Wrong number of tx outputs",2, t.getOutputs().size());
assertEquals(destination, t.getOutput(0).getScriptPubKey().getToAddress(PARAMS));
assertEquals(wallet.currentChangeAddress(), t.getOutputs().get(1).getScriptPubKey().getToAddress(PARAMS));
assertEquals(valueOf(0, 50), t.getOutputs().get(1).getValue());
// Check the script runs and signatures verify.
t.getInputs().get(0).verify();
}
代码示例来源:origin: greenaddress/GreenBits
@Test
public void sendRequestP2PKHTest() {
SendRequest req = SendRequest.to(OTHER_ADDRESS, SATOSHI.multiply(12));
assertEquals(OTHER_ADDRESS, req.tx.getOutputs().get(0).getScriptPubKey().getToAddress(PARAMS));
}
代码示例来源:origin: greenaddress/GreenBits
@Test
public void sendRequestP2PKTest() {
ECKey key = new ECKey();
SendRequest req = SendRequest.to(PARAMS, key, SATOSHI.multiply(12));
assertArrayEquals(key.getPubKey(), req.tx.getOutputs().get(0).getScriptPubKey().getPubKey());
}
代码示例来源:origin: greenaddress/GreenBits
@Test
public void testOptimalEncodingMessageSize() {
Transaction tx = new Transaction(PARAMS);
int length = tx.length;
// add basic transaction input, check the length
tx.addOutput(new TransactionOutput(PARAMS, null, Coin.COIN, ADDRESS));
length += getCombinedLength(tx.getOutputs());
// add basic output, check the length
length += getCombinedLength(tx.getInputs());
// optimal encoding size should equal the length we just calculated
assertEquals(tx.getOptimalEncodingMessageSize(), length);
}
内容来源于网络,如有侵权,请联系作者删除!