Skip to content

Commit

Permalink
feature: SignHashTx() detects if it is a GAMetaTx and if so makes the…
Browse files Browse the repository at this point in the history
… SignedTx with no signatures instead
  • Loading branch information
randomshinichi committed Aug 13, 2019
1 parent 1c18110 commit a384743
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions aeternity/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,21 @@ func Hash(tx *SignedTx) (txhash string, err error) {
return txhash, nil
}

// SignHashTx wraps a *Tx struct in a SignedTx, then calculates the signature
// and hash.
// SignHashTx wraps a *Tx struct in a SignedTx, then returns its signature and
// hash.
func SignHashTx(kp *Account, tx Transaction, networkID string) (signedTx SignedTx, txhash, signature string, err error) {
signedTx = NewSignedTx([][]byte{}, tx)
sigBytes, err := Sign(kp, &signedTx, networkID)
if err != nil {
return
var signatureBytes []byte

if _, ok := tx.(*GAMetaTx); !ok {
signatureBytes, err = Sign(kp, &signedTx, networkID)
if err != nil {
return
}
signedTx.Signatures = append(signedTx.Signatures, signatureBytes)
signature = Encode(PrefixSignature, signatureBytes)

}
signedTx.Signatures = append(signedTx.Signatures, sigBytes)
signature = Encode(PrefixSignature, sigBytes)

txhash, err = Hash(&signedTx)
if err != nil {
Expand Down

0 comments on commit a384743

Please sign in to comment.