本文整理汇总了Java中org.bitcoinj.core.TransactionOutput.getScriptBytes方法的典型用法代码示例。如果您正苦于以下问题:Java TransactionOutput.getScriptBytes方法的具体用法?Java TransactionOutput.getScriptBytes怎么用?Java TransactionOutput.getScriptBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bitcoinj.core.TransactionOutput
的用法示例。
在下文中一共展示了TransactionOutput.getScriptBytes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isEWMessage
import org.bitcoinj.core.TransactionOutput; //导入方法依赖的package包/类
public static boolean isEWMessage(Transaction tx) {
List<TransactionOutput> outputs = tx.getOutputs();
for (TransactionOutput out : outputs) {
byte[] scriptBytes = out.getScriptBytes();
if(scriptBytes.length>0) {
String hexString = Hex.toHexString(scriptBytes);
if(hexString.startsWith("6a")) {
hexString=hexString.substring(2);
if( hexString.startsWith("455720") || hexString.substring(2).startsWith("455720") ) {
return true;
}
}
}
}
return false;
}
示例2: isTransactionBroadcastAnnouncement
import org.bitcoinj.core.TransactionOutput; //导入方法依赖的package包/类
public boolean isTransactionBroadcastAnnouncement(Transaction tx) {
List<TransactionOutput> outputs = tx.getOutputs();
TransactionOutput scndOutput = outputs.get(1);
if(!scndOutput.getScriptPubKey().isOpReturn()) {
return false;
}
byte[] script = scndOutput.getScriptBytes();
//check magic numbers that are defined in BroadcastAnnouncement
return BroadcastAnnouncement.isBroadcastAnnouncementScript(script);
}
示例3: TrimmedOutput
import org.bitcoinj.core.TransactionOutput; //导入方法依赖的package包/类
public TrimmedOutput(TransactionOutput output, long index, TrimmedTransaction tx) {
super(output.getParams(), Preconditions.checkNotNull(tx), output.getValue(), output.getScriptBytes());
this.index = index;
this.txHash = null;
}
示例4: checkAlias
import org.bitcoinj.core.TransactionOutput; //导入方法依赖的package包/类
public String checkAlias(Transaction tx, WalletObservable walletObservable) {
final List<TransactionOutput> outputs = tx.getOutputs();
for (TransactionOutput to : outputs) {
byte[] script = to.getScriptBytes();
if(script.length>0) {
String hexString = Hex.toHexString(script);
Log.i(TAG, "outputHEX: " + hexString);
if (hexString.startsWith("6a")) {
Log.i(TAG, "outputHEX is OP_RETURN! ");
hexString = hexString.substring(2);
String aliasNameHex=null;
if(hexString.startsWith(EWA_PREFIX) ) { //NON_STANDARD
Log.i(TAG, "outputHEX is EWA NON STANDARD");
aliasNameHex = hexString.substring(6);
} else if (hexString.length()>2 && hexString.substring(2).startsWith(EWA_PREFIX)) {
Log.i(TAG, "outputHEX is EWA WITH LENGTH");
aliasNameHex = hexString.substring(8);
}
if(aliasNameHex!=null) {
String aliasName = new String( Bitcoin.fromHex(aliasNameHex) , Charset.forName("utf-8") );
if(aliasName!=null && aliasName.length()>0) {
aliasName= aliasName.trim();
if(aliasName.length()>20)
aliasName=aliasName.substring(0,20);
Log.i(TAG, "Found alias name!! " + aliasName);
if(tx.getConfidence().getConfidenceType() == TransactionConfidence.ConfidenceType.PENDING ) {
Log.i(TAG, "alias tx is pending");
walletObservable.setUnconfirmedAliasName(aliasName);
} else {
walletObservable.setUnconfirmedAliasName(null);
walletObservable.setAliasName(aliasName);
Log.i(TAG, "alias tx is confirmed!");
}
walletObservable.notifyObservers();
return aliasName;
}
}
}
}
}
return null;
}