Completed
Pull Request — master (#339)
by thomas
104:00 queued 33:35
created

BitcoinConsensus::verify()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

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 0
cts 3
cp 0
crap 2
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
    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