btcpayserver / btcpayserver-greenfield-php

28 stars 25 forks source link

StoreOnChainWalletTransaction Getters Don't like up #118

Open utxo-one opened 1 year ago

utxo-one commented 1 year ago

Endpoint returns

object(BTCPayServer\Result\StoreOnChainWalletTransactionList)#661 (1) {
  ["data":"BTCPayServer\Result\AbstractResult":private]=>
  array(1) {
    [0]=>
    array(9) {
      ["transactionHash"]=>
      string(64) "f1689f524f0c0339e6e502f484345604908cbe07ddc1929233dc0cef0e7a42a4"
      ["comment"]=>
      string(0) ""
      ["labels"]=>
      array(0) {
      }
      ["amount"]=>
      string(4) "0.01"
      ["blockHash"]=>
      NULL
      ["blockHeight"]=>
      int(2469676)
      ["confirmations"]=>
      int(1)
      ["timestamp"]=>
      int(1690641768)
      ["status"]=>
      string(9) "Confirmed"
    }
  }
}

But getters are current set to:

<?php

declare(strict_types=1);

namespace BTCPayServer\Result;

class StoreOnChainWalletTransaction extends AbstractResult
{
    public function getDestinations(): StoreOnChainWalletTransactionDestinationList
    {
        $data = $this->getData();
        return new StoreOnChainWalletTransactionDestinationList($data['destinations']);
    }

    public function getFeeRate(): StoreOnChainWalletFeeRate
    {
        $data = $this->getData();
        return new StoreOnChainWalletFeeRate($data['feeRate']);
    }

    public function proceedWithPayjoin(): bool
    {
        $data = $this->getData();
        return $data['proceedWithPayjoin'];
    }

    public function proceedWithBroadcast(): bool
    {
        $data = $this->getData();
        return $data['proceedWithBroadcast'];
    }

    public function noChange(): bool
    {
        $data = $this->getData();
        return $data['noChange'];
    }

    public function rbf(): bool
    {
        $data = $this->getData();
        return $data['rbf'];
    }

    /**
     * @return array strings
     */
    public function selectedInputs(): array
    {
        $data = $this->getData();
        return $data['selectedInputs'];
    }
}

Where did these getters come from? or did we change the endpoint?

ndeet commented 1 year ago

Good catch :+1: seems we overlooked that one. Often the response is the same like the request and likely we did not double check it is the case for the transaction. Fixed by #119