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


Java AddressFormatException类代码示例

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


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

示例1: testVector

import com.google.bitcoin.core.AddressFormatException; //导入依赖的package包/类
private void testVector(int testCase) throws AddressFormatException {
    log.info("=======  Test vector {}", testCase);
    HDWTestVector tv = tvs[testCase];
    DeterministicKey masterPrivateKey = HDKeyDerivation.createMasterPrivateKey(Hex.decode(tv.seed));
    Assert.assertEquals(testEncode(tv.priv), testEncode(masterPrivateKey.serializePrivB58()));
    Assert.assertEquals(testEncode(tv.pub), testEncode(masterPrivateKey.serializePubB58()));
    DeterministicHierarchy dh = new DeterministicHierarchy(masterPrivateKey);
    for (int i = 0; i < tv.derived.size(); i++) {
        HDWTestVector.DerivedTestCase tc = tv.derived.get(i);
        log.info("{}", tc.name);
        Assert.assertEquals(tc.name, String.format("Test%d %s", testCase + 1, tc.getPathDescription()));
        int depth = tc.path.length - 1;
        DeterministicKey ehkey = dh.deriveChild(Arrays.asList(tc.path).subList(0, depth), false, true, tc.path[depth]);
        Assert.assertEquals(testEncode(tc.priv), testEncode(ehkey.serializePrivB58()));
        Assert.assertEquals(testEncode(tc.pub), testEncode(ehkey.serializePubB58()));
    }
}
 
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:18,代码来源:BIP32Test.java

示例2: getToAddress

import com.google.bitcoin.core.AddressFormatException; //导入依赖的package包/类
public String getToAddress(String inputAddress) {
	final String userEntered = inputAddress;
	if (userEntered.length() > 0) {
		try {
			new Address(Constants.NETWORK_PARAMETERS, userEntered);

			return userEntered;
		} catch (AddressFormatException e) {
			List<Pair<String, String>> labels = this.getLabelList();

			for (Pair<String, String> label : labels) {
				if (label.first.toLowerCase(Locale.ENGLISH).equals(userEntered.toLowerCase(Locale.ENGLISH))) {
					try {
						new Address(Constants.NETWORK_PARAMETERS, label.second);

						return label.second;
					} catch (AddressFormatException e1) {}
				}
			}
		}
	}

	return null;
}
 
开发者ID:10xEngineer,项目名称:My-Wallet-Android,代码行数:25,代码来源:MyRemoteWallet.java

示例3: createMasterPubKeyFromPubB58

import com.google.bitcoin.core.AddressFormatException; //导入依赖的package包/类
public static DeterministicKey createMasterPubKeyFromPubB58(String xpubstr)
    throws AddressFormatException
{
    byte[] data = Base58.decodeChecked(xpubstr);
    ByteBuffer ser = ByteBuffer.wrap(data);
    if (ser.getInt() != 0x0488B21E)
        throw new AddressFormatException("bad xpub version");
    ser.get();		// depth
    ser.getInt();	// parent fingerprint
    ser.getInt();	// child number
    byte[] chainCode = new byte[32];
    ser.get(chainCode);
    byte[] pubBytes = new byte[33];
    ser.get(pubBytes);
    return HDKeyDerivation.createMasterPubKeyFromBytes(pubBytes, chainCode);
}
 
开发者ID:ksedgwic,项目名称:BTCReceive,代码行数:17,代码来源:WalletUtil.java

示例4: validateAddress

import com.google.bitcoin.core.AddressFormatException; //导入依赖的package包/类
private boolean validateAddress(String address) {
    Boolean addressIsInvalid = Boolean.TRUE;

    if (address != null && !address.isEmpty()) {
        // Copy address to wallet preferences.
        this.bitcoinController.getModel().setActiveWalletPreference(BitcoinModel.VALIDATION_ADDRESS_VALUE, address);

        try {
            new Address(this.bitcoinController.getModel().getNetworkParameters(), address);
            addressIsInvalid = Boolean.FALSE;
        } catch (AddressFormatException afe) {
            // Carry on.
        } catch (java.lang.StringIndexOutOfBoundsException e) {
            // Carry on.
        }
    } else {
        this.bitcoinController.getModel().setActiveWalletPreference(BitcoinModel.VALIDATION_ADDRESS_VALUE, "");
    }
    this.bitcoinController.getModel().setActiveWalletPreference(BitcoinModel.VALIDATION_ADDRESS_IS_INVALID, addressIsInvalid.toString());

    return !addressIsInvalid.booleanValue();
}
 
开发者ID:coinspark,项目名称:sparkbit,代码行数:23,代码来源:Validator.java

示例5: validateAddress

import com.google.bitcoin.core.AddressFormatException; //导入依赖的package包/类
private boolean validateAddress(String address) {
       Boolean addressIsInvalid = Boolean.TRUE;

       if (address != null && !address.isEmpty()) {
           // Copy address to wallet preferences.
    validationState.put(VALIDATION_ADDRESS_VALUE, address);

           try {
               new Address(this.bitcoinController.getModel().getNetworkParameters(), address);
               addressIsInvalid = Boolean.FALSE;
           } catch (AddressFormatException afe) {
               // Carry on.
           } catch (java.lang.StringIndexOutOfBoundsException e) {
               // Carry on.
           }
       } else {
    validationState.put(VALIDATION_ADDRESS_VALUE, "");
       }
validationState.put(VALIDATION_ADDRESS_IS_INVALID, addressIsInvalid.toString());

       return !addressIsInvalid.booleanValue();
   }
 
开发者ID:coinspark,项目名称:sparkbit,代码行数:23,代码来源:AssetValidator.java

示例6: testAddr

import com.google.bitcoin.core.AddressFormatException; //导入依赖的package包/类
private boolean testAddr(String text) {
    try {
        new Address(params, text);
        return true;
    } catch (AddressFormatException e) {
        return false;
    }
}
 
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:9,代码来源:BitcoinAddressValidator.java

示例7: getFromAddress

import com.google.bitcoin.core.AddressFormatException; //导入依赖的package包/类
@Override
public Address getFromAddress() {
	try {
		return new Address(params, address);
	} catch (AddressFormatException e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:10xEngineer,项目名称:My-Wallet-Android,代码行数:10,代码来源:MyTransactionInput.java

示例8: getToAddress

import com.google.bitcoin.core.AddressFormatException; //导入依赖的package包/类
public Address getToAddress() {
	try {
		return new Address(params, address);
	} catch (AddressFormatException e) {
		e.printStackTrace();
	}

	return null;
}
 
开发者ID:10xEngineer,项目名称:My-Wallet-Android,代码行数:10,代码来源:MyTransactionOutput.java

示例9: HDAddress

import com.google.bitcoin.core.AddressFormatException; //导入依赖的package包/类
public HDAddress(NetworkParameters params,
                 DeterministicKey chainKey,
                 JSONObject addrNode)
    throws RuntimeException, JSONException {

    mParams = params;

    mAddrNum = addrNode.getInt("addrNum");
    mPath = addrNode.getString("path");

    // Derive ECKey.
    byte[] prvBytes = null;
    try {
        mPubBytes = Base58.decode(addrNode.getString("pubBytes"));
    } catch (AddressFormatException ex) {
        throw new RuntimeException("failed to decode pubBytes");
    }
    
    mECKey = new ECKey(prvBytes, mPubBytes);

    // Set creation time to BTCReceive epoch.
    mECKey.setCreationTimeSeconds(EPOCH);

    // Derive public key, public hash and address.
    mPubKey = mECKey.getPubKey();
    mPubKeyHash = mECKey.getPubKeyHash();
    mAddress = mECKey.toAddress(mParams);

    // Initialize transaction count and balance.  If we don't have
    // a persisted available amount, presume it is all available.
    mNumTrans = addrNode.getInt("numTrans");
    mBalance = addrNode.getLong("balance");
    mAvailable = addrNode.has("available") ?
        addrNode.getLong("available") : mBalance;

    mLogger.info("read address " + mPath + ": " + mAddress.toString());
}
 
开发者ID:ksedgwic,项目名称:BTCReceive,代码行数:38,代码来源:HDAddress.java

示例10: isValidAddress

import com.google.bitcoin.core.AddressFormatException; //导入依赖的package包/类
public static boolean isValidAddress(String address) {
    try {
        new Address(params, address);
        return true;
    } catch(AddressFormatException e) {
        return false;
    }
}
 
开发者ID:RCasatta,项目名称:geobit-chain,代码行数:9,代码来源:Validator.java

示例11: verify

import com.google.bitcoin.core.AddressFormatException; //导入依赖的package包/类
public ECKey verify(String input) throws WrongInputException {
try {
	ECKey sk = new DumpedPrivateKey(params, input).getKey();
	if (pkHash != null && !Arrays.equals(sk.getPubKeyHash(), pkHash)) {
		throw new WrongInputException("The secret key does not correspond expected public key.");
	}
	return sk;
} catch (AddressFormatException e) {
	throw new WrongInputException("Wrong format of the secret key.");
} 
     }
 
开发者ID:lukmaz,项目名称:BitcoinLottery,代码行数:12,代码来源:InputVerifiers.java

示例12: validateBitcoinAddress

import com.google.bitcoin.core.AddressFormatException; //导入依赖的package包/类
public static boolean validateBitcoinAddress(String address, BitcoinController bitcoinController) {
boolean isValid = false;
       if (address != null && !address.isEmpty()) {
           try {
               new Address(bitcoinController.getModel().getNetworkParameters(), address);
               isValid = true;
           } catch (AddressFormatException afe) {
               // Carry on.
           } catch (java.lang.StringIndexOutOfBoundsException e) {
               // Carry on.
           }
}
return isValid;
   }
 
开发者ID:coinspark,项目名称:sparkbit,代码行数:15,代码来源:CSMiscUtils.java

示例13: generate

import com.google.bitcoin.core.AddressFormatException; //导入依赖的package包/类
public Address generate() throws AddressFormatException {
    ECKey key = new DumpedPrivateKey(params, privKeys[(privKeyCounter++)
            % privKeys.length]).getKey();
    wallet.addKey(key);
    byte[] pubKeyHash = key.getPubKeyHash();
    return new Address(params, pubKeyHash);
}
 
开发者ID:dustyneuron,项目名称:bitprivacy,代码行数:8,代码来源:WalletHarness.java

示例14: importPrivateKey

import com.google.bitcoin.core.AddressFormatException; //导入依赖的package包/类
public Address importPrivateKey(String privKey)
        throws AddressFormatException {
    ECKey key = new DumpedPrivateKey(params, privKey).getKey();
    wallet.addKey(key);
    byte[] pubKeyHash = key.getPubKeyHash();
    return new Address(params, pubKeyHash);
}
 
开发者ID:dustyneuron,项目名称:bitprivacy,代码行数:8,代码来源:WalletHarness.java

示例15: testEncode

import com.google.bitcoin.core.AddressFormatException; //导入依赖的package包/类
private String testEncode(String what) throws AddressFormatException {
    return new String(Hex.encode(Base58.decodeChecked(what)));
}
 
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:4,代码来源:BIP32Test.java


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