mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-11-17 04:47:28 +00:00
Wallet protobuf serialization for RAISE_FEE transaction purpose.
This commit is contained in:
@@ -154,6 +154,8 @@ public class Transaction extends ChildMessage implements Serializable {
|
||||
/** Raise fee, e.g. child-pays-for-parent. */
|
||||
RAISE_FEE,
|
||||
// In future: de/refragmentation, privacy boosting/mixing, etc.
|
||||
// When adding a value, it also needs to be added to wallet.proto, WalletProtobufSerialize.makeTxProto()
|
||||
// and WalletProtobufSerializer.readTransaction()!
|
||||
}
|
||||
|
||||
private Purpose purpose = Purpose.UNKNOWN;
|
||||
|
||||
@@ -299,6 +299,7 @@ public class WalletProtobufSerializer {
|
||||
case ASSURANCE_CONTRACT_CLAIM: purpose = Protos.Transaction.Purpose.ASSURANCE_CONTRACT_CLAIM; break;
|
||||
case ASSURANCE_CONTRACT_PLEDGE: purpose = Protos.Transaction.Purpose.ASSURANCE_CONTRACT_PLEDGE; break;
|
||||
case ASSURANCE_CONTRACT_STUB: purpose = Protos.Transaction.Purpose.ASSURANCE_CONTRACT_STUB; break;
|
||||
case RAISE_FEE: purpose = Protos.Transaction.Purpose.RAISE_FEE; break;
|
||||
default:
|
||||
throw new RuntimeException("New tx purpose serialization not implemented.");
|
||||
}
|
||||
@@ -595,6 +596,7 @@ public class WalletProtobufSerializer {
|
||||
case ASSURANCE_CONTRACT_CLAIM: tx.setPurpose(Transaction.Purpose.ASSURANCE_CONTRACT_CLAIM); break;
|
||||
case ASSURANCE_CONTRACT_PLEDGE: tx.setPurpose(Transaction.Purpose.ASSURANCE_CONTRACT_PLEDGE); break;
|
||||
case ASSURANCE_CONTRACT_STUB: tx.setPurpose(Transaction.Purpose.ASSURANCE_CONTRACT_STUB); break;
|
||||
case RAISE_FEE: tx.setPurpose(Transaction.Purpose.RAISE_FEE); break;
|
||||
default: throw new RuntimeException("New purpose serialization not implemented");
|
||||
}
|
||||
} else {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,6 +19,7 @@ package org.bitcoinj.store;
|
||||
|
||||
|
||||
import org.bitcoinj.core.*;
|
||||
import org.bitcoinj.core.Transaction.Purpose;
|
||||
import org.bitcoinj.core.TransactionConfidence.ConfidenceType;
|
||||
import org.bitcoinj.crypto.DeterministicKey;
|
||||
import org.bitcoinj.params.MainNetParams;
|
||||
@@ -133,6 +134,18 @@ public class WalletProtobufSerializerTest {
|
||||
assertEquals(t1p.getTransactionOutput(0).getValue(), v1.value);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void raiseFeeTx() throws Exception {
|
||||
// Check basic tx serialization.
|
||||
Coin v1 = COIN;
|
||||
Transaction t1 = createFakeTx(params, v1, myAddress);
|
||||
t1.setPurpose(Purpose.RAISE_FEE);
|
||||
myWallet.receivePending(t1, null);
|
||||
Wallet wallet1 = roundTrip(myWallet);
|
||||
Transaction t1copy = wallet1.getTransaction(t1.getHash());
|
||||
assertEquals(Purpose.RAISE_FEE, t1copy.getPurpose());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doubleSpend() throws Exception {
|
||||
// Check that we can serialize double spends correctly, as this is a slightly tricky case.
|
||||
|
||||
@@ -271,6 +271,8 @@ message Transaction {
|
||||
ASSURANCE_CONTRACT_CLAIM = 3;
|
||||
ASSURANCE_CONTRACT_PLEDGE = 4;
|
||||
ASSURANCE_CONTRACT_STUB = 5;
|
||||
// Raise fee, e.g. child-pays-for-parent.
|
||||
RAISE_FEE = 6;
|
||||
// In future: de/refragmentation, privacy boosting/mixing, child-pays-for-parent fees, etc.
|
||||
}
|
||||
optional Purpose purpose = 10 [default = UNKNOWN];
|
||||
|
||||
Reference in New Issue
Block a user