Skip to content

Commit

Permalink
network id and user agent
Browse files Browse the repository at this point in the history
  • Loading branch information
koh-gt committed Aug 15, 2024
1 parent d7e88cb commit e99c31d
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ target
*.iml
*.chain
*.spvchain
checkpoints
checkpoints.txt
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.ferritej</groupId>
<artifactId>ferritej-parent</artifactId>
<version>0.14.2</version>
<version>1.0.0</version>
</parent>

<artifactId>ferritej-core</artifactId>
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/java/org/bitcoinj/core/NetworkParameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ public abstract class NetworkParameters {
public static final byte[] SATOSHI_KEY = Utils.HEX.decode("04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");
// Alert: removed from Bitcoin Core since March 2016 - 1AGRxqDa5WjUKBwHB9XYEjmkv1ucoUUy1s
/** The string returned by getId() for the main, production network where people trade things. */
public static final String ID_MAINNET = "org.bitcoin.production";
public static final String ID_MAINNET = "org.ferrite.production";
/** The string returned by getId() for the testnet. */
public static final String ID_TESTNET = "org.bitcoin.test";
public static final String ID_TESTNET = "org.ferrite.test";
/** The string returned by getId() for regtest mode. */
public static final String ID_REGTEST = "org.bitcoin.regtest";
public static final String ID_REGTEST = "org.ferrite.regtest";
/** Unit test network. */
public static final String ID_UNITTESTNET = "org.bitcoinj.unittest";
public static final String ID_UNITTESTNET = "org.ferritej.unittest";

/** The string used by the payment protocol to represent the main net. */
public static final String PAYMENT_PROTOCOL_ID_MAINNET = "main";
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/bitcoinj/core/VersionMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ public class VersionMessage extends Message {
public boolean relayTxesBeforeFilter;

/** The version of this library release, as a string. */
public static final String BITCOINJ_VERSION = "0.14.2";
public static final String BITCOINJ_VERSION = "1.0.0";
/** The value that is prepended to the subVer field of this application. */
public static final String LIBRARY_SUBVER = "/bitcoinj:" + BITCOINJ_VERSION + "/";
public static final String LIBRARY_SUBVER = "/FerriteJ:" + BITCOINJ_VERSION + "/";

public VersionMessage(NetworkParameters params, byte[] payload) throws ProtocolException {
super(params, payload, 0);
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/bitcoinj/script/ScriptBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ public static Script createRedeemScript(int threshold, List<ECKey> pubkeys) {
* the ledger.
*/
public static Script createOpReturnScript(byte[] data) {
checkArgument(data.length <= 40);
checkArgument(data.length <= 80);
return new ScriptBuilder().op(OP_RETURN).data(data).build();
}

Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/org/bitcoinj/wallet/Wallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -5068,7 +5068,9 @@ public void setTransactionBroadcaster(@Nullable org.bitcoinj.core.TransactionBro
// Don't hold the wallet lock whilst doing this, so if the broadcaster accesses the wallet at some point there
// is no inversion.
for (Transaction tx : toBroadcast) {
checkState(tx.getConfidence().getConfidenceType() == ConfidenceType.PENDING);
ConfidenceType confidenceType = tx.getConfidence().getConfidenceType();
checkState(confidenceType == ConfidenceType.PENDING || confidenceType == ConfidenceType.IN_CONFLICT,
"Expected PENDING or IN_CONFLICT, was %s.", confidenceType);
// Re-broadcast even if it's marked as already seen for two reasons
// 1) Old wallets may have transactions marked as broadcast by 1 peer when in reality the network
// never saw it, due to bugs.
Expand Down
11 changes: 11 additions & 0 deletions core/src/test/java/org/bitcoinj/wallet/WalletTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2167,6 +2167,17 @@ public void opReturnOneOutputTest() throws Exception {
wallet.completeTx(request);
}

@Test
public void opReturnMaxBytes() throws Exception {
receiveATransaction(wallet, myAddress);
Transaction tx = new Transaction(PARAMS);
Script script = ScriptBuilder.createOpReturnScript(new byte[80]);
tx.addOutput(Coin.ZERO, script);
SendRequest request = SendRequest.forTx(tx);
request.ensureMinRequiredFee = true;
wallet.completeTx(request);
}

@Test
public void opReturnOneOutputWithValueTest() throws Exception {
// Tests basic send of transaction with one output that destroys coins and has an OP_RETURN.
Expand Down
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.ferritej</groupId>
<artifactId>ferritej-parent</artifactId>
<version>0.14.2</version>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.ferritej</groupId>
<artifactId>ferritej-parent</artifactId>
<version>0.14.2</version>
<version>1.0.0</version>
<packaging>pom</packaging>

<modules>
Expand Down
2 changes: 1 addition & 1 deletion tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>org.ferritej</groupId>
<artifactId>ferritej-parent</artifactId>
<version>0.14.2</version>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion wallettemplate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.ferritej</groupId>
<artifactId>ferritej-parent</artifactId>
<version>0.14.2</version>
<version>1.0.0</version>
</parent>

<artifactId>wallettemplate</artifactId>
Expand Down

0 comments on commit e99c31d

Please sign in to comment.