Completed
Pull Request — master (#446)
by thomas
27:20 queued 18:57
created

BitcoinConsensus   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A verify() 0 11 2
1
<?php
2
3
namespace BitWasp\Bitcoin\Script\Consensus;
4
5
use BitWasp\Bitcoin\Script\Interpreter\InterpreterInterface;
6
use BitWasp\Bitcoin\Script\ScriptInterface;
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
     * @return bool
18
     */
19
    public function verify(TransactionInterface $tx, ScriptInterface $scriptPubKey, $flags, $nInputToSign, $amount)
20
    {
21
        $error = 0;
22
        if ($flags & InterpreterInterface::VERIFY_WITNESS) {
23
            $verify = (bool) bitcoinconsensus_verify_script_with_amount($scriptPubKey->getBinary(), $amount, $tx->getBinary(), $nInputToSign, $flags, $error);
24
        } else {
25
            $verify = (bool) bitcoinconsensus_verify_script($scriptPubKey->getBinary(), $tx->getBaseSerialization()->getBinary(), $nInputToSign, $flags, $error);
26
        }
27
28
        return $verify;
29
    }
30
}
31