Skip to content

Commit ed70c50

Browse files
boyan01cedricfung
authored andcommitted
fix sub might cause panic
1 parent 5014334 commit ed70c50

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)