-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multisign with existing transaction #104
Comments
I encountered the same problem as yours, have you solved it? |
Yes I have. I'll tell you how to do that soon |
I am very anxious😭😭😭😭😭 |
Here is an example how I did that stuff: ...
rawData, err := hex.DecodeString(withdrawal.RawDataHex)
if err != nil {
return errors.Wrap(err, "failed to marshal rawData")
}
tx := new(core.Transaction)
tx.RawData = new(core.TransactionRaw)
if err := proto.Unmarshal(rawData, tx.RawData); err != nil {
return errors.Wrap(err, "failed to parse proto")
}
signatures, err := stringArrayToByteSlice(withdrawal.Signatures)
if err != nil {
return errors.Wrap(err, "failed to unmarshal signatures")
}
h256h := sha256.New()
h256h.Write(rawData)
hash := h256h.Sum(nil)
txHash := hex.EncodeToString(hash)
withdrawal.TxHash = txHash
signature, err := crypto.Sign(hash, p.tronConfig.SignatureKey)
if err != nil {
return errors.Wrap(err, "failed to create signature")
}
tx.Signature = append(tx.Signature, signatures...)
tx.Signature = append(tx.Signature, signature)
result, err := p.client.WrappedCli.Broadcast(tx)
...
func stringArrayToByteSlice(signaturesString string) ([][]byte, error) {
var signaturesArray []string
err := json.Unmarshal([]byte(signaturesString), &signaturesArray)
if err != nil {
return nil, err
}
var signatures [][]byte
for _, str := range signaturesArray {
bytes, err := hex.DecodeString(str)
if err != nil {
continue
}
signatures = append(signatures, bytes)
}
return signatures, nil
} |
112#issue-1985969141 |
I'm getting my transaction from front-end in json-like format:
I want to add 1 more signature and broadcast this transaction, but I can't find examples how to create core.Transaction{} of this json tx and broadcast it. If anyone figured it out, please send me some examples.
I've tried to parse it to my own type structs and cast it to core.Transaction, but it was unsuccessful, I guess because of encoding.
Here is an example how I tried to parse it to structs:
The text was updated successfully, but these errors were encountered: