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


Java ScriptFormat类代码示例

本文整理汇总了Java中com.bitsofproof.supernode.common.ScriptFormat的典型用法代码示例。如果您正苦于以下问题:Java ScriptFormat类的具体用法?Java ScriptFormat怎么用?Java ScriptFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ScriptFormat类属于com.bitsofproof.supernode.common包,在下文中一共展示了ScriptFormat类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createCoinbase

import com.bitsofproof.supernode.common.ScriptFormat; //导入依赖的package包/类
/**
 * create a coin base transaction crediting the given address with a value and block height This is used in automated tests only.
 */
public static Transaction createCoinbase (Address address, long value, int blockHeight) throws ValidationException
{
	Transaction cb = new Transaction ();

	cb.setInputs (new ArrayList<TransactionInput> ());
	cb.setOutputs (new ArrayList<TransactionOutput> ());

	TransactionOutput out = new TransactionOutput ();
	out.setValue (value);
	cb.getOutputs ().add (out);

	out.setScript (address.getAddressScript ());

	TransactionInput in = new TransactionInput ();
	in.setSourceHash (Hash.ZERO_HASH_STRING);
	in.setIx (0);
	cb.getInputs ().add (in);

	ScriptFormat.Writer writer = new ScriptFormat.Writer ();
	writer.writeInt32 (blockHeight);
	in.setScript (writer.toByteArray ());

	cb.computeHash ();
	return cb;
}
 
开发者ID:bitsofproof,项目名称:bop-bitcoin-client,代码行数:29,代码来源:Transaction.java

示例2: getAddressScript

import com.bitsofproof.supernode.common.ScriptFormat; //导入依赖的package包/类
/**
 * get the transaction output script suitable to refer to this address
 * 
 * @return transaction output script
 * @throws ValidationException
 *             - if output script is unknown for this address
 */
public byte[] getAddressScript () throws ValidationException
{
	ScriptFormat.Writer writer = new ScriptFormat.Writer ();
	if ( type == Address.Type.COMMON )
	{
		writer.writeToken (new ScriptFormat.Token (Opcode.OP_DUP));
		writer.writeToken (new ScriptFormat.Token (Opcode.OP_HASH160));
		writer.writeData (bytes);
		writer.writeToken (new ScriptFormat.Token (Opcode.OP_EQUALVERIFY));
		writer.writeToken (new ScriptFormat.Token (Opcode.OP_CHECKSIG));
	}
	else if ( type == Address.Type.P2SH )
	{
		writer.writeToken (new ScriptFormat.Token (Opcode.OP_HASH160));
		writer.writeData (bytes);
		writer.writeToken (new ScriptFormat.Token (Opcode.OP_EQUAL));
	}
	else
	{
		throw new ValidationException ("unknown sink address type");
	}
	return writer.toByteArray ();
}
 
开发者ID:bitsofproof,项目名称:bop-bitcoin-client,代码行数:31,代码来源:Address.java

示例3: getAddressScript

import com.bitsofproof.supernode.common.ScriptFormat; //导入依赖的package包/类
public byte[] getAddressScript () throws ValidationException
{
	ScriptFormat.Writer writer = new ScriptFormat.Writer ();
	if ( type == Address.Type.COMMON )
	{
		writer.writeToken (new ScriptFormat.Token (Opcode.OP_DUP));
		writer.writeToken (new ScriptFormat.Token (Opcode.OP_HASH160));
		writer.writeData (bytes);
		writer.writeToken (new ScriptFormat.Token (Opcode.OP_EQUALVERIFY));
		writer.writeToken (new ScriptFormat.Token (Opcode.OP_CHECKSIG));
	}
	else if ( type == Address.Type.P2SH )
	{
		writer.writeToken (new ScriptFormat.Token (Opcode.OP_HASH160));
		writer.writeData (bytes);
		writer.writeToken (new ScriptFormat.Token (Opcode.OP_EQUAL));
	}
	else
	{
		throw new ValidationException ("unknown sink address type");
	}
	return writer.toByteArray ();
}
 
开发者ID:greenaddress,项目名称:WalletCordova,代码行数:24,代码来源:Address.java

示例4: createTransactionSource

import com.bitsofproof.supernode.common.ScriptFormat; //导入依赖的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

示例5: getVaultScript

import com.bitsofproof.supernode.common.ScriptFormat; //导入依赖的package包/类
private byte[] getVaultScript () throws ValidationException
{
	ScriptFormat.Writer writer = new ScriptFormat.Writer ();
	writer.writeToken (new ScriptFormat.Token (ScriptFormat.Opcode.OP_2));
	for ( Key key : publicKeys.values () )
	{
		writer.writeData (key.getPublic ());
	}
	writer.writeToken (new ScriptFormat.Token (ScriptFormat.Opcode.OP_3));
	writer.writeToken (new ScriptFormat.Token (ScriptFormat.Opcode.OP_CHECKMULTISIG));
	return writer.toByteArray ();
}
 
开发者ID:bitsofproof,项目名称:btc1k,代码行数:13,代码来源:Vault.java

示例6: getSignedBy

import com.bitsofproof.supernode.common.ScriptFormat; //导入依赖的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

示例7: getOutputAddress

import com.bitsofproof.supernode.common.ScriptFormat; //导入依赖的package包/类
/**
 * Get the address referenced in the script. The parse might fail for not plain-vanilla transactions and return null
 */
public Address getOutputAddress ()
{
	return ScriptFormat.getAddress (script);
}
 
开发者ID:bitsofproof,项目名称:bop-bitcoin-client,代码行数:8,代码来源:TransactionOutput.java


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