use of org.bitcoinj.core.NetworkParameters in project bisq-core by bisq-network.
the class Networks method unregister.
public static void unregister(NetworkParameters network) {
if (networks.contains(network)) {
ImmutableSet.Builder<NetworkParameters> builder = ImmutableSet.builder();
for (NetworkParameters parameters : networks) {
if (parameters.equals(network))
continue;
builder.add(parameters);
}
networks = builder.build();
}
}
use of org.bitcoinj.core.NetworkParameters in project samourai-wallet-android by Samourai-Wallet.
the class HD_WalletFactory method restoreWallet.
public HD_Wallet restoreWallet(String data, String passphrase, int nbAccounts) throws AddressFormatException, IOException, DecoderException, MnemonicException.MnemonicLengthException, MnemonicException.MnemonicWordException, MnemonicException.MnemonicChecksumException {
HD_Wallet hdw = null;
if (passphrase == null) {
passphrase = "";
}
NetworkParameters params = SamouraiWallet.getInstance().getCurrentNetworkParams();
InputStream wis = context.getResources().getAssets().open("BIP39/en.txt");
if (wis != null) {
List<String> words = null;
MnemonicCode mc = null;
mc = new MnemonicCode(wis, BIP39_ENGLISH_SHA256);
byte[] seed = null;
if (data.matches(FormatsUtil.XPUB)) {
String[] xpub = data.split(":");
hdw = new HD_Wallet(params, xpub);
} else if (data.matches(FormatsUtil.HEX) && data.length() % 4 == 0) {
seed = Hex.decodeHex(data.toCharArray());
hdw = new HD_Wallet(44, mc, params, seed, passphrase, nbAccounts);
} else {
// only use for BIP39 English
data = data.toLowerCase().replaceAll("[^a-z]+", " ");
words = Arrays.asList(data.trim().split("\\s+"));
seed = mc.toEntropy(words);
hdw = new HD_Wallet(44, mc, params, seed, passphrase, nbAccounts);
}
wis.close();
}
BIP47Util.getInstance(context).reset();
BIP49Util.getInstance(context).reset();
wallets.clear();
wallets.add(hdw);
return hdw;
}
use of org.bitcoinj.core.NetworkParameters in project elastic-core-maven by OrdinaryDude.
the class RedeemFunctions method redeem.
public static boolean redeem(String address_entry, String secretPhrase, String[] bitcoin_privkeys, boolean graceblock) {
String secp_signatures = "";
NetworkParameters params = MainNetParams.get();
long target_id = Account.getId(Crypto.getPublicKey(secretPhrase));
String message = Redeem.getSignMessage(Redeem.getClaimableAmount(address_entry), address_entry, target_id);
// Sign inputs
for (int i = 0; i < bitcoin_privkeys.length; ++i) {
ECKey key;
DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, bitcoin_privkeys[i]);
key = dumpedPrivateKey.getKey();
String signed = key.signMessage(message);
bitcoin_privkeys[i] = signed;
}
secp_signatures = String.join("-", bitcoin_privkeys);
final Attachment attachment = new Attachment.RedeemAttachment(address_entry, secp_signatures);
boolean success = false;
try {
make(attachment, secretPhrase, Account.getId(Crypto.getPublicKey(secretPhrase)), Redeem.getClaimableAmount(address_entry), true, graceblock);
success = true;
} catch (Exception e) {
Logger.logErrorMessage(e.getMessage());
}
return success;
}
use of org.bitcoinj.core.NetworkParameters in project elastic-core-maven by OrdinaryDude.
the class RedeemTest method redeem_different_sig_and_receipient.
private static boolean redeem_different_sig_and_receipient(String address_entry, String secretPhrase, long accountId, String[] bitcoin_privkeys, boolean graceblock) {
String secp_signatures = "";
NetworkParameters params = MainNetParams.get();
long target_id = Account.getId(Crypto.getPublicKey(secretPhrase));
String message = Redeem.getSignMessage(Redeem.getClaimableAmount(address_entry), address_entry, target_id);
// Sign inputs
for (int i = 0; i < bitcoin_privkeys.length; ++i) {
ECKey key;
DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, bitcoin_privkeys[i]);
key = dumpedPrivateKey.getKey();
String signed = key.signMessage(message);
bitcoin_privkeys[i] = signed;
}
secp_signatures = String.join("-", bitcoin_privkeys);
final Attachment attachment = new Attachment.RedeemAttachment(address_entry, secp_signatures);
boolean success = false;
try {
make(attachment, secretPhrase, accountId, Redeem.getClaimableAmount(address_entry), true, graceblock);
success = true;
} catch (Exception e) {
Logger.logErrorMessage(e.getMessage());
}
return success;
}
Aggregations