diff --git a/routes/access_group.go b/routes/access_group.go index 6a5b7278..873f3d01 100644 --- a/routes/access_group.go +++ b/routes/access_group.go @@ -117,7 +117,8 @@ func (fes *APIServer) accessGroupHandler( accessGroupOwnerPkBytes, accessGroupPkBytes, accessGroupKeyNameBytes, accessGroupOperationType, extraData, - requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator()) if err != nil { return fmt.Errorf("problem creating transaction: %v", err) } @@ -397,7 +398,8 @@ func (fes *APIServer) accessGroupMemberHandler( accessGroupOwnerPkBytes, accessGroupKeyNameBytes, accessGroupMembers, accessGroupMemberOperationType, extraData, - requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator()) if err != nil { return fmt.Errorf("problem creating transaction: %v", err) } diff --git a/routes/admin_transaction.go b/routes/admin_transaction.go index 4f6bbceb..7b2f5277 100644 --- a/routes/admin_transaction.go +++ b/routes/admin_transaction.go @@ -273,7 +273,7 @@ func (fes *APIServer) UpdateGlobalParams(ww http.ResponseWriter, req *http.Reque maxNonceExpirationBlockHeightOffset, extraData, requestData.MinFeeRateNanosPerKB, - fes.backendServer.GetMempool(), additionalOutputs) + fes.backendServer.GetMempool(), additionalOutputs, fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("UpdateGlobalParams: Problem creating transaction: %v", err)) return @@ -401,7 +401,7 @@ func (fes *APIServer) SwapIdentity(ww http.ResponseWriter, req *http.Request) { toPublicKey, requestData.MinFeeRateNanosPerKB, - fes.backendServer.GetMempool(), additionalOutputs) + fes.backendServer.GetMempool(), additionalOutputs, fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("SwapIdentity: Problem creating transaction: %v", err)) return diff --git a/routes/associations.go b/routes/associations.go index 14c9f9b7..23f88b5e 100644 --- a/routes/associations.go +++ b/routes/associations.go @@ -252,6 +252,7 @@ func (fes *APIServer) CreateUserAssociation(ww http.ResponseWriter, req *http.Re requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator(), ) if err != nil { _AddInternalServerError(ww, fmt.Sprintf("CreateUserAssociation: problem creating txn: %v", err)) @@ -337,6 +338,7 @@ func (fes *APIServer) DeleteUserAssociation(ww http.ResponseWriter, req *http.Re requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator(), ) if err != nil { _AddInternalServerError(ww, fmt.Sprintf("DeleteUserAssociation: problem creating txn: %v", err)) @@ -804,6 +806,7 @@ func (fes *APIServer) CreatePostAssociation(ww http.ResponseWriter, req *http.Re requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator(), ) if err != nil { _AddInternalServerError(ww, fmt.Sprintf("CreatePostAssociation: problem creating txn: %v", err)) @@ -889,6 +892,7 @@ func (fes *APIServer) DeletePostAssociation(ww http.ResponseWriter, req *http.Re requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator(), ) if err != nil { _AddInternalServerError(ww, fmt.Sprintf("DeletePostAssociation: problem creating txn: %v", err)) diff --git a/routes/exchange.go b/routes/exchange.go index a5f0259d..84a99649 100644 --- a/routes/exchange.go +++ b/routes/exchange.go @@ -766,7 +766,7 @@ func (fes *APIServer) APITransferDeSo(ww http.ResponseWriter, rr *http.Request) txnn, totalInputt, spendAmountt, feeNanoss, err = fes.blockchain.CreateMaxSpend( senderPublicKeyBytes, recipientPub.SerializeCompressed(), uint64(minFeeRateNanosPerKB), - fes.backendServer.GetMempool(), additionalOutputs) + fes.backendServer.GetMempool(), additionalOutputs, fes.backendServer.GetFeeEstimator()) if err != nil { APIAddError(ww, fmt.Sprintf("APITransferDeSo: Error processing MAX transaction: %v", err)) return @@ -1423,7 +1423,7 @@ func (fes *APIServer) _augmentAndProcessTransactionWithSubsidyWithKey( // return an error. totalInput, spendAmount, changeAmount, fees, err := fes.blockchain.AddInputsAndChangeToTransactionWithSubsidy(txn, minFeeRateNanosPerKB, - inputSubsidy, fes.mempool, 0) + inputSubsidy, fes.mempool, 0, fes.backendServer.GetFeeEstimator()) if err != nil { return 0, 0, 0, 0, fmt.Errorf("_augmentAndProcessTransactionWithKey: Problem adding inputs and "+ "change to transaction %v: %v", txn, err) diff --git a/routes/message.go b/routes/message.go index e30f75a8..8f150d4b 100644 --- a/routes/message.go +++ b/routes/message.go @@ -714,7 +714,8 @@ func (fes *APIServer) SendMessageStateless(ww http.ResponseWriter, req *http.Req senderMessagingPublicKey, senderMessagingGroupKeyNameBytes, recipientMessagingPublicKey, recipientMessagingGroupKeyNameBytes, tstamp, extraData, - requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("SendMessageStateless: Problem creating transaction: %v", err)) return @@ -973,7 +974,8 @@ func (fes *APIServer) RegisterMessagingGroupKey(ww http.ResponseWriter, req *htt txn, totalInput, changeAmount, fees, err := fes.blockchain.CreateMessagingKeyTxn( ownerPkBytes, messagingPkBytes, messagingKeyNameBytes, messagingKeySignature, []*lib.MessagingGroupMember{}, extraData, - requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("RegisterMessagingGroupKey: Problem creating transaction: %v", err)) return diff --git a/routes/new_message.go b/routes/new_message.go index f33d09f5..c428c382 100644 --- a/routes/new_message.go +++ b/routes/new_message.go @@ -372,11 +372,12 @@ func (fes *APIServer) sendMessageHandler( // Call CreateNewMessageTxn the core lib to construct the transaction to send a group chat message. // The message type must be lib.NewMessageTypeGroupChat, and operation type is lib.NewMessageOperationCreate. txn, totalInput, changeAmount, fees, err := fes.blockchain.CreateNewMessageTxn( - senderGroupOwnerPkBytes, *lib.NewPublicKey(senderGroupOwnerPkBytes), *lib.NewGroupKeyName(senderGroupKeyNameBytes), *lib.NewPublicKey(senderAccessGroupPkbytes), - *lib.NewPublicKey(recipientGroupOwnerPkBytes), *lib.NewGroupKeyName(recipientGroupKeyNameBytes), *lib.NewPublicKey(recipientAccessGroupPkbytes), - hexDecodedEncryptedMessageBytes, tstamp, - newMessageType, newMessageOperationType, - extraData, requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + senderGroupOwnerPkBytes, *lib.NewPublicKey(senderGroupOwnerPkBytes), + *lib.NewGroupKeyName(senderGroupKeyNameBytes), *lib.NewPublicKey(senderAccessGroupPkbytes), + *lib.NewPublicKey(recipientGroupOwnerPkBytes), *lib.NewGroupKeyName(recipientGroupKeyNameBytes), + *lib.NewPublicKey(recipientAccessGroupPkbytes), hexDecodedEncryptedMessageBytes, tstamp, + newMessageType, newMessageOperationType, extraData, requestData.MinFeeRateNanosPerKB, + fes.backendServer.GetMempool(), additionalOutputs, fes.backendServer.GetFeeEstimator()) if err != nil { return errors.Wrapf(err, "Problem creating transaction: ") } diff --git a/routes/nft.go b/routes/nft.go index c6affae5..d730d16b 100644 --- a/routes/nft.go +++ b/routes/nft.go @@ -262,7 +262,8 @@ func (fes *APIServer) CreateNFT(ww http.ResponseWriter, req *http.Request) { additionalDESORoyaltiesPubKeyMap, additionalCoinRoyaltiesPubKeyMap, extraData, - requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("CreateNFT: Problem creating transaction: %v", err)) return @@ -411,7 +412,8 @@ func (fes *APIServer) UpdateNFT(ww http.ResponseWriter, req *http.Request) { uint64(requestData.MinBidAmountNanos), requestData.IsBuyNow, requestData.BuyNowPriceNanos, - requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("UpdateNFT: Problem creating transaction: %v", err)) return @@ -568,7 +570,8 @@ func (fes *APIServer) CreateNFTBid(ww http.ResponseWriter, req *http.Request) { nftPostHash, uint64(requestData.SerialNumber), uint64(requestData.BidAmountNanos), - requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("CreateNFTBid: Problem creating transaction: %v", err)) return @@ -731,7 +734,8 @@ func (fes *APIServer) AcceptNFTBid(ww http.ResponseWriter, req *http.Request) { bidderPKID.PKID, uint64(requestData.BidAmountNanos), encryptedUnlockableTextBytes, - requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("AcceptNFTBid: Problem creating transaction: %v", err)) return @@ -1649,7 +1653,8 @@ func (fes *APIServer) TransferNFT(ww http.ResponseWriter, req *http.Request) { nftPostHash, uint64(requestData.SerialNumber), []byte(requestData.EncryptedUnlockableText), - requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("TransferNFT: Problem creating transaction: %v", err)) return @@ -1789,7 +1794,8 @@ func (fes *APIServer) AcceptNFTTransfer(ww http.ResponseWriter, req *http.Reques updaterPublicKeyBytes, nftPostHash, uint64(requestData.SerialNumber), - requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("AcceptNFTTransfer: Problem creating transaction: %v", err)) return @@ -1928,7 +1934,8 @@ func (fes *APIServer) BurnNFT(ww http.ResponseWriter, req *http.Request) { updaterPublicKeyBytes, nftPostHash, uint64(requestData.SerialNumber), - requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("BurnNFT: Problem creating transaction: %v", err)) return diff --git a/routes/shared.go b/routes/shared.go index c050007c..2a82de51 100644 --- a/routes/shared.go +++ b/routes/shared.go @@ -397,7 +397,8 @@ func (fes *APIServer) SendSeedDeSo(recipientPkBytes []byte, amountNanos uint64, if utxoView.GlobalParamsEntry != nil && utxoView.GlobalParamsEntry.MinimumNetworkFeeNanosPerKB > 0 { minFee = utxoView.GlobalParamsEntry.MinimumNetworkFeeNanosPerKB } - _, _, _, _, err = fes.blockchain.AddInputsAndChangeToTransaction(txn, minFee, fes.mempool) + _, _, _, _, err = fes.blockchain.AddInputsAndChangeToTransaction(txn, minFee, fes.mempool, + fes.backendServer.GetFeeEstimator()) if err != nil { return nil, fmt.Errorf("SendSeedDeSo: Error adding inputs for seed DeSo: %v", err) } diff --git a/routes/transaction.go b/routes/transaction.go index 6405f370..b3355b50 100644 --- a/routes/transaction.go +++ b/routes/transaction.go @@ -409,7 +409,8 @@ func (fes *APIServer) UpdateProfile(ww http.ResponseWriter, req *http.Request) { requestData.IsHidden, additionalFees, extraData, - requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("UpdateProfile: Problem creating transaction: %v", err)) return @@ -1069,7 +1070,7 @@ func (fes *APIServer) SendDeSo(ww http.ResponseWriter, req *http.Request) { // Create a MAX transaction txnn, totalInputt, spendAmountt, feeNanoss, err = fes.blockchain.CreateMaxSpend( senderPkBytes, recipientPkBytes, requestData.MinFeeRateNanosPerKB, - fes.backendServer.GetMempool(), additionalOutputs) + fes.backendServer.GetMempool(), additionalOutputs, fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("SendDeSo: Error processing MAX transaction: %v", err)) return @@ -1103,7 +1104,8 @@ func (fes *APIServer) SendDeSo(ww http.ResponseWriter, req *http.Request) { // depending on what the user requested. totalInputt, spendAmountt, changeAmountt, feeNanoss, err = fes.blockchain.AddInputsAndChangeToTransaction( - txnn, requestData.MinFeeRateNanosPerKB, fes.mempool) + txnn, requestData.MinFeeRateNanosPerKB, fes.mempool, + fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("SendDeSo: Error processing transaction: %v", err)) return @@ -1212,7 +1214,8 @@ func (fes *APIServer) CreateLikeStateless(ww http.ResponseWriter, req *http.Requ // Try and create the message for the user. txn, totalInput, changeAmount, fees, err := fes.blockchain.CreateLikeTxn( readerPkBytes, postHash, requestData.IsUnlike, - requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("CreateLikeStateless: Problem creating transaction: %v", err)) return @@ -1462,7 +1465,8 @@ func (fes *APIServer) SubmitPost(ww http.ResponseWriter, req *http.Request) { tstamp, postExtraData, requestData.IsHidden, - requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("SubmitPost: Problem creating transaction: %v", err)) return @@ -1615,7 +1619,8 @@ func (fes *APIServer) CreateFollowTxnStateless(ww http.ResponseWriter, req *http // Try and create the follow for the user. txn, totalInput, changeAmount, fees, err := fes.blockchain.CreateFollowTxn( followerPkBytes, followedPkBytes, requestData.IsUnfollow, - requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("CreateFollowTxnStateless: Problem creating transaction: %v", err)) return @@ -1789,7 +1794,8 @@ func (fes *APIServer) BuyOrSellCreatorCoin(ww http.ResponseWriter, req *http.Req requestData.MinDeSoExpectedNanos, requestData.MinCreatorCoinExpectedNanos, // Standard transaction fields - requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("BuyOrSellCreatorCoin: Problem adding inputs and change transaction: %v", err)) return @@ -2053,7 +2059,8 @@ func (fes *APIServer) TransferCreatorCoin(ww http.ResponseWriter, req *http.Requ requestData.CreatorCoinToTransferNanos, receiverPublicKeyBytes, // Standard transaction fields - requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("TransferCreatorCoin: Problem creating transaction: %v", err)) return @@ -2195,7 +2202,8 @@ func (fes *APIServer) SendDiamonds(ww http.ResponseWriter, req *http.Request) { diamondPostHash, requestData.DiamondLevel, // Standard transaction fields - requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("SendDiamonds: Problem creating transaction: %v", err)) return @@ -2214,7 +2222,8 @@ func (fes *APIServer) SendDiamonds(ww http.ResponseWriter, req *http.Request) { diamondPostHash, requestData.DiamondLevel, // Standard transaction fields - requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("SendDiamonds: Problem creating transaction: %v", err)) return @@ -2436,7 +2445,8 @@ func (fes *APIServer) DAOCoin(ww http.ResponseWriter, req *http.Request) { TransferRestrictionStatus: transferRestrictionStatus, }, // Standard transaction fields - requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("DAOCoin: Problem adding inputs and change transaction: %v", err)) return @@ -2571,7 +2581,8 @@ func (fes *APIServer) TransferDAOCoin(ww http.ResponseWriter, req *http.Request) DAOCoinToTransferNanos: requestData.DAOCoinToTransferNanos, }, // Standard transaction fields - requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("TransferDAOCoin: Problem creating transaction: %v", err)) return @@ -3126,6 +3137,7 @@ func (fes *APIServer) createDAOCoinLimitOrderResponse( minFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator(), ) if err != nil { @@ -3372,7 +3384,8 @@ func (fes *APIServer) AuthorizeDerivedKey(ww http.ResponseWriter, req *http.Requ memo, requestData.TransactionSpendingLimitHex, // Standard transaction fields - requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs) + requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator()) if err != nil { _AddBadRequestError(ww, fmt.Sprintf("AuthorizeDerivedKey: Problem creating transaction: %v", err)) return diff --git a/routes/validators.go b/routes/validators.go index 687a668d..5ac46603 100644 --- a/routes/validators.go +++ b/routes/validators.go @@ -125,6 +125,7 @@ func (fes *APIServer) RegisterAsValidator(ww http.ResponseWriter, req *http.Requ requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator(), ) if err != nil { _AddInternalServerError(ww, fmt.Sprintf("RegisterAsValidator: problem creating txn: %v", err)) @@ -199,6 +200,7 @@ func (fes *APIServer) UnregisterAsValidator(ww http.ResponseWriter, req *http.Re requestData.MinFeeRateNanosPerKB, fes.backendServer.GetMempool(), additionalOutputs, + fes.backendServer.GetFeeEstimator(), ) if err != nil { _AddInternalServerError(ww, fmt.Sprintf("UnregisterAsValidator: problem creating txn: %v", err))