Completed
Push — master ( 4c44d0...3576cd )
by thomas
8s
created

BitcoinConsensus::verify()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1.0202

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 6
dl 0
loc 11
ccs 8
cts 11
cp 0.7272
crap 1.0202
rs 9.4285
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 36
    public function verify(TransactionInterface $tx, ScriptInterface $scriptPubKey, $flags, $nInputToSign, $amount, ScriptWitnessInterface $witness = null)
21
    {
22 36
        $error = 0;
23 36
        return (bool) bitcoinconsensus_verify_script(
24 36
            $scriptPubKey->getBinary(),
25 36
            $tx->getBinary(),
26 18
            $nInputToSign,
27 18
            $flags,
28
            $error
29 18
        );
30
    }
31
}
32