Skip to content

Commit

Permalink
api: Require non-void change address in /fund
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechampine committed Nov 27, 2023
1 parent 5c9bb25 commit 607337e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,9 @@ func (s *server) walletsFundHandler(jc jape.Context) {
if outputSum.Cmp(amount) < 0 {
return nil, errors.New("insufficient balance")
} else if outputSum.Cmp(amount) > 0 {
if changeAddr == types.VoidAddress {
return nil, errors.New("change address must be specified")
}
txn.SiacoinOutputs = append(txn.SiacoinOutputs, types.SiacoinOutput{
Value: outputSum.Sub(amount),
Address: changeAddr,
Expand Down Expand Up @@ -446,6 +449,9 @@ func (s *server) walletsFundSFHandler(jc jape.Context) {
if outputSum < amount {
return nil, errors.New("insufficient balance")
} else if outputSum > amount {
if changeAddr == types.VoidAddress {
return nil, errors.New("change address must be specified")
}
txn.SiafundOutputs = append(txn.SiafundOutputs, types.SiafundOutput{
Value: outputSum - amount,
Address: changeAddr,
Expand Down

0 comments on commit 607337e

Please sign in to comment.