示例#1
0
 public function testGetValueIn()
 {
     $utxo1 = new Utxo(new OutPoint(new Buffer('a', 32), 0), new TransactionOutput(2, new Script()));
     $utxo2 = new Utxo(new OutPoint(new Buffer('a', 32), 1), new TransactionOutput(4, new Script()));
     $utxo3 = new Utxo(new OutPoint(new Buffer('b', 32), 0), new TransactionOutput(1, new Script()));
     $view = new UtxoView([$utxo1, $utxo2, $utxo3]);
     $transaction = TransactionFactory::build()->spendOutPoint($utxo1->getOutPoint())->spendOutPoint($utxo2->getOutPoint())->spendOutPoint($utxo3->getOutPoint())->output(5, new Script())->get();
     $this->assertEquals(7, $view->getValueIn(Bitcoin::getMath(), $transaction));
     $this->assertEquals(2, $view->getFeePaid(Bitcoin::getMath(), $transaction));
 }
示例#2
0
 /**
  * @param Utxo $utxo
  */
 private function addUtxo(Utxo $utxo)
 {
     $this->utxo[$utxo->getOutPoint()->getTxId()->getBinary() . $utxo->getOutPoint()->getVout()] = $utxo;
 }