Skip to content

Commit 0c85f9a

Browse files
authored
Allow fee to be below minfee, if given explicitly. (algorand#2295)
This makes other txns accept explicitly low fees. Sorry for the code duplication, but I did not want to change libgoal's existing behavior where it increases fee to minfee.
1 parent 34c6686 commit 0c85f9a

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

cmd/goal/application.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,10 @@ var createAppCmd = &cobra.Command{
402402
if err != nil {
403403
reportErrorf("Cannot construct transaction: %s", err)
404404
}
405+
explicitFee := cmd.Flags().Changed("fee")
406+
if explicitFee {
407+
tx.Fee = basics.MicroAlgos{Raw: fee}
408+
}
405409

406410
if outFilename == "" {
407411
// Broadcast
@@ -480,6 +484,10 @@ var updateAppCmd = &cobra.Command{
480484
if err != nil {
481485
reportErrorf("Cannot construct transaction: %s", err)
482486
}
487+
explicitFee := cmd.Flags().Changed("fee")
488+
if explicitFee {
489+
tx.Fee = basics.MicroAlgos{Raw: fee}
490+
}
483491

484492
// Broadcast or write transaction to file
485493
if outFilename == "" {
@@ -553,6 +561,10 @@ var optInAppCmd = &cobra.Command{
553561
if err != nil {
554562
reportErrorf("Cannot construct transaction: %s", err)
555563
}
564+
explicitFee := cmd.Flags().Changed("fee")
565+
if explicitFee {
566+
tx.Fee = basics.MicroAlgos{Raw: fee}
567+
}
556568

557569
// Broadcast or write transaction to file
558570
if outFilename == "" {
@@ -626,6 +638,10 @@ var closeOutAppCmd = &cobra.Command{
626638
if err != nil {
627639
reportErrorf("Cannot construct transaction: %s", err)
628640
}
641+
explicitFee := cmd.Flags().Changed("fee")
642+
if explicitFee {
643+
tx.Fee = basics.MicroAlgos{Raw: fee}
644+
}
629645

630646
// Broadcast or write transaction to file
631647
if outFilename == "" {
@@ -699,6 +715,10 @@ var clearAppCmd = &cobra.Command{
699715
if err != nil {
700716
reportErrorf("Cannot construct transaction: %s", err)
701717
}
718+
explicitFee := cmd.Flags().Changed("fee")
719+
if explicitFee {
720+
tx.Fee = basics.MicroAlgos{Raw: fee}
721+
}
702722

703723
// Broadcast or write transaction to file
704724
if outFilename == "" {
@@ -772,6 +792,10 @@ var callAppCmd = &cobra.Command{
772792
if err != nil {
773793
reportErrorf("Cannot construct transaction: %s", err)
774794
}
795+
explicitFee := cmd.Flags().Changed("fee")
796+
if explicitFee {
797+
tx.Fee = basics.MicroAlgos{Raw: fee}
798+
}
775799

776800
// Broadcast or write transaction to file
777801
if outFilename == "" {
@@ -845,6 +869,10 @@ var deleteAppCmd = &cobra.Command{
845869
if err != nil {
846870
reportErrorf("Cannot construct transaction: %s", err)
847871
}
872+
explicitFee := cmd.Flags().Changed("fee")
873+
if explicitFee {
874+
tx.Fee = basics.MicroAlgos{Raw: fee}
875+
}
848876

849877
// Broadcast or write transaction to file
850878
if outFilename == "" {

cmd/goal/asset.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
"github.com/spf13/cobra"
2424

25+
"github.com/algorand/go-algorand/data/basics"
2526
"github.com/algorand/go-algorand/libgoal"
2627
)
2728

@@ -214,6 +215,10 @@ var createAssetCmd = &cobra.Command{
214215
if err != nil {
215216
reportErrorf("Cannot construct transaction: %s", err)
216217
}
218+
explicitFee := cmd.Flags().Changed("fee")
219+
if explicitFee {
220+
tx.Fee = basics.MicroAlgos{Raw: fee}
221+
}
217222

218223
if outFilename == "" {
219224
wh, pw := ensureWalletHandleMaybePassword(dataDir, walletName, true)
@@ -289,6 +294,10 @@ var destroyAssetCmd = &cobra.Command{
289294
if err != nil {
290295
reportErrorf("Cannot construct transaction: %s", err)
291296
}
297+
explicitFee := cmd.Flags().Changed("fee")
298+
if explicitFee {
299+
tx.Fee = basics.MicroAlgos{Raw: fee}
300+
}
292301

293302
if outFilename == "" {
294303
wh, pw := ensureWalletHandleMaybePassword(dataDir, walletName, true)
@@ -378,6 +387,10 @@ var configAssetCmd = &cobra.Command{
378387
if err != nil {
379388
reportErrorf("Cannot construct transaction: %s", err)
380389
}
390+
explicitFee := cmd.Flags().Changed("fee")
391+
if explicitFee {
392+
tx.Fee = basics.MicroAlgos{Raw: fee}
393+
}
381394

382395
if outFilename == "" {
383396
wh, pw := ensureWalletHandleMaybePassword(dataDir, walletName, true)
@@ -447,6 +460,10 @@ var sendAssetCmd = &cobra.Command{
447460
if err != nil {
448461
reportErrorf("Cannot construct transaction: %s", err)
449462
}
463+
explicitFee := cmd.Flags().Changed("fee")
464+
if explicitFee {
465+
tx.Fee = basics.MicroAlgos{Raw: fee}
466+
}
450467

451468
tx.Note = parseNoteField(cmd)
452469
tx.Lease = parseLease(cmd)
@@ -524,6 +541,10 @@ var freezeAssetCmd = &cobra.Command{
524541
if err != nil {
525542
reportErrorf("Cannot construct transaction: %s", err)
526543
}
544+
explicitFee := cmd.Flags().Changed("fee")
545+
if explicitFee {
546+
tx.Fee = basics.MicroAlgos{Raw: fee}
547+
}
527548

528549
if outFilename == "" {
529550
wh, pw := ensureWalletHandleMaybePassword(dataDir, walletName, true)

cmd/goal/interact.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,10 @@ var appExecuteCmd = &cobra.Command{
601601
if err != nil {
602602
reportErrorf("Cannot construct transaction: %s", err)
603603
}
604+
explicitFee := cmd.Flags().Changed("fee")
605+
if explicitFee {
606+
tx.Fee = basics.MicroAlgos{Raw: fee}
607+
}
604608

605609
if outFilename == "" {
606610
wh, pw := ensureWalletHandleMaybePassword(dataDir, walletName, true)

0 commit comments

Comments
 (0)