本文整理了Java中org.bitcoinj.wallet.Wallet.saveToFile()
方法的一些代码示例,展示了Wallet.saveToFile()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Wallet.saveToFile()
方法的具体详情如下:
包路径:org.bitcoinj.wallet.Wallet
类名称:Wallet
方法名:saveToFile
[英]Uses protobuf serialization to save the wallet to the given file. To learn more about this file format, see WalletProtobufSerializer. Writes out first to a temporary file in the same directory and then renames once written.
[中]使用protobuf序列化将钱包保存到给定文件。要了解有关此文件格式的更多信息,请参阅WalletProtobufSerializer。首先写入同一目录中的临时文件,然后在写入后重命名。
代码示例来源:origin: HashEngineering/dashj
/**
* Uses protobuf serialization to save the wallet to the given file. To learn more about this file format, see
* {@link WalletProtobufSerializer}. Writes out first to a temporary file in the same directory and then renames
* once written.
*/
public void saveToFile(File f) throws IOException {
File directory = f.getAbsoluteFile().getParentFile();
File temp = File.createTempFile("wallet", null, directory);
saveToFile(temp, f);
}
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
/**
* Uses protobuf serialization to save the wallet to the given file. To learn more about this file format, see
* {@link WalletProtobufSerializer}. Writes out first to a temporary file in the same directory and then renames
* once written.
*/
public void saveToFile(File f) throws IOException {
File directory = f.getAbsoluteFile().getParentFile();
File temp = File.createTempFile("wallet", null, directory);
saveToFile(temp, f);
}
代码示例来源:origin: fr.acinq/bitcoinj-core
/**
* Uses protobuf serialization to save the wallet to the given file. To learn more about this file format, see
* {@link WalletProtobufSerializer}. Writes out first to a temporary file in the same directory and then renames
* once written.
*/
public void saveToFile(File f) throws IOException {
File directory = f.getAbsoluteFile().getParentFile();
File temp = File.createTempFile("wallet", null, directory);
saveToFile(temp, f);
}
代码示例来源:origin: greenaddress/GreenBits
/**
* Uses protobuf serialization to save the wallet to the given file. To learn more about this file format, see
* {@link WalletProtobufSerializer}. Writes out first to a temporary file in the same directory and then renames
* once written.
*/
public void saveToFile(File f) throws IOException {
File directory = f.getAbsoluteFile().getParentFile();
File temp = File.createTempFile("wallet", null, directory);
saveToFile(temp, f);
}
代码示例来源:origin: HashEngineering/dashj
private static void saveWallet(File walletFile) {
try {
// This will save the new state of the wallet to a temp file then rename, in case anything goes wrong.
wallet.saveToFile(walletFile);
} catch (IOException e) {
System.err.println("Failed to save wallet! Old wallet should be left untouched.");
e.printStackTrace();
System.exit(1);
}
}
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
private void saveNowInternal() throws IOException {
final Stopwatch watch = Stopwatch.createStarted();
File directory = file.getAbsoluteFile().getParentFile();
File temp = File.createTempFile("wallet", null, directory);
final Listener listener = vListener;
if (listener != null)
listener.onBeforeAutoSave(temp);
wallet.saveToFile(temp, file);
if (listener != null)
listener.onAfterAutoSave(file);
watch.stop();
log.info("Save completed in {}", watch);
}
代码示例来源:origin: fr.acinq/bitcoinj-core
private void saveNowInternal() throws IOException {
final Stopwatch watch = Stopwatch.createStarted();
File directory = file.getAbsoluteFile().getParentFile();
File temp = File.createTempFile("wallet", null, directory);
final Listener listener = vListener;
if (listener != null)
listener.onBeforeAutoSave(temp);
wallet.saveToFile(temp, file);
if (listener != null)
listener.onAfterAutoSave(file);
watch.stop();
log.info("Save completed in {}", watch);
}
代码示例来源:origin: HashEngineering/dashj
private void saveNowInternal() throws IOException {
final Stopwatch watch = Stopwatch.createStarted();
File directory = file.getAbsoluteFile().getParentFile();
File temp = File.createTempFile("wallet", null, directory);
final Listener listener = vListener;
if (listener != null)
listener.onBeforeAutoSave(temp);
wallet.saveToFile(temp, file);
if (listener != null)
listener.onAfterAutoSave(file);
watch.stop();
log.info("Save completed in {}", watch);
}
代码示例来源:origin: greenaddress/GreenBits
private void saveNowInternal() throws IOException {
final Stopwatch watch = Stopwatch.createStarted();
File directory = file.getAbsoluteFile().getParentFile();
File temp = File.createTempFile("wallet", null, directory);
final Listener listener = vListener;
if (listener != null)
listener.onBeforeAutoSave(temp);
wallet.saveToFile(temp, file);
if (listener != null)
listener.onAfterAutoSave(file);
watch.stop();
log.info("Save completed in {}", watch);
}
代码示例来源:origin: HashEngineering/dashj
@Override
protected void shutDown() throws Exception {
// Runs in a separate thread.
try {
Context.propagate(context);
vPeerGroup.stop();
vWallet.saveToFile(vWalletFile);
vStore.close();
vPeerGroup = null;
vWallet = null;
vStore = null;
vChain = null;
} catch (BlockStoreException e) {
throw new IOException(e);
}
}
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
@Override
protected void shutDown() throws Exception {
// Runs in a separate thread.
try {
Context.propagate(context);
vPeerGroup.stop();
vWallet.saveToFile(vWalletFile);
vStore.close();
vPeerGroup = null;
vWallet = null;
vStore = null;
vChain = null;
} catch (BlockStoreException e) {
throw new IOException(e);
}
}
代码示例来源:origin: fr.acinq/bitcoinj-core
@Override
protected void shutDown() throws Exception {
// Runs in a separate thread.
try {
Context.propagate(context);
vPeerGroup.stop();
vWallet.saveToFile(vWalletFile);
vStore.close();
vPeerGroup = null;
vWallet = null;
vStore = null;
vChain = null;
} catch (BlockStoreException e) {
throw new IOException(e);
}
}
代码示例来源:origin: greenaddress/GreenBits
@Override
protected void shutDown() throws Exception {
// Runs in a separate thread.
try {
Context.propagate(context);
vPeerGroup.stop();
vWallet.saveToFile(vWalletFile);
vStore.close();
vPeerGroup = null;
vWallet = null;
vStore = null;
vChain = null;
} catch (BlockStoreException e) {
throw new IOException(e);
}
}
代码示例来源:origin: ICOnator/ICOnator-backend
public BitcoinTestPaymentService(BlockChain bitcoinBlockchain,
Context bitcoinContext,
NetworkParameters bitcoinNetworkParameters,
PeerGroup peerGroup,
String walletPassword, String walletPath)
throws IOException, CipherException, UnreadableWalletException {
this.bitcoinBlockchain = bitcoinBlockchain;
this.bitcoinContext = bitcoinContext;
this.bitcoinNetworkParameters = bitcoinNetworkParameters;
this.peerGroup = peerGroup;
File walletFile = new File(walletPath);
if (walletFile.exists()) {
LOG.info("Wallet exists... trying to load from: {}", walletPath);
this.bitcoinWallet = Wallet.loadFromFile(new File(walletPath));
} else {
LOG.info("Wallet does NOT exist... creating one.", walletPath);
this.bitcoinWallet = new Wallet(this.bitcoinContext);
this.bitcoinWallet.saveToFile(walletFile);
}
LOG.info("Wallet loaded: address={}", this.bitcoinWallet.currentReceiveAddress());
this.bitcoinWallet.autosaveToFile(walletFile, 500, TimeUnit.MILLISECONDS, null);
this.bitcoinBlockchain.addWallet(this.bitcoinWallet);
peerGroup.addWallet(this.bitcoinWallet);
}
代码示例来源:origin: HashEngineering/dashj
wallet.saveToFile(walletFile);
代码示例来源:origin: HashEngineering/dashj
public static void main(String[] args) throws Exception {
File file = new File(args[0]);
Wallet wallet = Wallet.loadFromFile(file);
System.out.println(wallet.toString());
// Set up the components and link them together.
final NetworkParameters params = TestNet3Params.get();
BlockStore blockStore = new MemoryBlockStore(params);
BlockChain chain = new BlockChain(params, wallet, blockStore);
final PeerGroup peerGroup = new PeerGroup(params, chain);
peerGroup.startAsync();
wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
@Override
public synchronized void onCoinsReceived(Wallet w, Transaction tx, Coin prevBalance, Coin newBalance) {
System.out.println("\nReceived tx " + tx.getHashAsString());
System.out.println(tx.toString());
}
});
// Now download and process the block chain.
peerGroup.downloadBlockChain();
peerGroup.stopAsync();
wallet.saveToFile(file);
System.out.println("\nDone!\n");
System.out.println(wallet.toString());
}
}
代码示例来源:origin: fr.acinq/bitcoinj-core
private Wallet createOrLoadWallet(boolean shouldReplayWallet) throws Exception {
Wallet wallet;
maybeMoveOldWalletOutOfTheWay();
if (vWalletFile.exists()) {
wallet = loadWallet(shouldReplayWallet);
} else {
wallet = createWallet();
wallet.freshReceiveKey();
for (WalletExtension e : provideWalletExtensions()) {
wallet.addExtension(e);
}
// Currently the only way we can be sure that an extension is aware of its containing wallet is by
// deserializing the extension (see WalletExtension#deserializeWalletExtension(Wallet, byte[]))
// Hence, we first save and then load wallet to ensure any extensions are correctly initialized.
wallet.saveToFile(vWalletFile);
wallet = loadWallet(false);
}
if (useAutoSave) {
this.setupAutoSave(wallet);
}
return wallet;
}
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
private Wallet createOrLoadWallet(boolean shouldReplayWallet) throws Exception {
Wallet wallet;
maybeMoveOldWalletOutOfTheWay();
if (vWalletFile.exists()) {
wallet = loadWallet(shouldReplayWallet);
} else {
wallet = createWallet();
wallet.freshReceiveKey();
for (WalletExtension e : provideWalletExtensions()) {
wallet.addExtension(e);
}
// Currently the only way we can be sure that an extension is aware of its containing wallet is by
// deserializing the extension (see WalletExtension#deserializeWalletExtension(Wallet, byte[]))
// Hence, we first save and then load wallet to ensure any extensions are correctly initialized.
wallet.saveToFile(vWalletFile);
wallet = loadWallet(false);
}
if (useAutoSave) {
this.setupAutoSave(wallet);
}
return wallet;
}
代码示例来源:origin: greenaddress/GreenBits
private Wallet createOrLoadWallet(boolean shouldReplayWallet) throws Exception {
Wallet wallet;
maybeMoveOldWalletOutOfTheWay();
if (vWalletFile.exists()) {
wallet = loadWallet(shouldReplayWallet);
} else {
wallet = createWallet();
wallet.freshReceiveKey();
for (WalletExtension e : provideWalletExtensions()) {
wallet.addExtension(e);
}
// Currently the only way we can be sure that an extension is aware of its containing wallet is by
// deserializing the extension (see WalletExtension#deserializeWalletExtension(Wallet, byte[]))
// Hence, we first save and then load wallet to ensure any extensions are correctly initialized.
wallet.saveToFile(vWalletFile);
wallet = loadWallet(false);
}
if (useAutoSave) {
this.setupAutoSave(wallet);
}
return wallet;
}
代码示例来源:origin: HashEngineering/dashj
private Wallet createOrLoadWallet(boolean shouldReplayWallet) throws Exception {
Wallet wallet;
maybeMoveOldWalletOutOfTheWay();
if (vWalletFile.exists()) {
wallet = loadWallet(shouldReplayWallet);
} else {
wallet = createWallet();
wallet.freshReceiveKey();
for (WalletExtension e : provideWalletExtensions()) {
wallet.addExtension(e);
}
// Currently the only way we can be sure that an extension is aware of its containing wallet is by
// deserializing the extension (see WalletExtension#deserializeWalletExtension(Wallet, byte[]))
// Hence, we first save and then load wallet to ensure any extensions are correctly initialized.
wallet.saveToFile(vWalletFile);
wallet = loadWallet(false);
}
if (useAutoSave) {
this.setupAutoSave(wallet);
}
return wallet;
}
内容来源于网络,如有侵权,请联系作者删除!