Completed
Pull Request — master (#339)
by thomas
105:25 queued 102:16
created

BitcoinConsensus::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace BitWasp\Bitcoin\Script\Consensus;
4
5
use BitWasp\Bitcoin\Script\ScriptInterface;
6
use BitWasp\Bitcoin\Script\ScriptWitnessInterface;
7
use BitWasp\Bitcoin\Transaction\TransactionInterface;
8
9
class BitcoinConsensus implements ConsensusInterface
10
{
11
    /**
12
     * @param TransactionInterface $tx
13
     * @param ScriptInterface $scriptPubKey
14
     * @param int $nInputToSign
15
     * @param int $flags
16
     * @param int $amount
17
     * @param ScriptWitnessInterface|null $witness
18
     * @return bool
19
     */
20
    public function verify(TransactionInterface $tx, ScriptInterface $scriptPubKey, $flags, $nInputToSign, $amount, ScriptWitnessInterface $witness = null)
21
    {
22
        $error = 0;
23
        return (bool) bitcoinconsensus_verify_script(
24
            $scriptPubKey->getBinary(),
25
            $tx->getBinary(),
26
            $nInputToSign,
27
            $flags,
28
            $error
29
        );
30
    }
31
}
32