org.bitcoinj.signers.TransactionSigner Maven / Gradle / Ivy
/*
* Copyright 2014 Kosta Korenkov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bitcoinj.signers;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.crypto.ChildNumber;
import org.bitcoinj.script.Script;
import org.bitcoinj.wallet.KeyBag;
import org.bitcoinj.wallet.Wallet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Implementations of this interface are intended to sign inputs of the given transaction. Given transaction may already
* be partially signed or somehow altered by other signers.
* To make use of the signer, you need to add it into the wallet by
* calling {@link Wallet#addTransactionSigner(TransactionSigner)}. Signer will be serialized
* along with the wallet data. In order for a wallet to recreate signer after deserialization, each signer
* should have no-args constructor
*/
public interface TransactionSigner {
/**
* This class wraps transaction proposed to complete keeping a metadata that may be updated, used and effectively
* shared by transaction signers.
*/
class ProposedTransaction {
public final Transaction partialTx;
/**
* HD key paths used for each input to derive a signing key. It's useful for multisig inputs only.
* The keys used to create a single P2SH address have the same derivation path, so to use a correct key each signer
* has to know a derivation path of signing keys used by previous signers. For each input signers will use the
* same derivation path and we need to store only one key path per input. As TransactionInput is mutable, inputs
* are identified by their scriptPubKeys (keys in this map).
*/
public final Map