mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-08-01 12:31:23 +00:00
Step 2: Move and refactor packages
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
package org.bitcoinj.examples;
|
||||
package com.dogecoin.dogecoinj.examples;
|
||||
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
import org.bitcoinj.core.Wallet;
|
||||
import org.bitcoinj.params.TestNet3Params;
|
||||
import org.bitcoinj.wallet.DeterministicSeed;
|
||||
import com.dogecoin.dogecoinj.core.NetworkParameters;
|
||||
import com.dogecoin.dogecoinj.core.Wallet;
|
||||
import com.dogecoin.dogecoinj.params.TestNet3Params;
|
||||
import com.dogecoin.dogecoinj.wallet.DeterministicSeed;
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
/**
|
@@ -1,14 +1,14 @@
|
||||
package org.bitcoinj.examples;
|
||||
package com.dogecoin.dogecoinj.examples;
|
||||
|
||||
import org.bitcoinj.core.*;
|
||||
import org.bitcoinj.kits.WalletAppKit;
|
||||
import org.bitcoinj.params.RegTestParams;
|
||||
import org.bitcoinj.utils.BriefLogFormatter;
|
||||
import org.bitcoinj.utils.Threading;
|
||||
import com.dogecoin.dogecoinj.core.*;
|
||||
import com.dogecoin.dogecoinj.kits.WalletAppKit;
|
||||
import com.dogecoin.dogecoinj.params.RegTestParams;
|
||||
import com.dogecoin.dogecoinj.utils.BriefLogFormatter;
|
||||
import com.dogecoin.dogecoinj.utils.Threading;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.bitcoinj.core.Coin.*;
|
||||
import static com.dogecoin.dogecoinj.core.Coin.*;
|
||||
|
||||
/**
|
||||
* This is a little test app that waits for a coin on a local regtest node, then generates two transactions that double
|
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.bitcoinj.examples;
|
||||
package com.dogecoin.dogecoinj.examples;
|
||||
|
||||
import org.bitcoinj.core.Wallet;
|
||||
import com.dogecoin.dogecoinj.core.Wallet;
|
||||
|
||||
import java.io.File;
|
||||
|
@@ -15,16 +15,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.bitcoinj.examples;
|
||||
package com.dogecoin.dogecoinj.examples;
|
||||
|
||||
import org.bitcoinj.core.*;
|
||||
import org.bitcoinj.kits.WalletAppKit;
|
||||
import org.bitcoinj.params.RegTestParams;
|
||||
import org.bitcoinj.protocols.channels.PaymentChannelClientConnection;
|
||||
import org.bitcoinj.protocols.channels.StoredPaymentChannelClientStates;
|
||||
import org.bitcoinj.protocols.channels.ValueOutOfRangeException;
|
||||
import org.bitcoinj.utils.BriefLogFormatter;
|
||||
import org.bitcoinj.utils.Threading;
|
||||
import com.dogecoin.dogecoinj.core.*;
|
||||
import com.dogecoin.dogecoinj.kits.WalletAppKit;
|
||||
import com.dogecoin.dogecoinj.params.RegTestParams;
|
||||
import com.dogecoin.dogecoinj.protocols.channels.PaymentChannelClientConnection;
|
||||
import com.dogecoin.dogecoinj.protocols.channels.StoredPaymentChannelClientStates;
|
||||
import com.dogecoin.dogecoinj.protocols.channels.ValueOutOfRangeException;
|
||||
import com.dogecoin.dogecoinj.utils.BriefLogFormatter;
|
||||
import com.dogecoin.dogecoinj.utils.Threading;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
@@ -39,7 +39,7 @@ import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static org.bitcoinj.core.Coin.CENT;
|
||||
import static com.dogecoin.dogecoinj.core.Coin.CENT;
|
||||
|
||||
/**
|
||||
* Simple client that connects to the given host, opens a channel, and pays one cent.
|
@@ -15,17 +15,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.bitcoinj.examples;
|
||||
package com.dogecoin.dogecoinj.examples;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
import org.bitcoinj.core.Sha256Hash;
|
||||
import org.bitcoinj.core.VerificationException;
|
||||
import org.bitcoinj.core.WalletExtension;
|
||||
import org.bitcoinj.kits.WalletAppKit;
|
||||
import org.bitcoinj.params.RegTestParams;
|
||||
import org.bitcoinj.protocols.channels.*;
|
||||
import org.bitcoinj.utils.BriefLogFormatter;
|
||||
import com.dogecoin.dogecoinj.core.Coin;
|
||||
import com.dogecoin.dogecoinj.core.NetworkParameters;
|
||||
import com.dogecoin.dogecoinj.core.Sha256Hash;
|
||||
import com.dogecoin.dogecoinj.core.VerificationException;
|
||||
import com.dogecoin.dogecoinj.core.WalletExtension;
|
||||
import com.dogecoin.dogecoinj.kits.WalletAppKit;
|
||||
import com.dogecoin.dogecoinj.params.RegTestParams;
|
||||
import com.dogecoin.dogecoinj.protocols.channels.*;
|
||||
import com.dogecoin.dogecoinj.utils.BriefLogFormatter;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
@@ -15,13 +15,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.bitcoinj.examples;
|
||||
package com.dogecoin.dogecoinj.examples;
|
||||
|
||||
import org.bitcoinj.core.*;
|
||||
import org.bitcoinj.params.TestNet3Params;
|
||||
import org.bitcoinj.store.BlockStore;
|
||||
import org.bitcoinj.store.MemoryBlockStore;
|
||||
import org.bitcoinj.utils.BriefLogFormatter;
|
||||
import com.dogecoin.dogecoinj.core.*;
|
||||
import com.dogecoin.dogecoinj.params.TestNet3Params;
|
||||
import com.dogecoin.dogecoinj.store.BlockStore;
|
||||
import com.dogecoin.dogecoinj.store.MemoryBlockStore;
|
||||
import com.dogecoin.dogecoinj.utils.BriefLogFormatter;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.concurrent.Future;
|
@@ -15,13 +15,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.bitcoinj.examples;
|
||||
package com.dogecoin.dogecoinj.examples;
|
||||
|
||||
import org.bitcoinj.core.*;
|
||||
import org.bitcoinj.params.TestNet3Params;
|
||||
import org.bitcoinj.store.BlockStore;
|
||||
import org.bitcoinj.store.MemoryBlockStore;
|
||||
import org.bitcoinj.utils.BriefLogFormatter;
|
||||
import com.dogecoin.dogecoinj.core.*;
|
||||
import com.dogecoin.dogecoinj.params.TestNet3Params;
|
||||
import com.dogecoin.dogecoinj.store.BlockStore;
|
||||
import com.dogecoin.dogecoinj.store.MemoryBlockStore;
|
||||
import com.dogecoin.dogecoinj.utils.BriefLogFormatter;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
import java.net.InetAddress;
|
@@ -15,15 +15,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.bitcoinj.examples;
|
||||
package com.dogecoin.dogecoinj.examples;
|
||||
|
||||
import org.bitcoinj.core.*;
|
||||
import org.bitcoinj.crypto.KeyCrypterException;
|
||||
import org.bitcoinj.kits.WalletAppKit;
|
||||
import org.bitcoinj.params.MainNetParams;
|
||||
import org.bitcoinj.params.RegTestParams;
|
||||
import org.bitcoinj.params.TestNet3Params;
|
||||
import org.bitcoinj.utils.BriefLogFormatter;
|
||||
import com.dogecoin.dogecoinj.core.*;
|
||||
import com.dogecoin.dogecoinj.crypto.KeyCrypterException;
|
||||
import com.dogecoin.dogecoinj.kits.WalletAppKit;
|
||||
import com.dogecoin.dogecoinj.params.MainNetParams;
|
||||
import com.dogecoin.dogecoinj.params.RegTestParams;
|
||||
import com.dogecoin.dogecoinj.params.TestNet3Params;
|
||||
import com.dogecoin.dogecoinj.utils.BriefLogFormatter;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
@@ -81,7 +81,7 @@ public class ForwardingService {
|
||||
kit.wallet().addEventListener(new AbstractWalletEventListener() {
|
||||
@Override
|
||||
public void onCoinsReceived(Wallet w, Transaction tx, Coin prevBalance, Coin newBalance) {
|
||||
// Runs in the dedicated "user thread" (see bitcoinj docs for more info on this).
|
||||
// Runs in the dedicated "user thread" (see dogecoinj docs for more info on this).
|
||||
//
|
||||
// The transaction "tx" can either be pending, or included into a block (we didn't see the broadcast).
|
||||
Coin value = tx.getValueSentToMe(w);
|
@@ -1,16 +1,16 @@
|
||||
package org.bitcoinj.examples;
|
||||
package com.dogecoin.dogecoinj.examples;
|
||||
|
||||
import org.bitcoinj.core.*;
|
||||
import org.bitcoinj.kits.WalletAppKit;
|
||||
import org.bitcoinj.params.TestNet3Params;
|
||||
import org.bitcoinj.script.Script;
|
||||
import com.dogecoin.dogecoinj.core.*;
|
||||
import com.dogecoin.dogecoinj.kits.WalletAppKit;
|
||||
import com.dogecoin.dogecoinj.params.TestNet3Params;
|
||||
import com.dogecoin.dogecoinj.script.Script;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The following example shows how to use the by bitcoinj provided WalletAppKit.
|
||||
* The WalletAppKit class wraps the boilerplate (Peers, BlockChain, BlockStorage, Wallet) needed to set up a new SPV bitcoinj app.
|
||||
* The following example shows how to use the by dogecoinj provided WalletAppKit.
|
||||
* The WalletAppKit class wraps the boilerplate (Peers, BlockChain, BlockStorage, Wallet) needed to set up a new SPV dogecoinj app.
|
||||
*
|
||||
* In this example we also define a WalletEventListener class with implementors that are called when the wallet changes (for example sending/receiving money)
|
||||
*/
|
||||
@@ -26,11 +26,11 @@ public class Kit {
|
||||
// While developing your application you probably want to use the Regtest mode and run your local bitcoin network. Run bitcoind with the -regtest flag
|
||||
// To test you app with a real network you can use the testnet. The testnet is an alternative bitcoin network that follows the same rules as main network. Coins are worth nothing and you can get coins for example from http://faucet.xeno-genesis.com/
|
||||
//
|
||||
// For more information have a look at: https://bitcoinj.github.io/testing and https://bitcoin.org/en/developer-examples#testing-applications
|
||||
// For more information have a look at: https://dogecoinj.github.io/testing and https://bitcoin.org/en/developer-examples#testing-applications
|
||||
NetworkParameters params = TestNet3Params.get();
|
||||
|
||||
// Now we initialize a new WalletAppKit. The kit handles all the boilerplate for us and is the easiest way to get everything up and running.
|
||||
// Have a look at the WalletAppKit documentation and its source to understand what's happening behind the scenes: https://github.com/bitcoinj/bitcoinj/blob/master/core/src/main/java/org/bitcoinj/kits/WalletAppKit.java
|
||||
// Have a look at the WalletAppKit documentation and its source to understand what's happening behind the scenes: https://github.com/dogecoinj/dogecoinj/blob/master/core/src/main/java/org/dogecoinj/kits/WalletAppKit.java
|
||||
WalletAppKit kit = new WalletAppKit(params, new File("."), "walletappkit-example");
|
||||
|
||||
// In case you want to connect with your local bitcoind tell the kit to connect to localhost.
|
||||
@@ -38,11 +38,11 @@ public class Kit {
|
||||
//kit.connectToLocalHost();
|
||||
|
||||
// Now we start the kit and sync the blockchain.
|
||||
// bitcoinj is working a lot with the Google Guava libraries. The WalletAppKit extends the AbstractIdleService. Have a look at the introduction to Guava services: https://code.google.com/p/guava-libraries/wiki/ServiceExplained
|
||||
// dogecoinj is working a lot with the Google Guava libraries. The WalletAppKit extends the AbstractIdleService. Have a look at the introduction to Guava services: https://code.google.com/p/guava-libraries/wiki/ServiceExplained
|
||||
kit.startAsync();
|
||||
kit.awaitRunning();
|
||||
|
||||
// To observe wallet events (like coins received) we implement a EventListener class that extends the AbstractWalletEventListener bitcoinj then calls the different functions from the EventListener class
|
||||
// To observe wallet events (like coins received) we implement a EventListener class that extends the AbstractWalletEventListener dogecoinj then calls the different functions from the EventListener class
|
||||
WalletListener wListener = new WalletListener();
|
||||
kit.wallet().addEventListener(wListener);
|
||||
|
@@ -15,15 +15,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.bitcoinj.examples;
|
||||
package com.dogecoin.dogecoinj.examples;
|
||||
|
||||
import org.bitcoinj.core.AbstractPeerEventListener;
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
import org.bitcoinj.core.Peer;
|
||||
import org.bitcoinj.core.PeerGroup;
|
||||
import org.bitcoinj.net.discovery.DnsDiscovery;
|
||||
import org.bitcoinj.params.MainNetParams;
|
||||
import org.bitcoinj.utils.BriefLogFormatter;
|
||||
import com.dogecoin.dogecoinj.core.AbstractPeerEventListener;
|
||||
import com.dogecoin.dogecoinj.core.NetworkParameters;
|
||||
import com.dogecoin.dogecoinj.core.Peer;
|
||||
import com.dogecoin.dogecoinj.core.PeerGroup;
|
||||
import com.dogecoin.dogecoinj.net.discovery.DnsDiscovery;
|
||||
import com.dogecoin.dogecoinj.params.MainNetParams;
|
||||
import com.dogecoin.dogecoinj.utils.BriefLogFormatter;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import javax.swing.*;
|
@@ -14,18 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.bitcoinj.examples;
|
||||
package com.dogecoin.dogecoinj.examples;
|
||||
|
||||
import org.bitcoinj.core.AbstractPeerEventListener;
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
import org.bitcoinj.core.Peer;
|
||||
import org.bitcoinj.core.PeerAddress;
|
||||
import org.bitcoinj.core.VersionMessage;
|
||||
import org.bitcoinj.net.discovery.DnsDiscovery;
|
||||
import org.bitcoinj.net.discovery.PeerDiscoveryException;
|
||||
import org.bitcoinj.net.NioClientManager;
|
||||
import org.bitcoinj.params.MainNetParams;
|
||||
import org.bitcoinj.utils.BriefLogFormatter;
|
||||
import com.dogecoin.dogecoinj.core.AbstractPeerEventListener;
|
||||
import com.dogecoin.dogecoinj.core.NetworkParameters;
|
||||
import com.dogecoin.dogecoinj.core.Peer;
|
||||
import com.dogecoin.dogecoinj.core.PeerAddress;
|
||||
import com.dogecoin.dogecoinj.core.VersionMessage;
|
||||
import com.dogecoin.dogecoinj.net.discovery.DnsDiscovery;
|
||||
import com.dogecoin.dogecoinj.net.discovery.PeerDiscoveryException;
|
||||
import com.dogecoin.dogecoinj.net.NioClientManager;
|
||||
import com.dogecoin.dogecoinj.params.MainNetParams;
|
||||
import com.dogecoin.dogecoinj.utils.BriefLogFormatter;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
@@ -15,11 +15,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.bitcoinj.examples;
|
||||
package com.dogecoin.dogecoinj.examples;
|
||||
|
||||
import org.bitcoinj.core.*;
|
||||
import org.bitcoinj.params.MainNetParams;
|
||||
import org.bitcoinj.store.MemoryBlockStore;
|
||||
import com.dogecoin.dogecoinj.core.*;
|
||||
import com.dogecoin.dogecoinj.params.MainNetParams;
|
||||
import com.dogecoin.dogecoinj.store.MemoryBlockStore;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.net.InetAddress;
|
@@ -15,12 +15,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.bitcoinj.examples;
|
||||
package com.dogecoin.dogecoinj.examples;
|
||||
|
||||
import org.bitcoinj.core.*;
|
||||
import org.bitcoinj.params.TestNet3Params;
|
||||
import org.bitcoinj.store.BlockStore;
|
||||
import org.bitcoinj.store.MemoryBlockStore;
|
||||
import com.dogecoin.dogecoinj.core.*;
|
||||
import com.dogecoin.dogecoinj.params.TestNet3Params;
|
||||
import com.dogecoin.dogecoinj.store.BlockStore;
|
||||
import com.dogecoin.dogecoinj.store.MemoryBlockStore;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.InetAddress;
|
@@ -1,10 +1,10 @@
|
||||
package org.bitcoinj.examples;
|
||||
package com.dogecoin.dogecoinj.examples;
|
||||
|
||||
import org.bitcoinj.core.*;
|
||||
import org.bitcoinj.net.discovery.DnsDiscovery;
|
||||
import org.bitcoinj.params.TestNet3Params;
|
||||
import org.bitcoinj.store.SPVBlockStore;
|
||||
import org.bitcoinj.wallet.DeterministicSeed;
|
||||
import com.dogecoin.dogecoinj.core.*;
|
||||
import com.dogecoin.dogecoinj.net.discovery.DnsDiscovery;
|
||||
import com.dogecoin.dogecoinj.params.TestNet3Params;
|
||||
import com.dogecoin.dogecoinj.store.SPVBlockStore;
|
||||
import com.dogecoin.dogecoinj.wallet.DeterministicSeed;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -31,7 +31,7 @@ public class RestoreFromSeed {
|
||||
Wallet wallet = Wallet.fromSeed(params, seed);
|
||||
|
||||
// Because we are importing an existing wallet which might already have transactions we must re-download the blockchain to make the wallet picks up these transactions
|
||||
// You can find some information about this in the guides: https://bitcoinj.github.io/working-with-the-wallet#setup
|
||||
// You can find some information about this in the guides: https://dogecoinj.github.io/working-with-the-wallet#setup
|
||||
// To do this we clear the transactions of the wallet and delete a possible existing blockchain file before we download the blockchain again further down.
|
||||
System.out.println(wallet.toString());
|
||||
wallet.clearTransactions(0);
|
@@ -1,12 +1,12 @@
|
||||
package org.bitcoinj.examples;
|
||||
package com.dogecoin.dogecoinj.examples;
|
||||
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import org.bitcoinj.core.*;
|
||||
import org.bitcoinj.core.Wallet.BalanceType;
|
||||
import org.bitcoinj.kits.WalletAppKit;
|
||||
import org.bitcoinj.params.TestNet3Params;
|
||||
import com.dogecoin.dogecoinj.core.*;
|
||||
import com.dogecoin.dogecoinj.core.Wallet.BalanceType;
|
||||
import com.dogecoin.dogecoinj.kits.WalletAppKit;
|
||||
import com.dogecoin.dogecoinj.params.TestNet3Params;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class SendRequest {
|
||||
Address to = new Address(params, "mupBAFeT63hXfeeT4rnAUcpKHDkz1n4fdw");
|
||||
|
||||
// There are different ways to create and publish a SendRequest. This is probably the easiest one.
|
||||
// Have a look at the code of the SendRequest class to see what's happening and what other options you have: https://bitcoinj.github.io/javadoc/0.11/com/google/bitcoin/core/Wallet.SendRequest.html
|
||||
// Have a look at the code of the SendRequest class to see what's happening and what other options you have: https://dogecoinj.github.io/javadoc/0.11/com/google/bitcoin/core/Wallet.SendRequest.html
|
||||
//
|
||||
// Please note that this might raise a InsufficientMoneyException if your wallet has not enough coins to spend.
|
||||
// When using the testnet you can use a faucet (like the http://faucet.xeno-genesis.com/) to get testnet coins.
|
@@ -1,12 +1,12 @@
|
||||
// This file shows how to use bitcoinj from Javascript.
|
||||
// To run, grab the bitcoinj bundled JAR and then do something like this:
|
||||
// To run, grab the dogecoinj bundled JAR and then do something like this:
|
||||
//
|
||||
// jjs -cp bitcoinj-0.12-bundled.jar demo.js
|
||||
// jjs -cp dogecoinj-0.12-bundled.jar demo.js
|
||||
//
|
||||
// This will run this file using the Nashorn Javascript engine, which is not quite as fast as V8 but still very
|
||||
// competitive, speed wise. You can also get a repl/interpreter by doing this:
|
||||
//
|
||||
// jjs -cp bitcoinj-0.12-bundled.jar
|
||||
// jjs -cp dogecoinj-0.12-bundled.jar
|
||||
//
|
||||
// and then you can play around in the interpreter.
|
||||
//
|
||||
@@ -24,7 +24,7 @@
|
||||
//
|
||||
// export slf4j=/path/to/slf4j-jdk14-1.7.7.jar
|
||||
//
|
||||
// jjs -cp bitcoinj-0.12-bundled.jar:$slf4fj demo.js
|
||||
// jjs -cp dogecoinj-0.12-bundled.jar:$slf4fj demo.js
|
||||
//
|
||||
// Nashorn implements a slightly extended form of Javascript, you can learn the details of the java interop here:
|
||||
//
|
||||
@@ -91,7 +91,7 @@ connectedPeers.forEach(function(peer) {
|
||||
// just started up.
|
||||
});
|
||||
|
||||
// Nashorn, unlike V8, is thread safe (because it runs on the JVM). And bitcoinj is a threaded library. This means you
|
||||
// Nashorn, unlike V8, is thread safe (because it runs on the JVM). And dogecoinj is a threaded library. This means you
|
||||
// can freely run code in parallel and mix and match concurrent constructs to use your preferred style. Above we used
|
||||
// blocking code. This is convenient in scripts and so on, but sometimes we want to keep the main thread free. Let's
|
||||
// do the same thing but in an async style:
|
||||
|
Reference in New Issue
Block a user