Skip to content

Commit

Permalink
Merge pull request #585 from dashpay/fix/asset-lock-payload
Browse files Browse the repository at this point in the history
Fix/asset lock payload
  • Loading branch information
Syn-McJ authored Dec 30, 2024
2 parents 629ca9d + 9e286c7 commit 6c7a5d3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
31 changes: 31 additions & 0 deletions DashSync/shared/Models/Transactions/Base/DSAssetLockTransaction.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#import "DSChain.h"
#import "DSTransactionFactory.h"
#import "NSData+Dash.h"
#import "NSMutableData+Dash.h"

@implementation DSAssetLockTransaction

Expand Down Expand Up @@ -58,4 +59,34 @@ - (instancetype)initWithMessage:(NSData *)message onChain:(DSChain *)chain {

return self;
}

- (NSData *)payloadData {
return [self basePayloadData];
}

- (NSData *)basePayloadData {
NSMutableData *data = [NSMutableData data];
[data appendUInt8:self.specialTransactionVersion];
NSUInteger creditOutputsCount = self.creditOutputs.count;
[data appendVarInt:creditOutputsCount];
for (NSUInteger i = 0; i < creditOutputsCount; i++) {
DSTransactionOutput *output = self.creditOutputs[i];
[data appendUInt64:output.amount];
[data appendCountedData:output.outScript];
}
return data;
}

- (NSData *)toDataWithSubscriptIndex:(NSUInteger)subscriptIndex {
@synchronized(self) {
NSMutableData *data = [[super toDataWithSubscriptIndex:subscriptIndex] mutableCopy];
[data appendCountedData:[self payloadData]];
if (subscriptIndex != NSNotFound) [data appendUInt32:SIGHASH_ALL];
return data;
}
}
- (size_t)size {
return [super size] + [self payloadData].length;
}

@end
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ PODS:
- gRPC/Interface-Legacy (1.49.0):
- gRPC-RxLibrary/Interface (= 1.49.0)
- KVO-MVVM (0.5.1)
- Protobuf (3.28.3)
- Protobuf (3.29.2)
- SDWebImage (5.14.3):
- SDWebImage/Core (= 5.14.3)
- SDWebImage/Core (5.14.3)
Expand Down Expand Up @@ -721,7 +721,7 @@ SPEC CHECKSUMS:
gRPC-ProtoRPC: 1c223e0f1732bb8d0b9e9e0ea60cc0fe995b8e2d
gRPC-RxLibrary: 92327f150e11cf3b1c0f52e083944fd9f5cb5d1e
KVO-MVVM: 4df3afd1f7ebcb69735458b85db59c4271ada7c6
Protobuf: 5a8a7781d8e1004302f108977ac2d5b99323146f
Protobuf: ba5d83b2201386fec27d484c099cac510ea5c169
SDWebImage: 9c36e66c8ce4620b41a7407698dda44211a96764
tinycbor: d4d71dddda1f8392fbb4249f63faf8552f327590
TinyCborObjc: 5204540fb90ff0c40fb22d408fa51bab79d78a80
Expand Down

0 comments on commit 6c7a5d3

Please sign in to comment.