Java Code Examples for org.bitcoinj.core.Address#getHash160()
The following examples show how to use
org.bitcoinj.core.Address#getHash160() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LNEstablishAMessage.java From thunder with GNU Affero General Public License v3.0 | 5 votes |
public LNEstablishAMessage (ECKey channelKeyServer, Transaction anchor, RevocationHash revocationHash, long clientAmount, long serverAmount, int minConfirmationAnchor, Address address, int feePerByte, long csvDelay) { this.channelKeyServer = channelKeyServer.getPubKey(); this.minConfirmationAnchor = minConfirmationAnchor; this.anchorTransaction = anchor.bitcoinSerialize(); this.revocationHash = revocationHash; this.amountClient = clientAmount; this.amountServer = serverAmount; this.addressBytes = address.getHash160(); this.feePerByte = feePerByte; this.csvDelay = csvDelay; }
Example 2
Source File: UtxoTrieMgr.java From jelectrum with MIT License | 5 votes |
public static byte[] getPublicKeyForTxOut(TransactionOutput out, NetworkParameters params) { byte[] public_key=null; Script script = null; try { script = out.getScriptPubKey(); if (script.isSentToRawPubKey()) { byte[] key = out.getScriptPubKey().getPubKey(); byte[] address_bytes = org.bitcoinj.core.Utils.sha256hash160(key); public_key = address_bytes; } else { Address a = script.getToAddress(params); public_key = a.getHash160(); } } catch(ScriptException e) { public_key = figureOutStrange(script, out, params); } return public_key; }
Example 3
Source File: DumpTxList.java From jelectrum with MIT License | 4 votes |
public static void main(String args[]) throws Exception { Jelectrum jelly = new Jelectrum(new Config(args[0])); Scanner scan = new Scanner(new FileInputStream(args[1])); PrintStream pout = new PrintStream(new FileOutputStream(args[2], false)); TXUtil txutil = new TXUtil(jelly.getDB(), jelly.getNetworkParameters()); while(scan.hasNext()) { String hash = scan.next(); Transaction tx = jelly.getDB().getTransaction(new Sha256Hash(hash)).getTx(jelly.getNetworkParameters()); int in_idx =0; for(TransactionInput in : tx.getInputs()) { Address addr = in.getFromAddress(); byte[] h160 = addr.getHash160(); pout.println("txin:" + hash + ":" + in_idx + ":" + Hex.encodeHexString(h160)); in_idx++; /*System.out.println("Input: " + in); Script script = in.getScriptSig(); for(ScriptChunk chunk : script.getChunks()) { if (chunk.isOpCode()) { System.out.println(" op " + chunk.opcode); } if (chunk.isPushData() && (chunk.data != null)) { System.out.println(" data " + chunk.data.length); } }*/ } pout.println("tx:" + hash + ":" + txutil.getTXBlockHeight(tx, jelly.getBlockChainCache())); for(TransactionOutput out : tx.getOutputs()) { int idx = out.getIndex(); Script script = out.getScriptPubKey(); for(ScriptChunk chunk : script.getChunks()) { if (chunk.isOpCode()) { //System.out.println(" op " + chunk.opcode); } if (chunk.isPushData() && (chunk.data != null)) { pout.println("txout:" + hash + ":" + idx + ":" + Hex.encodeHexString(chunk.data)); } } } } pout.flush(); pout.close(); }
Example 4
Source File: UtxoTrieMgr.java From jelectrum with MIT License | 4 votes |
public String getKeyForInput(TransactionInput in) { if (in.isCoinBase()) return null; try { byte[] public_key=null; Address a = in.getFromAddress(); public_key = a.getHash160(); return getKey(public_key, in.getOutpoint().getHash(), (int)in.getOutpoint().getIndex()); } catch(ScriptException e) { //Lets try this the other way try { TransactionOutPoint out_p = in.getOutpoint(); Transaction src_tx = tx_util.getTransaction(out_p.getHash()); TransactionOutput out = src_tx.getOutput((int)out_p.getIndex()); return getKeyForOutput(out, (int)out_p.getIndex()); } catch(ScriptException e2) { return null; } } }
Example 5
Source File: UtxoTrieMgr.java From jelectrum with MIT License | 4 votes |
public static String getPrefixForAddress(Address a) { byte[] public_key=a.getHash160(); return Hex.encodeHexString(public_key); }