本文整理汇总了Java中org.bitcoinj.core.DumpedPrivateKey类的典型用法代码示例。如果您正苦于以下问题:Java DumpedPrivateKey类的具体用法?Java DumpedPrivateKey怎么用?Java DumpedPrivateKey使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DumpedPrivateKey类属于org.bitcoinj.core包,在下文中一共展示了DumpedPrivateKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decodeMemoTransactionsReceived
import org.bitcoinj.core.DumpedPrivateKey; //导入依赖的package包/类
private void decodeMemoTransactionsReceived(final JSONObject memoObject) {
ECKey toKey;
toKey = ECKey.fromPrivate(DumpedPrivateKey.fromBase58(null, wifkey).getKey().getPrivKeyBytes());
if (context == null) return;
try {
String message = memoObject.get("message").toString();
PublicKey fromKey = new Address(memoObject.get("from").toString()).getPublicKey();
String nonce = memoObject.get("nonce").toString();
// if (memosToDecodeHm.containsKey(memoObject)) {
// memosToDecodeHm.put(memoObject, Memo.decodeMessage(fromKey, toKey, message, nonce));
// }
loadMemoSListForDecoding();
} catch (JSONException | MalformedAddressException e) {
e.printStackTrace();
}
}
示例2: decodeAllMemosInTransactionsReceived
import org.bitcoinj.core.DumpedPrivateKey; //导入依赖的package包/类
private void decodeAllMemosInTransactionsReceived(final List<JSONObject> memosArray) {
ECKey toKey;
toKey = ECKey.fromPrivate(DumpedPrivateKey.fromBase58(null, wifkey).getKey().getPrivKeyBytes());
for (JSONObject memoObject : memosArray) {
try {
String message = memoObject.get("message").toString();
PublicKey fromKey = new Address(memoObject.get("from").toString()).getPublicKey();
String nonce = memoObject.get("nonce").toString();
// if (memosToDecodeHm.containsKey(memoObject)) {
// memosToDecodeHm.put(memoObject, Memo.decodeMessage(fromKey, toKey, message, nonce));
// }
decodingMemosComplete();
} catch (JSONException | MalformedAddressException e) {
e.printStackTrace();
}
}
}
示例3: addExistingKeys
import org.bitcoinj.core.DumpedPrivateKey; //导入依赖的package包/类
/** Adds multiple pre-existing keys to the wallet.
* @author Francis Fasola
* @param keys String representation of the private key(s). */
public void addExistingKeys(String... keys) {
for (String key : keys) {
DumpedPrivateKey _key = DumpedPrivateKey.fromBase58(params, key);
this.wallet.importKey(_key.getKey());
}
}
示例4: CreatingPair
import org.bitcoinj.core.DumpedPrivateKey; //导入依赖的package包/类
/**
* Creates new form CreatingPair
*/
public CreatingPair(final String username, final String password) {
initComponents();
BitcoinWot.centreWindow(this);
setCursor(new Cursor(Cursor.WAIT_CURSOR));
new Thread(new Runnable() {
@Override
public void run() {
try {
ECKey generatedKey = new KeyDerivator(username, password).generateKey();
BitcoinWot.KEY = generatedKey;
Address newAddress = new Address(new MainNetParams(),
generatedKey.getPubKeyHash());
DumpedPrivateKey privateKey = generatedKey.getPrivateKeyEncoded(new MainNetParams());
jTextField1.setText(newAddress.toString());
jTextField2.setText(privateKey.toString());
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
jLabel1.setText("Par criado com sucesso!");
jButton1.setEnabled(true);
} catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(null,
"Erro ao derivar as chaves: " + ex);
}
}
}).start();
}
示例5: getIncomingMask
import org.bitcoinj.core.DumpedPrivateKey; //导入依赖的package包/类
public byte[] getIncomingMask(Wallet wallet, byte[] pubkey, byte[] outPoint) throws AddressFormatException, Exception {
Address notifAddress = getNotificationAddress(wallet);
DumpedPrivateKey dpk = new DumpedPrivateKey(MainNetParams.get(), notifAddress.getPrivateKeyString());
ECKey inputKey = dpk.getKey();
byte[] privkey = inputKey.getPrivKeyBytes();
byte[] mask = PaymentCode.getMask(new SecretPoint(privkey, pubkey).ECDHSecretAsBytes(), outPoint);
return mask;
}
示例6: getBinBytesFromWif
import org.bitcoinj.core.DumpedPrivateKey; //导入依赖的package包/类
public void getBinBytesFromWif(final String pin, final String wif_key, final String accountName) {
Log.d(TAG, "getBinBytesFromWif. pin: " + pin + ", wif_key: " + wif_key + ", accountName: " + accountName);
//Fill with an invalid brainkey to not break the backup format (The presence of brainkey seems mandatory)
BrainKey brainKey = new BrainKey("NOT A VALID BRAINKEY (PREVIOUSLY WIF IMPORTED ACCOUNT)", 0);
try {
ArrayList<Wallet> wallets = new ArrayList<>();
ArrayList<LinkedAccount> accounts = new ArrayList<>();
ArrayList<PrivateKeyBackup> keys = new ArrayList<>();
Wallet wallet = new Wallet(accountName, brainKey.getBrainKey(), brainKey.getSequenceNumber(), Chains.BITSHARES.CHAIN_ID, pin);
wallets.add(wallet);
String wif = Crypt.getInstance().decrypt_string(wif_key);
ECKey key = DumpedPrivateKey.fromBase58(NetworkParameters.fromID(NetworkParameters.ID_MAINNET), wif).getKey();
PrivateKeyBackup keyBackup = new PrivateKeyBackup(key.getPrivKeyBytes(),
brainKey.getSequenceNumber(),
brainKey.getSequenceNumber(),
wallet.getEncryptionKey(pin));
keys.add(keyBackup);
LinkedAccount linkedAccount = new LinkedAccount(accountName, Chains.BITSHARES.CHAIN_ID);
accounts.add(linkedAccount);
WalletBackup backup = new WalletBackup(wallets, keys, accounts);
byte[] results = FileBin.serializeWalletBackup(backup, pin);
List<Integer> resultFile = new ArrayList<>();
for (byte result : results) {
resultFile.add(result & 0xff);
}
saveBinContentToFile(resultFile, accountName);
} catch (Exception e) {
hideDialog(false);
Log.e(TAG, "Exception. Msg: " + e.getMessage());
Toast.makeText(myActivity, myActivity.getResources().getString(R.string.unable_to_generate_bin_format_for_key), Toast.LENGTH_SHORT).show();
}
}
示例7: deserialize
import org.bitcoinj.core.DumpedPrivateKey; //导入依赖的package包/类
@Override
public ECKey deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
JsonToken token = p.getCurrentToken();
switch (token) {
case VALUE_STRING:
try {
return DumpedPrivateKey.fromBase58(null, p.getValueAsString()).getKey();
} catch (AddressFormatException e) {
throw new InvalidFormatException(p, "Invalid Key", p.getValueAsString(), ECKey.class);
}
default:
return (ECKey) ctxt.handleUnexpectedToken(ECKey.class, p);
}
}
示例8: getAddressFromPrivateKey
import org.bitcoinj.core.DumpedPrivateKey; //导入依赖的package包/类
public static String getAddressFromPrivateKey(String privateKeyBase58) {
DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(np, privateKeyBase58);
ECKey key = dumpedPrivateKey.getKey();
return key.toAddress(np).toString();
}
示例9: broadcastTransactionSynchronousVote
import org.bitcoinj.core.DumpedPrivateKey; //导入依赖的package包/类
protected static void broadcastTransactionSynchronousVote() throws Exception {
LOG.info("Start method broadcastTransactionSynchronousVote");
int id = 2;
GetDynamicGlobalPropertiesDto getDynamicGlobalPropertiesDto = getDynamicGlobalProperties();
DynamicGlobalPropertiesDto dynamicGlobalPropertiesDto = getDynamicGlobalPropertiesDto.getResults();
BaseTransactionDto baseTransactionDto = new BaseTransactionDto();
long headBlockNumber = dynamicGlobalPropertiesDto.getHeadBlockNumber();
String headBlockId = dynamicGlobalPropertiesDto.getHeadBlockId();
int refBlockNum = TransactionUtil.long2Last2Byte(headBlockNumber);
baseTransactionDto.setRefBlockNum(refBlockNum);
long refBlockPrefix = TransactionUtil.hexString2Long(headBlockId, 4);
baseTransactionDto.setRefBlockPrefix(refBlockPrefix);
Date time = dynamicGlobalPropertiesDto.getTime();
Date expiration = Util.addTime(time, BaseTransactionDto.DEFAULT_EXPIRATION_TIME);
baseTransactionDto.setExpiration(expiration);
List<BaseOperation> operations = baseTransactionDto.getOperations();
VoteDto voteDto = new VoteDto();
operations.add(voteDto);
voteDto.setAuthor("tushinetc");
voteDto.setPermlink("pik-reabilitirovalsya");
voteDto.setVoter(ACCOUNT);
voteDto.setWeight(10000);
GetConfigDto getConfigDto = getConfig();
ConfigDto configDto = getConfigDto.getResults();
String chainId = configDto.getSteemitChainId();
ECKey postingKey = DumpedPrivateKey.fromBase58(null, PRIVATE_KEY)
.getKey();
baseTransactionDto.setSignatures(chainId, postingKey);
LOG.info("get baseTransactionDto: " + baseTransactionDto);
BroadcastTransactionSynchronous broadcastTransactionSynchronous = new BroadcastTransactionSynchronous(id,
baseTransactionDto);
GetBroadcastTransactionSynchronousDto broadcastTransactionSynchronousDto = Util
.executePost(broadcastTransactionSynchronous, GetBroadcastTransactionSynchronousDto.class, URL_NODE);
LOG.info("Get result:" + broadcastTransactionSynchronousDto);
LOG.info("Finish method broadcastTransactionSynchronousVote");
}
示例10: broadcastTransactionSynchronousComment
import org.bitcoinj.core.DumpedPrivateKey; //导入依赖的package包/类
protected static void broadcastTransactionSynchronousComment() throws Exception {
LOG.info("Start method broadcastTransactionSynchronousComment");
int id = 2;
GetDynamicGlobalPropertiesDto getDynamicGlobalPropertiesDto = getDynamicGlobalProperties();
DynamicGlobalPropertiesDto dynamicGlobalPropertiesDto = getDynamicGlobalPropertiesDto.getResults();
BaseTransactionDto baseTransactionDto = new BaseTransactionDto();
long headBlockNumber = dynamicGlobalPropertiesDto.getHeadBlockNumber();
String headBlockId = dynamicGlobalPropertiesDto.getHeadBlockId();
int refBlockNum = TransactionUtil.long2Last2Byte(headBlockNumber);
baseTransactionDto.setRefBlockNum(refBlockNum);
long refBlockPrefix = TransactionUtil.hexString2Long(headBlockId, 4);
baseTransactionDto.setRefBlockPrefix(refBlockPrefix);
Date time = dynamicGlobalPropertiesDto.getTime();
Date expiration = Util.addTime(time, BaseTransactionDto.DEFAULT_EXPIRATION_TIME);
baseTransactionDto.setExpiration(expiration);
List<BaseOperation> operations = baseTransactionDto.getOperations();
CommentDto commentDto = new CommentDto();
operations.add(commentDto);
String title = "Test post author " + ACCOUNT + " привет";
String permlink = Util.title2Permlink(title);
String image = "https://imgp.golos.io/0x0/http://s1.iconbird.com/ico/2013/8/429/w512h5121377940192185096settingsstreamline.png ";
String body = "This is body. \n This is auto post write " + ACCOUNT + "! \n "
+ "(Тест, этот авто пост написан " + ACCOUNT + ") \n " + image;
Map<String, List<String>> key2value = new HashMap<String, List<String>>();
List<String> tags = new ArrayList<String>();
tags.add("ru--programmirovanie");
tags.add("ru--golos4j");
tags.add("api");
List<String> images = new ArrayList<String>();
images.add(image);
key2value.put(CommentDto.TAGS_KEY, tags);
key2value.put(CommentDto.IMAGE_KEY, images);
// key2value.put(CommentDto.LINKS_KEY, value)
commentDto.setAuthor(ACCOUNT);
commentDto.setBody(body);
commentDto.setJsonMetadata(key2value);
commentDto.setParentAuthor("");
commentDto.setParentPermlink("rzd-free-seat");
commentDto.setPermlink(permlink);
commentDto.setTitle(title);
GetConfigDto getConfigDto = getConfig();
ConfigDto configDto = getConfigDto.getResults();
String chainId = configDto.getSteemitChainId();
ECKey postingKey = DumpedPrivateKey.fromBase58(null, PRIVATE_KEY)
.getKey();
baseTransactionDto.setSignatures(chainId, postingKey);
LOG.info("get baseTransactionDto: " + baseTransactionDto);
BroadcastTransactionSynchronous broadcastTransactionSynchronous = new BroadcastTransactionSynchronous(id,
baseTransactionDto);
GetBroadcastTransactionSynchronousDto broadcastTransactionSynchronousDto = Util
.executePost(broadcastTransactionSynchronous, GetBroadcastTransactionSynchronousDto.class, URL_NODE);
LOG.info("Get result:" + broadcastTransactionSynchronousDto);
LOG.info("Finish method broadcastTransactionSynchronousComment");
}
示例11: broadcastTransactionSynchronousTransfer
import org.bitcoinj.core.DumpedPrivateKey; //导入依赖的package包/类
protected static void broadcastTransactionSynchronousTransfer() throws Exception {
LOG.info("Start method broadcastTransactionSynchronousTransfer");
int id = 2;
GetDynamicGlobalPropertiesDto getDynamicGlobalPropertiesDto = getDynamicGlobalProperties();
DynamicGlobalPropertiesDto dynamicGlobalPropertiesDto = getDynamicGlobalPropertiesDto.getResults();
BaseTransactionDto baseTransactionDto = new BaseTransactionDto();
long headBlockNumber = dynamicGlobalPropertiesDto.getHeadBlockNumber();
String headBlockId = dynamicGlobalPropertiesDto.getHeadBlockId();
int refBlockNum = TransactionUtil.long2Last2Byte(headBlockNumber);
baseTransactionDto.setRefBlockNum(refBlockNum);
long refBlockPrefix = TransactionUtil.hexString2Long(headBlockId, 4);
baseTransactionDto.setRefBlockPrefix(refBlockPrefix);
Date time = dynamicGlobalPropertiesDto.getTime();
Date expiration = Util.addTime(time, BaseTransactionDto.DEFAULT_EXPIRATION_TIME);
baseTransactionDto.setExpiration(expiration);
List<BaseOperation> operations = baseTransactionDto.getOperations();
TransferDto transferDto = new TransferDto();
operations.add(transferDto);
transferDto.setFrom(ACCOUNT);
transferDto.setTo("onixred");
transferDto.setAmount("0.005 GOLOS");
transferDto.setMemo("test log4j");
GetConfigDto getConfigDto = getConfig();
ConfigDto configDto = getConfigDto.getResults();
String chainId = configDto.getSteemitChainId();
org.bitcoinj.core.ECKey postingKey = org.bitcoinj.core.DumpedPrivateKey.fromBase58(null, PRIVATE_KEY2)
.getKey();
baseTransactionDto.setSignatures(chainId, postingKey);
LOG.info("get baseTransactionDto: " + baseTransactionDto);
BroadcastTransactionSynchronous broadcastTransactionSynchronous = new BroadcastTransactionSynchronous(id,
baseTransactionDto);
GetBroadcastTransactionSynchronousDto broadcastTransactionSynchronousDto = Util
.executePost(broadcastTransactionSynchronous, GetBroadcastTransactionSynchronousDto.class, URL_NODE);
LOG.info("Get result:" + broadcastTransactionSynchronousDto);
LOG.info("Finish method broadcastTransactionSynchronousTransfer");
}
示例12: maybeDecodeKey
import org.bitcoinj.core.DumpedPrivateKey; //导入依赖的package包/类
private void maybeDecodeKey() {
checkState(state == State.DECODE_KEY);
checkState(privateKeyToSweep != null);
if (privateKeyToSweep instanceof DumpedPrivateKey) {
final ECKey key = ((DumpedPrivateKey) privateKeyToSweep).getKey();
askConfirmSweep(key);
} else if (privateKeyToSweep instanceof BIP38PrivateKey) {
badPasswordView.setVisibility(View.INVISIBLE);
final String password = passwordView.getText().toString().trim();
passwordView.setText(null); // get rid of it asap
if (!password.isEmpty()) {
ProgressDialogFragment.showProgress(fragmentManager,
getString(R.string.sweep_wallet_fragment_decrypt_progress));
new DecodePrivateKeyTask(backgroundHandler) {
@Override
protected void onSuccess(ECKey decryptedKey) {
log.info("successfully decoded BIP38 private key");
ProgressDialogFragment.dismissProgress(fragmentManager);
askConfirmSweep(decryptedKey);
}
@Override
protected void onBadPassphrase() {
log.info("failed decoding BIP38 private key (bad password)");
ProgressDialogFragment.dismissProgress(fragmentManager);
badPasswordView.setVisibility(View.VISIBLE);
passwordView.requestFocus();
}
}.decodePrivateKey((BIP38PrivateKey) privateKeyToSweep, password);
}
} else {
throw new IllegalStateException("cannot handle type: " + privateKeyToSweep.getClass().getName());
}
}
示例13: handlePrivateKey
import org.bitcoinj.core.DumpedPrivateKey; //导入依赖的package包/类
protected void handlePrivateKey(final VersionedChecksummedBytes key) {
final Address address = new Address(Constants.NETWORK_PARAMETERS,
((DumpedPrivateKey) key).getKey().getPubKeyHash());
handlePaymentIntent(PaymentIntent.fromAddress(address, null));
}
示例14: getPaymentAddress
import org.bitcoinj.core.DumpedPrivateKey; //导入依赖的package包/类
public PaymentAddress getPaymentAddress(PaymentCode pcode, int idx, Address address) throws AddressFormatException, NotSecp256k1Exception {
DumpedPrivateKey dpk = new DumpedPrivateKey(MainNetParams.get(), address.getPrivateKeyString());
ECKey eckey = dpk.getKey();
PaymentAddress paymentAddress = new PaymentAddress(pcode, idx, eckey.getPrivKeyBytes());
return paymentAddress;
}
示例15: updateAccountAuthorities
import org.bitcoinj.core.DumpedPrivateKey; //导入依赖的package包/类
/**
* Method that will actually perform a call to the full node and update the key controlling
* the account specified at the private field called 'updatingAccount'.
*/
private void updateAccountAuthorities() {
UserAccount account = currentTask.getAccount();
BrainKey brainKey = currentTask.getBrainKey();
oldKey = String.format("%s:%s", account.getName(), brainKey.getWalletImportFormat());
Log.d(TAG, "updateAccountAuthorities. account to update: " + account.getName() + ", id: " + account.getObjectId());
Log.d(TAG, "current brain key: " + brainKey.getBrainKey());
try {
// Coming up with a new brain key suggestion
BufferedReader reader = new BufferedReader(new InputStreamReader(getAssets().open(AccountActivity.BRAINKEY_FILE), "UTF-8"));
String dictionary = reader.readLine();
String suggestion = BrainKey.suggest(dictionary);
newBrainKey = new BrainKey(suggestion, 0);
/* Keeping this suggestion in shared preferences in case we get interrupted */
storeSuggestion(suggestion);
/* Storing the key in the database for long-term */
database.insertKey(newBrainKey);
Log.d(TAG, "new brain key: " + suggestion);
// Keeping a reference of the account to be changed, with the updated values
Address address = new Address(ECKey.fromPublicOnly(newBrainKey.getPrivateKey().getPubKey()));
// Building a transaction that will be used to update the account key
HashMap<PublicKey, Long> authMap = new HashMap<>();
authMap.put(address.getPublicKey(), 1L);
Authority authority = new Authority(1, authMap, null);
AccountOptions options = new AccountOptions(address.getPublicKey());
AccountUpdateOperationBuilder builder = new AccountUpdateOperationBuilder()
.setAccount(currentTask.getAccount())
.setActive(authority)
.setOptions(options);
AccountUpdateOperation op = builder.build();
if (currentTask.isUpdateOwner()) {
// Only changing the "owner" authority in some cases.
op.setOwner(authority);
}
// if(currentTask.isUpdateMemo()){
// // Only changing the "memo" authority if it is the same as the active.
// builder.setOptions(options);
// }
ArrayList<BaseOperation> operations = new ArrayList<>();
operations.add(op);
Date date = Calendar.getInstance().getTime();
long expirationTime = (date.getTime() / 1000) + Transaction.DEFAULT_EXPIRATION_TIME;
BlockData blockData = new BlockData(Application.refBlockNum, Application.refBlockPrefix, expirationTime);
Transaction transaction = new Transaction(DumpedPrivateKey.fromBase58(null, brainKey.getWalletImportFormat()).getKey(), blockData, operations);
refreshKeyWorker = new WebsocketWorkerThread(new TransactionBroadcastSequence(transaction, new Asset("1.3.0"), refreshKeysListener), nodeIndex);
refreshKeyWorker.start();
} catch (IOException e) {
Log.e(TAG, "IOException. Msg: " + e.getMessage());
}
}