Skip to content

Commit 46a3419

Browse files
authored
Merge pull request #193 from MixinNetwork/fix_send_tx_with_output_panic
fix sub might cause panic
2 parents 5014334 + ed70c50 commit 46a3419

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

transaction.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,14 @@ func SendTransactionWithOutputs(ctx context.Context, assetId string, recipients
183183
amt := common.NewIntegerFromString(in.Amount)
184184
totalInput = totalInput.Add(amt)
185185
}
186-
changeAmount := totalInput.Sub(totalOutput)
187-
if changeAmount.Sign() < 0 {
186+
if totalInput.Cmp(totalOutput) < 0 {
188187
return nil, &UtxoInsufficientError{
189188
TotalInput: totalInput,
190189
TotalOutput: totalOutput,
191190
OutputSize: 1,
192191
}
193192
}
193+
changeAmount := totalInput.Sub(totalOutput)
194194
if changeAmount.Sign() > 0 {
195195
ma := NewUUIDMixAddress([]string{u.UserId}, 1)
196196
recipients = append(recipients, &TransactionRecipient{

0 commit comments

Comments
 (0)