mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-14 11:15:51 +00:00
Introduce additional comment and some minor reformatting / simplification of the protobuf serializer.
This commit is contained in:
parent
8796705987
commit
73a5d95bea
@ -104,6 +104,9 @@ public class WalletProtobufSerializer {
|
||||
.setType(Protos.Key.Type.ORIGINAL);
|
||||
if (key.getPrivKeyBytes() != null)
|
||||
buf.setPrivateKey(ByteString.copyFrom(key.getPrivKeyBytes()));
|
||||
// We serialize the public key even if the private key is present for speed reasons: we don't want to do
|
||||
// lots of slow EC math to load the wallet, we prefer to store the redundant data instead. It matters more
|
||||
// on mobile platforms.
|
||||
buf.setPublicKey(ByteString.copyFrom(key.getPubKey()));
|
||||
walletBuilder.addKey(buf);
|
||||
}
|
||||
@ -115,7 +118,7 @@ public class WalletProtobufSerializer {
|
||||
Protos.Transaction.Builder txBuilder = Protos.Transaction.newBuilder();
|
||||
|
||||
txBuilder.setPool(Protos.Transaction.Pool.valueOf(wtx.getPool().getValue()))
|
||||
.setHash(ByteString.copyFrom(tx.getHash().getBytes()))
|
||||
.setHash(hashToByteString(tx.getHash()))
|
||||
.setVersion((int) tx.getVersion());
|
||||
|
||||
if (tx.getUpdateTime() != null) {
|
||||
@ -130,8 +133,8 @@ public class WalletProtobufSerializer {
|
||||
for (TransactionInput input : tx.getInputs()) {
|
||||
Protos.TransactionInput.Builder inputBuilder = Protos.TransactionInput.newBuilder()
|
||||
.setScriptBytes(ByteString.copyFrom(input.getScriptBytes()))
|
||||
.setTransactionOutPointHash(ByteString.copyFrom(input.getOutpoint().getHash().getBytes()))
|
||||
.setTransactionOutPointIndex((int)input.getOutpoint().getIndex()); // FIXME
|
||||
.setTransactionOutPointHash(hashToByteString(input.getOutpoint().getHash()))
|
||||
.setTransactionOutPointIndex((int) input.getOutpoint().getIndex());
|
||||
if (input.hasSequence()) {
|
||||
inputBuilder.setSequence((int)input.getSequence());
|
||||
}
|
||||
@ -146,9 +149,9 @@ public class WalletProtobufSerializer {
|
||||
final TransactionInput spentBy = output.getSpentBy();
|
||||
if (spentBy != null) {
|
||||
Sha256Hash spendingHash = spentBy.getParentTransaction().getHash();
|
||||
int spentByTransactionIndex = spentBy.getParentTransaction().getInputs().indexOf(spentBy);
|
||||
outputBuilder.setSpentByTransactionHash(hashToByteString(spendingHash))
|
||||
.setSpentByTransactionIndex(
|
||||
spentBy.getParentTransaction().getInputs().indexOf(spentBy));
|
||||
.setSpentByTransactionIndex(spentByTransactionIndex);
|
||||
}
|
||||
txBuilder.addTransactionOutput(outputBuilder);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user