Skip to content

Commit

Permalink
2.5.8
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielWeigl committed Dec 7, 2015
1 parent 8dc7c55 commit fea9edf
Show file tree
Hide file tree
Showing 119 changed files with 3,295 additions and 2,001 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -107,6 +107,7 @@ Authors
- Dmitry Murashchik
- Constantin Vennekel
- Leo Wandersleb
- Daniel Krawisz

Credits
=======
Expand Down
Expand Up @@ -123,9 +123,9 @@ public BigDecimal multiply(BigDecimal pricePerBtc) {
return toBigDecimal().multiply(BigDecimal.valueOf(satoshis));
}

protected Bitcoins parse(String input) {
return Bitcoins.valueOf(input);
}
protected Bitcoins parse(String input) {
return Bitcoins.valueOf(input);
}

@Override
public String toString() {
Expand Down Expand Up @@ -201,4 +201,4 @@ private static long roundToSignificantFigures(long num, int n) {
return ret;
}

}
}
Expand Up @@ -111,8 +111,8 @@ public UnspentTransactionOutput[] getFundingOutputs() {
return _funding;
}

protected UnsignedTransaction(List<TransactionOutput> outputs, List<UnspentTransactionOutput> funding,
IPublicKeyRing keyRing, NetworkParameters network) {
public UnsignedTransaction(List<TransactionOutput> outputs, List<UnspentTransactionOutput> funding,
IPublicKeyRing keyRing, NetworkParameters network) {
_network = network;
_outputs = outputs.toArray(new TransactionOutput[]{});
_funding = funding.toArray(new UnspentTransactionOutput[]{});
Expand Down Expand Up @@ -251,7 +251,7 @@ public void addOutputs(OutputList outputs) throws OutputTooSmallException {
}
}

private static TransactionOutput createOutput(Address sendTo, long value, NetworkParameters network) {
public static TransactionOutput createOutput(Address sendTo, long value, NetworkParameters network) {
ScriptOutput script;
if (sendTo.isMultisig(network)) {
script = new ScriptOutputP2SH(sendTo.getTypeSpecificBytes());
Expand Down Expand Up @@ -299,11 +299,11 @@ public UnsignedTransaction createUnsignedTransaction(Collection<UnspentTransacti
throws InsufficientFundsException, UnableToBuildTransactionException {
// Make a copy so we can mutate the list
List<UnspentTransactionOutput> unspent = new LinkedList<UnspentTransactionOutput>(inventory);
OldOutputs oldOutputs = new OldOutputs(minerFeeToUse, unspent);
long fee = oldOutputs.getFee();
long outputSum = oldOutputs.getOutputSum();
//todo extract coinselector interface with 2 implementations, oldest and pruning
List<UnspentTransactionOutput> funding = pruneRedundantOutputs(oldOutputs.getAllFunding(), fee + outputSum);
OldestOutputsFirst oldestOutputsFirst = new OldestOutputsFirst(minerFeeToUse, unspent);
long fee = oldestOutputsFirst.getFee();
long outputSum = oldestOutputsFirst.getOutputSum();
List<UnspentTransactionOutput> funding = pruneRedundantOutputs(oldestOutputsFirst.getAllNeededFundings(), fee + outputSum);
// the number of inputs might have changed - recalculate the fee
fee = estimateFee(funding.size(), _outputs.size() + 1, minerFeeToUse);

long found = 0;
Expand Down Expand Up @@ -501,26 +501,36 @@ private static int estimateTransactionSize(int inputs, int outputs) {
return estimate;
}

private static long estimateFee(int inputs, int outputs, long minerFeeToUse) {
/**
* Returns the estimate needed fee in satoshis for a default P2PKH transaction with a certain number
* of inputs and outputs and the specified per-kB-fee
*
* @param inputs number of inputs
* @param outputs number of outputs
* @param minerFeePerKb miner fee in satoshis per kB
**/
public static long estimateFee(int inputs, int outputs, long minerFeePerKb) {
// fee is based on the size of the transaction, we have to pay for
// every 1000 bytes
int txSize = estimateTransactionSize(inputs, outputs);
long requiredFee = (long) (((float) txSize / 1000.0) * minerFeePerKb);

// check if our estimation leads to a small fee that's below the default bitcoind-MIN_RELAY_FEE
// if so, use the MIN_RELAY_FEE
if (minerFeeToUse < MIN_RELAY_FEE) {
minerFeeToUse = MIN_RELAY_FEE;
if (requiredFee < MIN_RELAY_FEE) {
requiredFee = MIN_RELAY_FEE;
}

// fee is based on the size of the transaction, we have to pay for
// every 1000 bytes
int txSize = estimateTransactionSize(inputs, outputs);
long requiredFee = (long) (((float) txSize / 1000.0) * minerFeeToUse);
return requiredFee;
}

private class OldOutputs {
// todo: generalize this into a interface and provide different coin-selectors
private class OldestOutputsFirst {
private List<UnspentTransactionOutput> allFunding;
private long fee;
private long outputSum;

public OldOutputs(long minerFeeToUse, List<UnspentTransactionOutput> unspent) throws InsufficientFundsException {
public OldestOutputsFirst(long minerFeeToUse, List<UnspentTransactionOutput> unspent) throws InsufficientFundsException {
// Find the funding for this transaction
allFunding = new LinkedList<UnspentTransactionOutput>();
fee = minerFeeToUse;
Expand All @@ -540,7 +550,7 @@ public OldOutputs(long minerFeeToUse, List<UnspentTransactionOutput> unspent) th
}
}

public List<UnspentTransactionOutput> getAllFunding() {
public List<UnspentTransactionOutput> getAllNeededFundings() {
return allFunding;
}

Expand Down
Expand Up @@ -50,6 +50,7 @@ public void addPrivateKey(PrivateKey privateKey, PublicKey publicKey, Address ad
/**
* Find a Bitcoin signer by public key
*/
@Override
public BitcoinSigner findSignerByPublicKey(PublicKey publicKey) {
return _privateKeys.get(publicKey);
}
Expand Down
Expand Up @@ -24,6 +24,7 @@
import com.mrd.bitlib.util.Sha256Hash;
import com.mrd.bitlib.util.ByteReader.InsufficientBytesException;

// OutPoint denotes a particular output of a given transaction.
public class OutPoint implements Serializable {
private static final long serialVersionUID = 1L;

Expand Down
Expand Up @@ -27,6 +27,14 @@

import java.io.Serializable;

/**
* Transaction represents a raw Bitcoin transaction. In other words, it contains only the information found in the
* byte string representing a Bitcoin transaction. It contains no contextual information, such as the height
* of the transaction in the block chain or the outputs that its inputs redeem.
*
* Implements Serializable and is inserted directly in and out of the database. Therefore it cannot be changed
* without messing with the database.
*/
public class Transaction implements Serializable {
private static final long serialVersionUID = 1L;
public static class TransactionParsingException extends Exception {
Expand Down
8 changes: 2 additions & 6 deletions public/btchip/src/main/java/com/btchip/BTChipDongle.java
Expand Up @@ -20,11 +20,7 @@
package com.btchip;

import com.btchip.comm.BTChipTransport;
import com.btchip.utils.BIP32Utils;
import com.btchip.utils.BufferUtils;
import com.btchip.utils.CoinFormatUtils;
import com.btchip.utils.Dump;
import com.btchip.utils.VarintUtils;
import com.btchip.utils.*;

import java.io.ByteArrayOutputStream;
import java.util.Arrays;
Expand Down Expand Up @@ -366,7 +362,7 @@ private byte[] exchange(byte[] apdu) throws BTChipException {
throw new BTChipException("Truncated response");
}
lastSW = ((int) (response[response.length - 2] & 0xff) << 8) |
(int) (response[response.length - 1] & 0xff);
(int) (response[response.length - 1] & 0xff);
byte[] result = new byte[response.length - 2];
System.arraycopy(response, 0, result, 0, response.length - 2);
return result;
Expand Down
5 changes: 4 additions & 1 deletion public/coinapult/build.gradle
Expand Up @@ -18,7 +18,10 @@ dependencies {
compile 'com.fasterxml.jackson.core:jackson-core:2.1.0'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.1.0'
compile 'com.fasterxml.jackson.core:jackson-databind:2.1.0'
compile 'com.google.http-client:google-http-client-jackson2:1.19.0'
compile ('com.google.http-client:google-http-client-jackson2:1.19.0') {
// jackson comes with an older version of findbugs than required elsewhere
exclude group: 'com.google.code.findbugs'
}

compile 'com.madgag.spongycastle:core:1.51.0.0'
compile 'com.madgag.spongycastle:prov:1.51.0.0'
Expand Down
Expand Up @@ -42,6 +42,7 @@ public class ChatEntry implements Serializable {
public static final int EVENT_SUBTYPE_OWNER_STOPPED = 12;
public static final int EVENT_SUBTYPE_PEER_STOPPED = 13;
public static final int EVENT_SUBTYPE_TRADE_LOCATION = 14;
public static final int EVENT_SUBTYPE_CASH_ONLY_WARNING = 15;

@JsonProperty
public long time;
Expand Down
11 changes: 9 additions & 2 deletions public/mbw/build.gradle
Expand Up @@ -39,6 +39,13 @@ dependencies {
compile 'com.squareup.okhttp:okhttp:2.2.0'
compile 'com.android.support:multidex:1.0.1'

compile ('com.google.code.findbugs:annotations:3.0.1') {
//transitive = false
//exclude group: 'javax/annotation/**'
// with these excludes stuff works. not sure which can be removed.
exclude module: 'jsr305'
exclude module: 'jcip-annotations'
}
}

def commonDebugKeystore = file("../../keystore_debug")
Expand All @@ -64,8 +71,8 @@ android {
buildToolsVersion androidSdkBuildVersion

defaultConfig {
versionCode 25700
versionName '2.5.7'
versionCode 25805
versionName '2.5.8'
multiDexEnabled true
}

Expand Down
5 changes: 5 additions & 0 deletions public/mbw/res-sources/licenses.md
@@ -0,0 +1,5 @@
Files used for the localTraderLocalOnly.xcf:

* thumbs-up: [public domain](https://pixabay.com/en/hand-thumb-sign-ok-yes-positive-311121/)
* guys: [public domain](https://openclipart.org/detail/201468/men-shacking-hand-4-differents-versions)
* earth: [public domanin](https://openclipart.org/detail/3320/earth)
Binary file added public/mbw/res-sources/localTraderLocalOnly.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/mbw/res-sources/localTraderLocalOnly.xcf
Binary file not shown.
13 changes: 13 additions & 0 deletions public/mbw/res-sources/updateDrawables.sh
@@ -0,0 +1,13 @@
#!/bin/bash

sizeNames=(ldpi mdpi hdpi xhdpi xxhdpi)
sizes=(360 480 720 960 1800)
fileIn=localTraderLocalOnly.png
fileOut=lt_local_only_warning.png

for ((n=0; n <= 4; n++))
do
fOut="../src/main/res/drawable-"${sizeNames[n]}"/"$fileOut
convert -background none -resize ${sizes[n]}"x" $fileIn - | \
pngquant --force 64 > $fOut
done
1 change: 1 addition & 0 deletions public/mbw/src/main/AndroidManifest.xml
Expand Up @@ -59,6 +59,7 @@
<activity android:name=".activity.modern.GetFromAddressBookActivity" />
<activity android:name=".activity.AddAccountActivity" />
<activity android:name=".activity.AddAdvancedAccountActivity" />
<activity android:name=".activity.AddCoinapultAccountActivity" />
<activity android:name=".activity.ScanActivity" />
<activity android:name=".activity.TransactionDetailsActivity" />
<activity android:name=".activity.settings.SettingsActivity" />
Expand Down
Expand Up @@ -269,9 +269,10 @@ private static String decode(String value) {
sb.append('(');
} else if (c == ')') {
sb.append(')');
} else {
// decode error, ignore this character
}
// else {
// decode error, ignore this character
// }
} else {
if (c == '/') {
slash = true;
Expand Down
Expand Up @@ -39,6 +39,6 @@
/**
* Created by Andreas on 20.06.2015.
*/
public interface BitidKeyDerivation {
public interface BitIdKeyDerivation {
InMemoryPrivateKey deriveKey(int accountIndex, String site);
}
40 changes: 25 additions & 15 deletions public/mbw/src/main/java/com/mycelium/wallet/BitcoinUri.java
Expand Up @@ -34,15 +34,14 @@

package com.mycelium.wallet;

import java.io.Serializable;
import java.math.BigDecimal;

import android.net.Uri;

import com.google.common.base.Optional;
import com.mrd.bitlib.model.Address;
import com.mrd.bitlib.model.NetworkParameters;

import java.io.Serializable;
import java.math.BigDecimal;

/**
* This is a crude implementation of a Bitcoin URI, but for now it works for our
* purpose.
Expand All @@ -56,8 +55,8 @@ public class BitcoinUri implements Serializable {
public final String callbackURL;

// returns a BitcoinUriWithAddress if address != null
public static BitcoinUri from(Address address, Long amount, String label, String callbackURL){
if (address != null){
public static BitcoinUri from(Address address, Long amount, String label, String callbackURL) {
if (address != null) {
return new BitcoinUriWithAddress(address, amount, label, callbackURL);
} else {
return new BitcoinUri(null, amount, label, callbackURL);
Expand Down Expand Up @@ -108,7 +107,12 @@ public static Optional<BitcoinUri> parse(String uri, NetworkParameters network)
}

// Label
// Bip21 defines "?label" and "?message" - lets try "label" first and if it does not
// exist, lets use "message"
String label = u.getQueryParameter("label");
if (label == null) {
label = u.getQueryParameter("message");
}

// Payment Uri
String paymentUri = u.getQueryParameter("r");
Expand All @@ -125,15 +129,21 @@ public static BitcoinUri fromAddress(Address address) {
return new BitcoinUri(address, null, null);
}

public String toString() {
Uri.Builder builder = new Uri.Builder()
.scheme("bitcoin")
.authority(address == null ? "" : address.toString());
if (amount != null) builder.appendQueryParameter("amount", amount.toString());
if (label != null) builder.appendQueryParameter("label", label);
if (callbackURL != null) builder.appendQueryParameter("r", callbackURL);
public String toString() {
Uri.Builder builder = new Uri.Builder()
.scheme("bitcoin")
.authority(address == null ? "" : address.toString());
if (amount != null) {
builder.appendQueryParameter("amount", amount.toString());
}
if (label != null) {
builder.appendQueryParameter("label", label);
}
if (callbackURL != null) {
builder.appendQueryParameter("r", callbackURL);
}
//todo: this can probably be solved nicer with some opaque flags or something
return builder.toString().replace("/", "");
}
return builder.toString().replace("/", "");
}

}
Expand Up @@ -86,7 +86,7 @@ private View.OnClickListener startResetListener(final Context context, final Mbw
return new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog d = new AlertDialog.Builder(ClearPinDialog.this.getContext())
new AlertDialog.Builder(ClearPinDialog.this.getContext())
.setPositiveButton(context.getString(R.string.yes), new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Expand Down
2 changes: 0 additions & 2 deletions public/mbw/src/main/java/com/mycelium/wallet/Constants.java
Expand Up @@ -131,6 +131,4 @@ public class Constants {
public static final int MIN_PIN_BLOCKHEIGHT_AGE_RESET_PIN = 7 * BITCOIN_BLOCKS_PER_DAY;
// Force user to read the warnings about additional backups
public static final int WAIT_SECONDS_BEFORE_ADDITIONAL_BACKUP = 60;
public static final BigDecimal COINAPULT_MINIMUM_AMOUNT = BigDecimal.ONE;

}

0 comments on commit fea9edf

Please sign in to comment.