fix: addScheduleSignature in ScheduleSignTransaction
@@ -12,9 +12,11 @@ import java.util.LinkedHashMap;
public final class ScheduleSignTransaction extends Transaction<ScheduleSignTransaction> {
private final ScheduleSignTransactionBody.Builder builder;
+ private final SignatureMap.Builder signatureBuilder;
public ScheduleSignTransaction() {
builder = ScheduleSignTransactionBody.newBuilder();
+ signatureBuilder = SignatureMap.newBuilder();
setMaxTransactionFee(new Hbar(5));
}
@@ -23,6 +25,7 @@ public final class ScheduleSignTransaction extends Transaction<ScheduleSignTrans
super(txs);
builder = bodyBuilder.getScheduleSign().toBuilder();
+ signatureBuilder = builder.getSigMap().toBuilder();
}
public ScheduleId getScheduleId() {
@@ -42,9 +45,8 @@ public final class ScheduleSignTransaction extends Transaction<ScheduleSignTrans
}
public ScheduleSignTransaction addScheduleSignature(PublicKey publicKey, byte[] signature) {
- SignatureMap.Builder sigMap = builder.getSigMap().toBuilder();
- sigMap.addSigPair(publicKey.toSignaturePairProtobuf(signature));
-
+ requireNotFrozen();
+ signatureBuilder.addSigPair(publicKey.toSignaturePairProtobuf(signature));
return this;
}
@@ -55,7 +57,7 @@ public final class ScheduleSignTransaction extends Transaction<ScheduleSignTrans
@Override
boolean onFreeze(TransactionBody.Builder bodyBuilder) {
- bodyBuilder.setScheduleSign(builder);
+ bodyBuilder.setScheduleSign(builder.setSigMap(signatureBuilder));
return true;
}
}
