Skip to content

Commit

Permalink
added no signed marshal
Browse files Browse the repository at this point in the history
  • Loading branch information
tersedream committed May 29, 2024
1 parent 0cf4097 commit 737c512
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions types/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,25 @@ func (tx *Transaction) MarshalBinary() ([]byte, error) {
return output, nil
}

func (tx *Transaction) NoSignedMarshalBinary() ([]byte, error) {

messageContent, err := tx.Message.MarshalBinary()
if err != nil {
return nil, fmt.Errorf("failed to encode tx.Message to binary: %w", err)
}

var signatureCount []byte
encodbin.EncodeCompactU16Length(&signatureCount, len(tx.Signatures))
output := make([]byte, 0, len(signatureCount)+len(signatureCount)*64+len(messageContent))
output = append(output, signatureCount...)
for _, sig := range tx.Signatures {
output = append(output, sig[:]...)
}
output = append(output, messageContent...)

return output, nil
}

// UnmarshalJSON parses the transaction Content
func (tx *Transaction) UnmarshalJSON(input []byte) error {
// Unmarshal data to []byte
Expand Down

0 comments on commit 737c512

Please sign in to comment.