Author

Topic: How to generate Bitcoin Gold raw transaction (Read 101 times)

newbie
Activity: 54
Merit: 0
March 06, 2018, 04:31:04 AM
#1
I can not generate valid raw transaction. Anyone know how to properly use ForkID ?
Code:
public static int calcSigHashValue(SigHash mode, boolean anyoneCanPay) {
        Preconditions.checkArgument(SigHash.ALL == mode || SigHash.NONE == mode || SigHash.SINGLE == mode);
        int sighashFlags = mode.value;
        if(anyoneCanPay) {
            sighashFlags |= SigHash.ANYONECANPAY.value;
        }

        return sighashFlags |= SigHash.FORK_ID.value;
    }

    public static int calcSigHashValue(SigHash mode, boolean anyoneCanPay, boolean forkid) {
        Preconditions.checkArgument(SigHash.ALL == mode || SigHash.NONE == mode || SigHash.SINGLE == mode);
        int sighashFlags = mode.value;
        if(anyoneCanPay) {
            sighashFlags |= SigHash.ANYONECANPAY.value;
        }

        if(forkid) {
            sighashFlags |= SigHash.FORK_ID.value;
        }

        return sighashFlags;
    }

and answer is:
Code:
mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation)
Jump to: