public double sum() { double sum = 0d; for (Coin c : coins) { sum+=c.getValue(); } }
public String getCoins() { /* Assuming you include `purseName` member in the purse class for storing purse name */ StringBuilder sb = new StringBuilder(this.purseName + "["); for(Coin c : coins) { sb.append(c.getCoin() + " " + c.getValue() + ", "); } return sb.append("]").toString(); }
public boolean equals(Coin coinToCompare) { return value.equals(coinToCompare.getValue()) && name.equals(coinToCompare.getName()); }
@Override public BigInteger getTransactionValue() throws MissingTransactionInformationException { try { return BigInteger.valueOf(bitcoinjTxOutput.getValue().getValue()); } catch (Exception e) { throw new MissingTransactionInformationException("Couldn't fetch transaction value.", e); } }
private void updateMiningFee(LanguageConfiguration languageConfiguration, BitcoinConfiguration bitcoinConfiguration, Optional<Coin> miningFee, int transactionSize) { if (miningFee.isPresent()) { Coin miningFeeAsCoin = miningFee.get(); String[] minerFeePaidArray = Formats.formatCoinAsSymbolic(miningFeeAsCoin.negate(), languageConfiguration, bitcoinConfiguration, true); miningFeePaidValue.setText(minerFeePaidArray[0] + minerFeePaidArray[1]); // Work out fee rate if (transactionSize > 0) { double feeRate = (double)miningFeeAsCoin.getValue() / transactionSize; miningFeePaidRateValue.setText(feeRateFormat.format(feeRate)); } else { miningFeePaidRateValue.setText(Languages.safeText(MessageKey.NOT_AVAILABLE)); } } else { miningFeePaidValue.setText(Languages.safeText(MessageKey.NOT_AVAILABLE)); miningFeePaidRateValue.setText(Languages.safeText(MessageKey.NOT_AVAILABLE)); } }
@Override public void stateChanged(ChangeEvent e) { Coin feePerKB = Coin.valueOf(feePerKBSlider.getValue() * Sliders.RESOLUTION); setChosenFee(feePerKB); getPanelModel().get().getConfiguration().getWallet().setFeePerKB(feePerKB.getValue()); }
@Override public int compare(TransactionOutput o1, TransactionOutput o2) { long amountDiff = o1.getValue().getValue() - o2.getValue().value; if (amountDiff != 0) { return (int) amountDiff; } else { byte[] hash1 = o1.getScriptBytes(); byte[] hash2 = o2.getScriptBytes(); return LexicographicalComparator.getComparator().compare(hash1, hash2); } } });
for (int i = 0; i < this.outputs.size(); ++i) { uint64ToByteStreamLE( BigInteger.valueOf(this.outputs.get(i).getValue().getValue()), bosHashOutputs ); ByteArrayOutputStream bosHashOutputs = new UnsafeByteArrayOutputStream(256); uint64ToByteStreamLE( BigInteger.valueOf(this.outputs.get(inputIndex).getValue().getValue()), bosHashOutputs ); bos.write(new VarInt(connectedScript.length).encode()); bos.write(connectedScript); uint64ToByteStreamLE(BigInteger.valueOf(prevValue.getValue()), bos); uint32ToByteStreamLE(inputs.get(inputIndex).getSequenceNumber(), bos); bos.write(hashOutputs);
for (int i = 0; i < this.outputs.size(); ++i) { uint64ToByteStreamLE( BigInteger.valueOf(this.outputs.get(i).getValue().getValue()), bosHashOutputs ); ByteArrayOutputStream bosHashOutputs = new UnsafeByteArrayOutputStream(256); uint64ToByteStreamLE( BigInteger.valueOf(this.outputs.get(inputIndex).getValue().getValue()), bosHashOutputs ); bos.write(new VarInt(connectedScript.length).encode()); bos.write(connectedScript); uint64ToByteStreamLE(BigInteger.valueOf(prevValue.getValue()), bos); uint32ToByteStreamLE(inputs.get(inputIndex).getSequenceNumber(), bos); bos.write(hashOutputs);
for (int i = 0; i < this.outputs.size(); ++i) { uint64ToByteStreamLE( BigInteger.valueOf(this.outputs.get(i).getValue().getValue()), bosHashOutputs ); ByteArrayOutputStream bosHashOutputs = new UnsafeByteArrayOutputStream(256); uint64ToByteStreamLE( BigInteger.valueOf(this.outputs.get(inputIndex).getValue().getValue()), bosHashOutputs ); bos.write(new VarInt(connectedScript.length).encode()); bos.write(connectedScript); uint64ToByteStreamLE(BigInteger.valueOf(prevValue.getValue()), bos); uint32ToByteStreamLE(inputs.get(inputIndex).getSequenceNumber(), bos); bos.write(hashOutputs);
System.out.println("Not enough coins in your wallet. Missing " + e.missing.getValue() + " satoshis are missing (including fees)"); System.out.println("Send money to: " + kit.wallet().currentReceiveAddress().toString());
dltTransaction.getFee().longValue() )); final Coin payout = Coin.valueOf(totalPayout.getValue()); UTXO inputUtxo = this.utxoList.stream() .filter(utxo -> utxo.getAddress().equals(fromAddress) && utxo.getValue().isGreaterThan(payout))
@Override public void initialiseContent(JPanel contentPanel) { contentPanel.setLayout( new MigLayout( Panels.migXYLayout(), "[]20[]", // Column constraints "[]1[]30[][]" // Row constraints )); WalletConfiguration walletConfiguration = Configurations.currentConfiguration.getWallet().deepCopy(); long feePerKB = walletConfiguration.getFeePerKB(); // Ensure the feePerKB is within the allowable range, updating the local walletConfiguration Coin normalisedFeePerKB = FeeService.normaliseRawFeePerKB(feePerKB); walletConfiguration.setFeePerKB(normalisedFeePerKB.getValue()); feePerKBSlider = Sliders.newAdjustTransactionFeeSlider(this, normalisedFeePerKB.longValue()); transactionFeeDisplayAmountMaV = Components.newDisplayAmountMaV( DisplayAmountStyle.PLAIN, false, "transaction.fee.amount"); JPanel transactionFeeAmountViewPanel = transactionFeeDisplayAmountMaV.getView().newComponentPanel(); transactionFeeDisplayAmountMaV.getView().setVisible(true); transactionFeeDisplayAmountMaV.getModel().setLocalAmountVisible(false); contentPanel.add(Labels.newExplainTransactionFee1(), "span 2, wrap"); contentPanel.add(Labels.newExplainTransactionFee2(), "span 2, wrap"); contentPanel.add(Labels.newAdjustTransactionFee(), "shrink"); contentPanel.add(feePerKBSlider, "growx,shrinky,width min:250:,wrap"); contentPanel.add(Labels.newLabel(MessageKey.TRANSACTION_FEE_CHOSEN), "shrink"); contentPanel.add(transactionFeeAmountViewPanel, "growx,shrinky,push,wrap"); contentPanel.add(Labels.newBlankLabel(), "span 2, push, wrap"); // spacer setChosenFee(Coin.valueOf(walletConfiguration.getFeePerKB())); }
String addressP2pkh = output.getAddressFromP2PKHScript(netParams).toString(); if (address.equals(addressP2pkh)) { sum += output.getValue().getValue(); break;
if (split < 0) { split *= -1; } if (split == 0) { split = 15; } while (split > value.getValue()) { split /= 2; TransactionOutput prevOut2 = new TransactionOutput(params, prevTx2, Coin.valueOf(value.getValue() - split), to); prevTx2.addOutput(prevOut2); t.addInput(prevOut2).setScriptSig(ScriptBuilder.createInputScript(TransactionSignature.dummy()));