Skip to content

Commit 09be2de

Browse files
committed
fix
1 parent cc69443 commit 09be2de

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

lib/tools.go

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,11 +1137,48 @@ func CreateSyncNeoGenesisHdrTx(cmd *cobra.Command, args []string) error {
11371137
}
11381138

11391139
func SignPolyMultiSigTxFile(cmd *cobra.Command, args []string) (err error) {
1140+
poly, acc, err := GetPolyAndAccByCmd(cmd)
1141+
if err != nil {
1142+
return fmt.Errorf("GetPolyAndAccByCmd failed, err:%s", err)
1143+
}
1144+
11401145
rawHex, err := ioutil.ReadFile(args[0])
11411146
if err != nil {
11421147
return
11431148
}
1144-
return SignPolyMultiSigTx(cmd, []string{string(rawHex)})
1149+
tx := &types.Transaction{}
1150+
raw, err := hex.DecodeString(string(rawHex))
1151+
if err != nil {
1152+
return fmt.Errorf("DecodeString failed, err:%s", err)
1153+
}
1154+
if err := tx.Deserialization(common.NewZeroCopySource(raw)); err != nil {
1155+
return fmt.Errorf("Deserialization failed, err:%s", err)
1156+
}
1157+
1158+
if err = poly.MultiSignToTransaction(tx, tx.Sigs[0].M, tx.Sigs[0].PubKeys, acc); err != nil {
1159+
return fmt.Errorf("multi sign failed, err: %s", err)
1160+
}
1161+
1162+
sink := common.NewZeroCopySink(nil)
1163+
err = tx.Serialization(sink)
1164+
if err != nil {
1165+
return fmt.Errorf("Serialization failed, err:%s", err)
1166+
}
1167+
1168+
if uint16(len(tx.Sigs[0].SigData)) >= tx.Sigs[0].M {
1169+
txhash, err := poly.SendTransaction(tx)
1170+
if err != nil {
1171+
return fmt.Errorf("failed to send tx to poly: %v\nRaw Tx: %s\n", err, hex.EncodeToString(sink.Bytes()))
1172+
}
1173+
WaitPolyTx(txhash, poly)
1174+
fmt.Printf("successful to sign poly tx and send tx %s to Poly with enough sigs\n", txhash.ToHexString())
1175+
return nil
1176+
}
1177+
fmt.Printf("successful to sign tx and %d/%d sigs now, need at least %d sig: raw tx: %s\n", len(tx.Sigs[0].SigData),
1178+
len(tx.Sigs[0].PubKeys), tx.Sigs[0].M, hex.EncodeToString(sink.Bytes()))
1179+
1180+
return nil
1181+
11451182
}
11461183

11471184
func SignPolyMultiSigTx(cmd *cobra.Command, args []string) error {

0 commit comments

Comments
 (0)