Skip to content

Commit

Permalink
add signature
Browse files Browse the repository at this point in the history
  • Loading branch information
jgimeno committed Nov 11, 2020
1 parent 529f6b8 commit c431f61
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion server/rosetta/services/construction.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,28 @@ func (sn SingleNetwork) ConstructionPayloads(ctx context.Context, request *types
txBldr, err := tx.BuildUnsignedTx(txFactory, sendMsg)

if txFactory.SignMode() == signing.SignMode_SIGN_MODE_UNSPECIFIED {
txFactory = txFactory.WithSignMode(signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON)
txFactory = txFactory.WithSignMode(signing.SignMode_SIGN_MODE_DIRECT)
}

signerData := authsigning.SignerData{
ChainID: txFactory.ChainID(),
AccountNumber: txFactory.AccountNumber(),
Sequence: txFactory.Sequence(),
}

sigData := signing.SingleSignatureData{
SignMode: txFactory.SignMode(),
Signature: nil,
}
sig := signing.SignatureV2{
PubKey: pubKey,
Data: &sigData,
Sequence: txFactory.Sequence(),
}
if err := txBldr.SetSignatures(sig); err != nil {
return nil, rosetta.WrapError(rosetta.ErrInvalidRequest, err.Error()).RosettaError()
}

signBytes, err := TxConfig.SignModeHandler().GetSignBytes(txFactory.SignMode(), signerData, txBldr.GetTx())
if err != nil {
return nil, rosetta.ToRosettaError(err)
Expand Down

0 comments on commit c431f61

Please sign in to comment.