public function pay(array $outputs, $changeAddress = null, $allowZeroConf = false, $randomizeChangeIdx = true, $feeStrategy = self::FEE_STRATEGY_OPTIMAL, $forceFee = null, $apiCheckFee = true) {
        if ($this->locked) {
            throw new \Exception("Wallet needs to be unlocked to pay");
        }

        if ($forceFee && $feeStrategy !== self::FEE_STRATEGY_FORCE_FEE) {
            throw new \InvalidArgumentException("feeStrategy should be set to force_fee to set a forced fee");
        }

        $outputs = (new OutputsNormalizer($this->getAddressReader()))->normalize($outputs);

        $txBuilder = new TransactionBuilder($this->addressReader);
        $txBuilder->randomizeChangeOutput($randomizeChangeIdx);
        $txBuilder->setFeeStrategy($feeStrategy);
        $txBuilder->setChangeAddress($changeAddress);

        foreach ($outputs as $output) {
            $txBuilder->addOutput($output);
        }

        $this->coinSelectionForTxBuilder($txBuilder, true, $allowZeroConf, $forceFee);

        if ($forceFee !== null) {
            $apiCheckFee = true;
        }

        return $this->sendTx($txBuilder, $apiCheckFee);
    }
public function pay(array $outputs, $changeAddress = null, $allowZeroConf = false, $randomizeChangeIdx = true, $feeStrategy = self::FEE_STRATEGY_OPTIMAL, $forceFee = null, $apiCheckFee = true) {
        if ($this->locked) {
            throw new \Exception("Wallet needs to be unlocked to pay");
        }

        if ($forceFee && $feeStrategy !== self::FEE_STRATEGY_FORCE_FEE) {
            throw new \InvalidArgumentException("feeStrategy should be set to force_fee to set a forced fee");
        }

        $outputs = (new OutputsNormalizer($this->getAddressReader()))->normalize($outputs);

        $txBuilder = new TransactionBuilder($this->addressReader);
        $txBuilder->randomizeChangeOutput($randomizeChangeIdx);
        $txBuilder->setFeeStrategy($feeStrategy);
        $txBuilder->setChangeAddress($changeAddress);

        foreach ($outputs as $output) {
            $txBuilder->addOutput($output);
        }

        $this->coinSelectionForTxBuilder($txBuilder, true, $allowZeroConf, $forceFee);

        if ($forceFee !== null) {
            $apiCheckFee = true;
        }

        return $this->sendTx($txBuilder, $apiCheckFee);
    }
public function pay ( array $ outputs , $ changeAddress = null , $ allowZeroConf = false , $ randomizeChangeIdx = true , $ feeStrategy = self :: FEE_STRATEGY_OPTIMAL , $ forceFee = null , $ apiCheckFee = true ) { if ( $ this -> locked ) { throw new \ Exception ( "Wallet needs to be unlocked to pay" ) ; } if ( $ forceFee && $ feeStrategy !== self :: FEE_STRATEGY_FORCE_FEE ) { throw new \ InvalidArgumentException ( "feeStrategy should be set to force_fee to set a forced fee" ) ; } $ outputs = ( new OutputsNormalizer ( $ this -> getAddressReader ( ) ) ) -> normalize ( $ outputs ) ; $ txBuilder = new TransactionBuilder ( $ this -> addressReader ) ; $ txBuilder -> randomizeChangeOutput ( $ randomizeChangeIdx ) ; $ txBuilder -> setFeeStrategy ( $ feeStrategy ) ; $ txBuilder -> setChangeAddress ( $ changeAddress ) ; foreach ( $ outputs as $ output ) { $ txBuilder -> addOutput ( $ output ) ; } $ this -> coinSelectionForTxBuilder ( $ txBuilder , true , $ allowZeroConf , $ forceFee ) ; if ( $ forceFee !== null ) { $ apiCheckFee = true ; } return $ this -> sendTx ( $ txBuilder , $ apiCheckFee ) ; }
create, sign and send a transaction

@param array    $outputs             [address => value, ] or [[address, value], ] or [['address' => address, 'value' => value], ] coins to send
value should be INT
@param string   $changeAddress       change address to use (autogenerated if NULL)
@param bool     $allowZeroConf
@param bool     $randomizeChangeIdx  randomize the location of the change (for increased privacy / anonimity)
@param string   $feeStrategy
@param null|int $forceFee            set a fixed fee instead of automatically calculating the correct fee, not recommended!
@param bool     $apiCheckFee         let the API apply sanity checks to the fee
@return string the txid / transaction hash
@throws \Exception
create sign and send a transaction