Skip to content

Commit

Permalink
Merge branch 'master' into 'develop'
Browse files Browse the repository at this point in the history
Master

See merge request !44
  • Loading branch information
itserg committed Oct 10, 2017
2 parents ce1edb1 + f613d8c commit 56c3eba
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
3 changes: 1 addition & 2 deletions mbw/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ dependencies {
annotationProcessor 'com.jakewharton:butterknife-compiler:8.1.0'
}


android {
configurations {
all*.exclude module: 'jcip-annotations'
Expand Down Expand Up @@ -94,7 +93,7 @@ android {
buildToolsVersion androidSdkBuildVersion

defaultConfig {
versionCode 290403
versionCode 290404
versionName '2.9.4'
multiDexEnabled true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
import com.mycelium.wallet.paymentrequest.PaymentRequestHandler;
import com.mycelium.wapi.api.lib.FeeEstimation;
import com.mycelium.wapi.api.response.Feature;
import com.mycelium.wapi.wallet.AbstractAccount;
import com.mycelium.wapi.wallet.AesKeyCipher;
import com.mycelium.wapi.wallet.KeyCipher;
import com.mycelium.wapi.wallet.WalletAccount;
Expand Down Expand Up @@ -623,7 +624,8 @@ private boolean canFundColuFrom(WalletAccount walletAccount) {
}

private long getAmountForColuTxOutputs() {
return 4 * ColuManager.DUST_OUTPUT_SIZE + ColuManager.METADATA_OUTPUT_SIZE;
int coluDustOutputSize = this._mbwManager.getNetwork().isTestnet() ? AbstractAccount.COLU_MAX_DUST_OUTPUT_SIZE_TESTNET : AbstractAccount.COLU_MAX_DUST_OUTPUT_SIZE_MAINNET;
return 2 * coluDustOutputSize + ColuManager.METADATA_OUTPUT_SIZE;
}

private boolean checkFee(boolean rescan) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public class ColuManager implements AccountProvider {
private Map<ColuAccount.ColuAssetType, AssetMetadata> assetsMetadata = new HashMap<>();

public static final int TIME_INTERVAL_BETWEEN_BALANCE_FUNDING_CHECKS = 50;
public static final int DUST_OUTPUT_SIZE = 600;
public static final int METADATA_OUTPUT_SIZE = 1;
public static final int AVERAGE_COLU_TX_SIZE = 212;

Expand Down
26 changes: 26 additions & 0 deletions wapi/src/main/java/com/mycelium/wapi/wallet/AbstractAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,10 @@ public void checkAmount(Receiver receiver, long kbMinerFee, CurrencyValue entere
public NetworkParameters getNetwork() {
return _network;
}

// TODO: 07.10.17 these values are subject to change and not a solid way to detect cc outputs.
public static final int COLU_MAX_DUST_OUTPUT_SIZE_TESTNET = 600;
public static final int COLU_MAX_DUST_OUTPUT_SIZE_MAINNET = 6000;

/**
* @param minerFeePerKbToUse Determines the dust level, at which including a UTXO costs more than it is worth.
Expand All @@ -874,6 +878,28 @@ protected Collection<TransactionOutputEx> getSpendableOutputs(long minerFeePerKb
output.isCoinBase && blockChainHeight - output.height < COINBASE_MIN_CONFIRMATIONS ||
!_allowZeroConfSpending && output.height == -1 && !isFromMe(output.outPoint.hash)) {
it.remove();
} else {
boolean isColuTransaction = false;
//Try to detect if the output came from the colu transaction
//The typical attribute of colu transaction is zero-based OP_RETURN output. It has the specific protocol identifier
//Protocol description link: https://github.com/Colored-Coins/Colored-Coins-Protocol-Specification/wiki/Coloring%20Scheme
Transaction transaction = TransactionEx.toTransaction(_backing.getTransaction(output.outPoint.hash));
for(int i = 0 ; i < transaction.outputs.length;i++) {
TransactionOutput curOutput = transaction.outputs[i];
byte[] scriptBytes = curOutput.script.getScriptBytes();
//Check the protocol identifier 0x4343 ASCII representation of the string CC ("Colored Coins")
if (curOutput.value == 0 && scriptBytes.length >= 4 && scriptBytes[2] == 0x43 && scriptBytes[3] == 0x43) {
isColuTransaction = true;
break;
}
}

if (isColuTransaction) {
int coluDustOutputSize = this._network.isTestnet() ? COLU_MAX_DUST_OUTPUT_SIZE_TESTNET : COLU_MAX_DUST_OUTPUT_SIZE_MAINNET;
if (output.value <= coluDustOutputSize) {
it.remove();
}
}
}
}
return allUnspentOutputs;
Expand Down

0 comments on commit 56c3eba

Please sign in to comment.